Eliminating static binaries (Was: Unwanted RPM dependencies)

Chris Adams cmadams at hiwaay.net
Wed Jun 6 13:41:26 UTC 2007


Once upon a time, Patrice Dumas <pertusus at free.fr> said:
> Even if dyn libraries are shared, the code that is needed to perform the
> link may add more to the executable. You can try with a simple 'hello
> world' that use printf.

You should probably test that before you post.  I would say this is the
smallest possible regular C program:

$ cat x.c
int main ()
{
	return 0;
}
$ gcc -o x-dyn x.c
$ gcc -static -o x-stat x.c
$ strip x-dyn x-stat
$ ls -l x-dyn x-stat
-rwxr-xr-x 1 cmadams users   2816 Jun  6 08:38 x-dyn
-rwxr-xr-x 1 cmadams users 459492 Jun  6 08:38 x-stat
$ 

I don't forsee a static executable being smaller than a dynamic
executable in the real world.  It is possible that somebody could
hand-build (e.g. no gcc, ld, etc.) such an executable, but that doesn't
really count (since that isn't done in the real world).

-- 
Chris Adams <cmadams at hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.




More information about the fedora-devel-list mailing list