http://bugs.freedesktop.org/show_bug.cgi?id=21777





--- Comment #9 from Dan Nicholson <dbn.li...@gmail.com>  2009-05-19 11:15:57 
PST ---
(In reply to comment #8)
> After digging into this for an hour straight (without knowing about this
> bug...), my brain hurts a bit but I'd be interested in knowing who's to blame:
> libtool, ld or Debian ;)

Just to boil down the test case.

Works: gcc -Wl,--as-needed -o .libs/dristat dristat.o ../libdrm/.libs/libdrm.so
-lrt

Fails: gcc -Wl,--as-needed -o .libs/dristat dristat.o ../libdrm/.libs/libdrm.so

There's two things going on.

1. The vanilla behavior of libtool is to add all dependency_libs in a .la file
to the link command line. So, for the case of libdrm.la, this means programs
will be linked explicitly to -lrt like in the Works case. With binutils ld,
this is not necessary as the linker will search DT_NEEDED entries in the
libraries on the command line and add them to ensure symbols are resolved.

And, of course, doing what libtool is doing can be harmful as your program
picks up extra NEEDED entries for libraries it doesn't directly use symbols
from. Hence, overlinking. So, debian's patch makes libtool skip dependency_libs
when linking a program. This should be a good thing, but here it exposes what I
think is a bug in ld.

2. Here dristat is using drmOpenMinor, which is a local symbol in libdrm.so. ld
seems to react to this by including the entire shared object into the
executable. Compare drmstat, which does not use internal symbols, to dristat:

$ nm .libs/drmstat | grep drmGetVersion
                 U drmGetVersion
$ nm .libs/dristat | grep drmGetVersion
0000000000405060 T drmGetVersion

Not such a big deal, except that then ld doesn't process the DT_NEEDED entries
in libdrm.so when linking dristat. Subsequently, it fails to add librt.so.1 and
then fails to resolve clock_gettime.

To work around this, we just explicitly link dristat to -lrt.


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to