Eliminating static binaries (Was: Unwanted RPM dependencies)

Patrice Dumas pertusus at free.fr
Thu Jun 7 06:32:39 UTC 2007

On Wed, Jun 06, 2007 at 08:41:26AM -0500, Chris Adams wrote:
> 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).

given that the dynamic executable is 2816 bytes, the static one could be 
smaller, however it is way bigger. In fact it seems to me (but I don't
rerally know a lot about those things, I was only saying something I saw
elsewhere) that it is way too bigger for that difference to be explained by 
static linking, there is something else happening there. 

In any case I stand corrected.


More information about the fedora-devel-list mailing list