Static linking considered harmful

Ulrich Drepper drepper at redhat.com
Thu Nov 23 00:33:27 UTC 2006


Japheth J.C. Cleaver wrote:
> I don't see how the first two paragraphs here comport with the remaining
> ones. If people are going to be able to compile things statically then
> they need to be able to.

The first paragraph is about linking the code which comes from your 
package statically.  I.e., only link those libraries statically and 
everything else dynamic.  Static linking is no all-or-nothing decision 
in case you didn't know.


> (Our mail server saw a
> performance boost of about 20% when we statically linked our process chain.)

I *very* much doubt those numbers.  Using PIC and the runtime linker 
does not add that much overhead.  Never has, never will.  If you compare 
apples and oranges you can come up with such numbers, of course.


> We should not remove the ability to easily install static libraries from
> the Fedora/Fedora-Extras system simply due to someone's crusade against
> it. If a Fedora user is to be trusted with Development Packages, then
> they should be trusted to "know what they're doing" wrt dynamic vs.
> static linking.

No.  And it can be proved easily: name all the libraries used in all the 
builds of the statically linked apps.  And automate rebuilding when any 
of those changes.  Fact is, nobody does this.  Only through dynamic 
linking can you take immediately advantage of the new builds.

And this is not "someone", it's everybody who understand a bit about 
this.  And it's not just Fedora or Red Hat, not even only Linux. 
Solaris is also pushing hard to eradicate static linking with system 
libraries.

Again, nobody is taking away the possibility to create partially 
statically linked apps.  I'm all for that as long as no maintenance 
borders are crossed.  This is what -Wl,-B,static and -Wl,-B-dynamic are for.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖




More information about the fedora-devel-list mailing list