Executable size difference between clang and gcc9
Dewayne Geraghty
dewaynegeraghty at gmail.com
Wed Nov 20 03:09:55 UTC 2019
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... :)
More information about the freebsd-hackers
mailing list