bug-gnu-pspp
[Top][All Lists]
Advanced

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

PSPP-BUG: [bug #63606] Underlinking of liboutput


From: Michael Orlitzky
Subject: PSPP-BUG: [bug #63606] Underlinking of liboutput
Date: Thu, 16 Feb 2023 20:22:43 -0500 (EST)

Follow-up Comment #2, bug #63606 (project pspp):

Thanks!

Passing --as-needed to the linker will ignore any -lfoo flags when libfoo is
not actually used by the thing being linked. For why we might want that...
packages like GTK include everything under the sun in their pkg-config --libs
output. If I'm linking my own program against gtk itself (rather than, say,
cairo), then I don't want my program being linked against cairo. In
particular, if cairo's soname changes, I don't care. But without --as-needed,
linking against cairo is exactly what will happen, because -lcairo gets output
by gtk's pkg-config --libs. And IIRC my program will break when libcairo gets
bumped, even though I'm not using libcairo!

So that's what --as-needed does and why people (especially a source-based
distro like Gentoo) might want to use it.

The downside is that it can break things that work without it. Suppose
executable A links to library B, and library B uses functions from library C.
Without --as-needed, you can forget to tell the build system that library B
needs library C. So long as you link the executable with -lB -lC, the whole
thing will work out just fine. But with --as-needed, the linker will notice
that "A" doesn't need "C", and drop the -lC. Which now breaks library B,
because it's expecting library C to be there.

That's what happened here and the fix is usually just a missing LIBADD to let
the linker know that one library needs another.

As for the git build: I just needed to RTFM and use the Smake file :)


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63606>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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