[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Top 20 unnecessary dependencies [was: Re: A plan to get rid of unnecessary package dependencies]



Mikhail Gusarov wrote:
> You (kmccarty@Princeton.EDU) wrote:
> 
>  KBM> Most of these are X-related, suggesting that quite a lot of .la
>  KBM> and .pc files are pretty indiscriminate about which X libs they
>  KBM> link in.
> 
> Will this problem disappear if end programs will pass --as-needed flag
> to the ld command line?

In many cases, yes, but there may be some breakage.  I'm by no means a
binutils expert, but following are the caveats I'm aware of.

A little before the release of Sarge, there was a discussion about
whether to do this by default:
	http://lists.debian.org/debian-devel/2005/04/msg00002.html

There is some concern that ld may strip away libraries that provide
constructors and destructors using this option.  See Gabor's emails in
the old thread:
	http://lists.debian.org/debian-devel/2005/04/msg00002.html
and in this thread:
	http://lists.debian.org/debian-devel/2006/09/msg00908.html

There is also concern that some libraries do *not* link against other
libraries they need, leaving it up to the end program to link them in.
Suppose libA.so uses symbols from libB.so, but doesn't link it.  (This
is arguably broken, but it happens.  But IMO a bug should be filed on
such libraries.)  Someone then writes program C, which uses symbols only
from libA.so, not from libB.so.  Nevertheless, linking program C
requires -lA -lB.  I think --as-needed will break in those cases.

Further, --as-needed doesn't work when creating shared libraries (at
least it didn't at the time I experimented with it; instead it stripped
out *all* NEEDED entries from the .so file!) so it won't help with those
cases of unnecessary dependencies.

Finally, if you use --as-needed in a Debian package, you'll want to have
a versioned Build-Depends on binutils (>= 2.16.1cvs20050902-1) to ensure
you avoid http://bugs.debian.org/320697 .

regards,

-- 
Kevin B. McCarty <kmccarty@princeton.edu>   Physics Department
WWW: http://www.princeton.edu/~kmccarty/    Princeton University
GPG: public key ID 4F83C751                 Princeton, NJ 08544



Reply to: