libtool & dependency_libs in *.la files

Richard W.M. Jones rjones at redhat.com
Fri Nov 26 15:52:37 UTC 2010


[Apologies if this has been covered before, but I cannot find anything
in the archives]

When building a package I noticed that binaries in the package were
still getting unnecessary DT_NEEDED entries.  Example:

  binary ---> depends only on libfoo.so
                                 |
				 |      libfoo depends on
                                 `----> libbar.so

but the binary was getting built with DT_NEEDED entries for both
'libfoo.so' and 'libbar.so', which is wrong.

ld had the '--no-add-needed' flag, so ld wasn't adding the extra
DT_NEEDED entry.  (See:
http://fedoraproject.org/wiki/UnderstandingDSOLinkChange )

I tracked this down to our old friend libtool.  Basically because the
binary and the library were being built out of the same source tree,
there was a 'libfoo.la' file which contained:

  dependency_libs='libbar.so'

and this causes libtool to decide to "helpfully" add -lbar to the
linker command line, even though it is completely unnecessary.

(This is not a problem if libfoo and the binary were in separate
source packages, because we already nuke the *.la files, which avoids
this brokenness across different packages.  The problem is
specifically confined to the case where binaries and libraries are
built from the *same* source package).

I was able to work around this by adding a libtool wrapper which set
dependency_libs='' in the *.la file.

I notice that Debian, Ubuntu and Gentoo have proposed something
similar:

http://wiki.debian.org/ReleaseGoals/LAFileRemoval
http://lists.debian.org/debian-devel/2009/08/msg00783.html
http://lists.debian.org/debian-release/2009/08/msg00217.html
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586082

except they are unilaterally modifying libtool downstream instead of
using my hackish wrapper, which is a better idea.  Apparently either
no one has tried to get this upstream, or libtool developers weren't
listening.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top


More information about the devel mailing list