Fwd: Re: Fix for --as-needed
Thiago Macieira
thiago.macieira at kdemail.net
Sun Nov 21 23:23:10 GMT 2004
Hello,
I've come up with a patch for the problems people were having with
--as-needed.
Description of the problem:
- meinproc uses libkio
- libkio uses libkdeui
- meinproc does not use libkdeui directly
When linking meinproc, libtool builds the whole dependency list, so that
both libkdeui and libkio are listed. In special, note that since libkdeui
is a dependency of libkio, it comes first.
The linker then links meinproc and, without --as-needed, adds to the
file's header:
NEEDED libkdeui.so.4
NEEDED libkio.so.4
With that, libkdeui is loaded first. When meinproc is used before the
libraries are installed, libtool relinks the program and add
$(builddir)/kdeui/.libs to the executable's RPATH. When the program is
then run, the correct version of libkdeui is found.
What happened when --as-needed got introduced is that, since meinproc
doesn't use libkdeui directly, the linker does not add the NEEDED symbol
to the program's header. Therefore, libkdeui is loaded only because
libkio uses it.
The problem in that case is that meinproc's RPATH does *not* influence the
search path for libkdeui. What's worse, libkio.so.4's RPATH cannot be
overriden.
My solution consists in:
1) adding the --enable-new-dtags flag to the linker, if supported. This
makes GNU ld emit RUNPATH directives as well as RPATH. The consequence is
twofold:
a) RPATH is ignored
b) RUNPATH is overrideable by LD_LIBRARY_PATH at run-time
2) making libtool's stub script use LD_LIBRARY_PATH as well as relinking.
(In truth, it probably doesn't have to relink, but I didn't want to make
such an intrusive change)
These two changes make the correct library be loaded.
3) make the --as-needed flag usage default to yes only if
--enable-new-dtags is present as well
The patch is attached. Tests here and with a guin...err... "test subject"
show it solves the problem. It changes kde-common/admin/acinclude.m4.in,
so I can't commit. Someone please review, test and commit if acceptable.
---------- ----------
Subject: Re: Fix for --as-needed
Date: Dom 21 Nov 2004 20:19
From: Mauricio Bahamonde <elkrammer at vtr.net>
To: Thiago Macieira <thiago at macieira.info>
Thiago,
Your patch seems to succesfully correct the problem, it worked fine
here. You should commit.
Thanks a lot for all your help.
Greetings,
--
Mauricio Bahamonde
<elkrammer at vtr.net>
-------------------------------------------------------
--
Thiago Macieira - Registered Linux user #65028
thiago (AT) macieira (DOT) info
ICQ UIN: 1967141 PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: as_needed-fix.diff
Type: text/x-diff
Size: 2175 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041121/e212ef7c/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041121/e212ef7c/attachment.sig>
More information about the kde-core-devel
mailing list