Static linking considered harmful

Patrice Dumas pertusus at free.fr
Wed Nov 22 11:39:40 UTC 2006


On Wed, Nov 22, 2006 at 05:56:07AM -0500, Jakub Jelinek wrote:
> On Wed, Nov 22, 2006 at 11:39:35AM +0100, Patrice Dumas wrote:
> > On Wed, Nov 22, 2006 at 11:34:14AM +0100, Arjan van de Ven wrote:
> > > 
> > > actually static linking DECREASES that portability !!
> > 
> > Are you saying that you can compile a program dynamically and run it
> > on old redhat, centos, old debian, mandrake and fedora core boxes?
> > I tried, it fails, while statically linked programs are fine (at least 
> > numerical models).
> 
> Yes and no.
> 
> Assuming if you link statically on very recent distro that your program
> will work on any old Linux distro is just very bad assumption.
> E.g. each glibc is configured for some minimal kernel version, if you
> attempt to run the program on older kernel some functions will crash,
> misbehave or the program won't start at all.  E.g. FC5+ glibc is
> configured for 2.6.9 and later kernels, so running it on say FC1
> just isn't going to fly.

Ok, my tests where from pre-FC5.

> If you want to create a program that will work on older distributions
> (within reasonable limits, e.g. glibc 2.0 or libc5 or a.out stuff
> isn't supported anymore in recent FCs), just compile/link against

I am not targeting such old systems. Assuming kernel 2.4 and glibc
above 2.0 is very reasonable, computers with oldest softs are likely
to be slow anyway.

> the oldest glibc etc. you want to support, whether by installing
> an old distro in the chroot or by installing and linking against
> something like compat-glibc (these days only present in RHEL,
> but could very well be revived for FC as well), using compat-gcc
> (on FC6 that has e.g. a side-effect of using -Wl,--hash-style=sysv
> etc.).

That would be cool to be able to do that. I indeed tested that on 
mandrake 9.2 it fails the way you describe (with kernel too old message).
In the mean time it is allready interesting to be able to run on any
computer with kernel > 2.6.9, even if the libraries are not installed
or there is no compatibility between the shared libraries. And once more
that can only be achieved by statically compiling.

--
Pat




More information about the fedora-devel-list mailing list