Date: Wed, 20 Nov 2019 14:09:24 +1100 From: Dewayne Geraghty <dewaynegeraghty@gmail.com> To: freebsd-hackers@freebsd.org Subject: Executable size difference between clang and gcc9 Message-ID: <CAGnMC6ptpLNTHMXXYroV28WLN7dqLKYSL1jCsa=h5uZZmuLVZQ@mail.gmail.com>
index | next in thread | raw e-mail
I noticed the executable a size difference between clang 8.0.1 and gcc
9.2.0 of a simple test code, build on FreeBSD12.1S (r353671M) below.:
Differences in object code seem reasonable:
# clang -O2 -march=haswell -flto -c "qdate.c"
-rw-r----- 1 root wheel 3896 8 Nov 12:59 qdate.o
# gcc9 -O2 -march=haswell -flto -c "qdate.c" ; ls -l qdate.o a.out
-rw-r----- 1 root wheel 5256 8 Nov 13:00 qdate.o
But the executable sizes?
# clang -O2 -march=haswell -flto "qdate.c" ; ls -l qdate.o a.out
-rwxr-x--- 1 root wheel 16360 8 Nov 13:10 a.out
# gcc9 -O2 -march=haswell -flto "qdate.c" ;ls -l qdate.o a.out
-rwxr-x--- 1 root wheel 8736 8 Nov 13:09 a.out
Is this size variation expected, and what is contributing to this
difference?
The executeables are the same size with/without lto; and both link to
/lib/libc
a.out:
libc.so.7 => /lib/libc.so.7 (0x800647000)
*/* Sample code*/*
*#include <stdio.h>#include <sys/time.h>int main (int argc, char **argv)
{ struct timeval tv; gettimeofday(&tv, NULL); if (argc > 1)
printf("%ld.%ld\n",tv.tv_sec,tv.tv_usec); else printf("%ld\n",tv.tv_sec);}*
The verbose compile/link command is available at
http://www.heuristicsystems.com/FreeBSD-compiler/
contains: clang.lis gcc9.lis qdate.c
PS who said anything placing malware on the end of executables, at the
compilation step? Really I'm not paranoid... :)
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGnMC6ptpLNTHMXXYroV28WLN7dqLKYSL1jCsa=h5uZZmuLVZQ>
