[Top][All Lists]

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

Re: RFC: proposal for indirect deplibs

From: Alexandre Oliva
Subject: Re: RFC: proposal for indirect deplibs
Date: 22 Dec 2004 17:45:49 -0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

On Nov 24, 2004, Ralf Wildenhues <address@hidden> wrote:

> On the other hand, on systems without a needed-following linker, it is
> necessary to explicitly list all dependent libraries.

It's a bit more complicated than this, actually.  Some linkers are
smart enough to look for dependencies, but they look for them in
different directories than those listed in -L.  GNU ld, for example,
looks for DT_NEEDED libs in -rpath-link, so unless you pass
-rpath-link for the needed libs, linking might pick up an old version
of a library that happens to be in say /usr/lib.  However, if you link
the lib in explicitly with -l, then it finds it in the -L-specified
search path.  If you build and install libs in multiple dirs, this can
get you into a very confusing situation, unless libtool takes care of
issuing the corresponding -rpath-link flags.

Also, the encoding of dependent libraries is only possible in dynamic
libraries, so you have to know with 100% of certainty whether the
linker is going to link a library statically or dynamically.  This
means taking flags such as -Bstatic and -Bdynamic into account,
otherwise you may end up refraining from linking in the dependencies
of a libtool library because you know the linker will, but then the
linker ends up using the static library, and then your assumption
falls apart.

Personally, I'd rather not attempt to second-guess the linker, and
instead use the --as-needed flag newly-added to GNU ld to implement
the libtool semantics you suggest, or perhaps even use --as-needed by
default whenever it's available.  This would require some portability
checking on whether dynamic loaders can actually handle inter-library
dependencies properly.  We can probably assume GNU/Linux dynamic
loaders do, but I wouldn't assume the same for other OSs, particularly
non-ELF ones.

Alexandre Oliva   
Red Hat Compiler Engineer   address@hidden,}
Free Software Evangelist  address@hidden,}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]