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

Re: -Wl,--as-needed considered possibly harmful

On Sun, Dec 09, 2007 at 11:31:19PM +0100, Romain Beauxis wrote:
> Le Sunday 09 December 2007 22:45:46 Nikita V. Youshchenko, vous avez écrit :
> > > However, most of the applications don't need to link against theora and
> > > speex.

> > Doesn't libshout reference symbols from libspeex and libtheora?

> Yes

> > If it does, resulting binary must be linked against both these libraries.
> > Unresolved symbols within binaries are really bad, because they will once
> > be unexpectedly called (e.g. in some init or deinit or error-handling), and
> > binary will crash, leaving user data unsaved.

> I think you are confusing the issue.

> Yes, libshout uses symbols from libspeex:
> objdump -x /usr/lib/libshout.so | grep NEEDED | grep speex
>   NEEDED      libspeex.so.1

> However, not all applications uses those symbols in their current code, so 
> they do not need to be linked against speex themselves.

And therefore, the scripts generating dependency information for dynamically
linking to libshout should *not* list libspeex or libtheora, and
consequently there's no need for -Wl,--as-needed.  (When statically linking,
-Wl,--as-needed is also irrelevant, because unused symbols from static libs
are already discarded.)

> Of course, correct dependencies will be pulled when requesting libshout.

No, currently the dependencies pulled in are overbroad.  Please fix
/usr/lib/pkgconfig/shout.pc to list the dependent libraries in
"Requires.private", not in "Requires".

Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek@ubuntu.com                                     vorlon@debian.org

Reply to: