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

Re: RFS: avant-window-navigator 0.2.1



On 03/02/2008, Julien Lavergne wrote:
> That's something I wanted to do, but I didn't find a good way to do
> that. I tried to replace ${shlibs:Depends} with only necessary
> library, but dpkg-shlibdeps still get the same warnings.

Oh, no, you definitely don't want to touch that!

The idea is to get rid of extra/unneeded “-lfoo -lbar …” in the
upstream Makefile, so as to link only against the libraries that are
actually used.

Sometimes, just deleting an -lfoo would do. But more commonly, the
build system doesn't allow you to use fine-grained library
dependencies. That's where LDFLAGS=-Wl,--as-needed is your friend,
since it tells the linker to forget about the unused libraries
(resulting in less NEEDED entries, and happy dpkg-shlibdeps).

*BUT* that might break the resulting binaries, since (depending on
various things, like build/link options), you may end up with
undefined references, which result in runtime crashes.

To avoid that, you probably want to use another LDFLAG(S):
-Wl,-z,defs, which explicitely forbids such undefined references.

Note that this might still break the build system, but that *is* a
good thing. Usually, the problem is that the intermediate builds are
broken, since the resolution of undefined references is (again, in
some conditions) postponed to the final linking. By using this option,
you explicitely forbid any single undefined reference (including in
the intermediate targets), which means that you might sometimes have
to modify the Makefiles to add some -lfoo or -lbar, or e.g. add
TARGET_LINK_LIBRARIES() in cmake build systems.

That's a bit of work, but you'll probably end up with less
dependencies (expressed in less Depends:), which is obviously
(installed size, testing migration, etc.) a good thing.

Cheers,

-- 
Cyril Brulebois

Attachment: pgpzZZeI8ZmUc.pgp
Description: PGP signature


Reply to: