--as-needed compile option?

Joe Orton jorton at redhat.com
Thu Mar 31 15:24:38 UTC 2005


On Thu, Mar 31, 2005 at 10:10:12AM -0500, Jakub Jelinek wrote:
> On Thu, Mar 31, 2005 at 04:04:17PM +0100, Joe Orton wrote:
> > So when I link httpd using -lssl -lcrypto, despite the fact that httpd
> > itself does not use any symbols from those libraries, I *must* get an
> > httpd with DT_NEEDED of libssl and libcrypto to ensure both stay mapped
> > for the lifetime of the process.  That's why use of --as-needed must
> > only be done as directed by the application.
> 
> Well, perhaps it could be added also by the tools that carelessly
> insert dozens of libraries on link command line although they aren't
> really needed (I mean libtool and pkg-config), but it certainly shouldn't
> be the linker's default.
> I.e. if you add libfoo.la on libtools link line, it would add -lfoo without
> --as-needed and whatever other libraries that .la would add in would be
> linked between --as-needed and --no-as-needed.

In general if I have a library libfoo whose ABI is dependent on the
library of another library libbar, it is not safe to presume that just
linking my program baz against just "-lfoo" means that baz is immune to
ABI changes in libbar, just because it uses no symbols from it.  (since
a structure or type change might propagate through)

So again, in that case, the separation between dependent libraries which
affect the library ABI and those which don't must be driven by the
library authors on a case-by-case basis; the tools can just offer an
interface so that the library author can express the distinction.

There was discussion on the libtool list about how to do this a while
back but I don't think anything has been done yet.

joe




More information about the fedora-test-list mailing list