* From: "Luka Z. Gerzic" <> * To: * Date: Fri, 12 Sep 2003 20:27:34 +0200 * Subject: main() static/dynamic To: glibc Developers, hi, sorry to bother you at alpha list, about this, but I didn't have any success in subscribing in glibc mailing lists (both bug and hack), so I decided to ask at alpha list about this odd behavior (as mr. Ulrich Drepper directed me to do so). My friend Milos Marceta and I where trying to compile some sources both on freebsd and linux for experimental reasons, when we found one very interesting thing about compiler & glibc optimisation. The *bsd binaries in -static mode where 10 times smaller then linux static binaries. We where stunned. We then created empty program with no functions, with only main() : echo "int main() {}" > linux.c gcc -o linux linux.c gcc -static -o linux-static linux.c strip linux-static ls -al And here are results from plain gcc/glibc (default install): You will probably notice that only static version is striped. system | arch. | glibc ver. | dynamic | static strip | +--------------+-------+--------------+-----------+--------------+ Slackware 7.1 | x86 | 2.91.66 | 11505 | 205360 | Slackware 8 | x86 | 2.95.3 | 13102 | 339360 | Slackware 9 | x86 | 3.2.2 | 10960 | 413360 | Debian 3 | ia64 | ia64 3.3 | 6831 | 848600 | Debian 3 | alpha | 2.95.4 | 8669 | 518224 | Red Hat 7.2 | alpha | 2.96 | 178107 | 493464 | SuSe 7.1 | alpha | 2.96 | 167243 | 451560 | FreeBSD 4.8 | x86 | 2.95.4 | 4180 | 12284 | NetBSD 1.6 | x86 | 2.95.3 | 5737 | 12500 | OpenBSD 3.2 | x86 | 2.95.3 | 25306 | 20480 | HP-UX B.11.11 |hppa64 | 3.2 | 8440 | 234832 | SunOS 5.6 | sparc | 2.8.1 | 24156 | 77364 | SunOS 5.8 | sparc | 3.2 | 6164 | 77312 | +--------------+-------+--------------+-----------+--------------+ Slackware 8 Linux 2.2.25 Reading specs from /usr/lib/gcc-lib/i686-slackware-linux/2.95.3/specs gcc version 2.95.3 20010315 (release) -rwxr-xr-x 1 stinger users 13102 Sep 12 17:36 linux* -rwxr-xr-x 1 stinger users 339360 Sep 12 17:38 linux-static* Slackware 9 Linux 2.4.21 Reading specs from /usr/lib/gcc-lib/i686-slackware-linux/3.2.2/specs gcc version 3.2.2 -rwxr-xr-x 1 stinger users 10960 Sep 12 17:42 linux* -rwxr-xr-x 1 stinger users 413360 Sep 12 17:42 linux-static* Slackware 7.1 Linux 2.2.25 Reading specs from /usr/lib/gcc-lib/i686-slackware-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) -rwxr-xr-x 1 stinger users 11505 Sep 12 16:36 linux* -rwxr-xr-x 1 stinger users 205360 Sep 12 16:38 linux-static* Debian GNU/Linux 3.0 Linux 2.4.18 ia64 Reading specs from /usr/local/lib/gcc-lib/ia64-unknown-linux-gnu/3.3/specs -rwxr-xr-x 1 stinger adm 6831 Sep 12 11:34 linux -rwxr-xr-x 1 stinger adm 848600 Sep 12 11:34 linux-static Debian GNU/Linux 3.0 Linux 2.4.18-smp alpha unknown Reading specs from /usr/lib/gcc-lib/alpha-linux/2.95.4/specs gcc version 2.95.4 20011002 (Debian prerelease) -rwxr-xr-x 1 stinger adm 8669 Sep 12 11:37 linux -rwxr-xr-x 1 stinger adm 518224 Sep 12 11:37 linux-static RedHat Linux 7.2 Linux 2.4.9-32.5smp alpha unknown Reading specs from /usr/lib/gcc-lib/alpha-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-108.7.2) -rwxr-xr-x 1 stinger admin 178107 Sep 12 11:41 linux -rwxr-xr-x 1 stinger admin 493464 Sep 12 11:41 linux-static SuSE Linux 7.1 Linux 2.2.19 alpha unknown Reading specs from /usr/lib/gcc-lib/alpha-suse-linux/2.96/specs gcc version 2.96 20000731 (SuSE Linux 7.1/Alpha) -rwxr-xr-x 1 stinger users 167243 Sep 12 10:44 linux -rwxr-xr-x 1 stinger users 451560 Sep 12 10:44 linux-static FreeBSD 4.8-RELEASE gcc version 2.95.4 20020320 [FreeBSD] -rwxr-xr-x 1 stinger energy 4180 Sep 12 11:46 bsd -rwxr-xr-x 1 stinger energy 12284 Sep 12 11:46 bsd-static NetBSD NetBSD 1.6 (GENERIC) gcc version 2.95.3 20010315 (release) (NetBSD nb3) -rwxr-xr-x 1 stinger admin 5737 Sep 12 11:48 bsd -rwxr-xr-x 1 stinger admin 12500 Sep 12 11:48 bsd-static OpenBSD 3.2 GENERIC#25 i386 Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd3.2/2.95.3/specs gcc version 2.95.3 20010125 (prerelease) -rwxr-xr-x 1 stinger users 25306 Sep 12 11:49 bsd -rwxr-xr-x 1 stinger users 20480 Sep 12 11:49 bsd-static HP-UX B.11.11 U 9000/800 unlimited-user license Reading specs from /usr/local/pa20_64/lib/gcc-lib/hppa64-hp-hpux11.00/3.2/specs gcc version 3.2 20020708 (experimental) -rwx------ 1 stinger gost 8440 Sep 12 11:51 linux -rwx------ 1 stinger gost 234832 Sep 12 11:51 linux-static SunOS sun 5.8 Generic_108528-13 sun4m sparc sun4m Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2/specs gcc version 3.2 -rwxr-xr-x 1 root other 6164 Sep 12 17:01 solaris_sun4m-dinamic -rwxr-xr-x 1 root other 77312 Sep 12 17:01 solaris_sun4m-static SunOS sun 5.6 Generic_105181-05 sun4m sparc sun4m Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs gcc version 2.8.1 -rwxr-xr-x 1 root other 24156 Sep 12 14:06 solaris_dinamic -rwxr-xr-x 1 root other 77364 Sep 12 14:06 solaris_static Can you please give us some explanation for this? Thank you! Best regards, Luka Z. Gerzic