bugPSPP - Bugs: bug #63606, Underlinking of liboutput

 
 

bug #63606: Underlinking of liboutput

Submitter:  Michael Orlitzky <mjo>
Submitted:  Sun 01 Jan 2023 02:24:20 PM UTC
   
 
Category:  Compilation/Portability Severity:  5 - Average
Status:  Fixed Assigned to:  None
Open/Closed:  Closed Release:  None
Effort:  0.00
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 17 Feb 2023 04:12:51 PM UTC, comment #3: 

Thanks for the info!

Ben Pfaff <blp>
Group administrator
Fri 17 Feb 2023 01:22:43 AM UTC, comment #2: 

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 :)

Michael Orlitzky <mjo>
Fri 17 Feb 2023 12:25:19 AM UTC, comment #1: 

Thanks for the report. I don't understand this issue, but I added $(CAIRO_LIBS) and $(LIBXML2_LIBS) to that variable in Git.

I'd like to hear about why PSPP doesn't build from Git.

Ben Pfaff <blp>
Group administrator
Sun 01 Jan 2023 02:24:20 PM UTC, original submission:  

We have an old bug in Gentoo,

  https://bugs.gentoo.org/732048

for an older version of pspp. While trying to reproduce this with either the lld or mold linkers and "-Wl,--as-needed" in my LDFLAGS, I get the following build failure:


(cd "./examples" \
         && "/var/lib/portage/tmp/portage/sci-mathematics/pspp-1.6.2-r1/work/pspp-1.6.2/src/ui/terminal/pspp" ../doc/pspp-figures/chisquare.sps -o - -O format=spv) > doc/pspp-figures/chisquare.spv.tmp
/var/lib/portage/tmp/portage/sci-mathematics/pspp-1.6.2-r1/work/pspp-1.6.2/src/ui/terminal/.libs/pspp: symbol lookup error: /var/lib/portage/tmp/portage/sci-mathematics/pspp-1.6.2-r1/work/pspp-1.6.2/src/.libs/libpspp-1.6.2.so: undefined symbol: pango_font_description_free


So, the build of pspp succeeded, but it has some unresolved symbols, stemming from libpspp. I've tracked this down, and I believe it's due to $(CAIRO_LIBS) being missing from src_output_liboutput_la_LIBADD. I wasn't able to get the git build working, but hacking $(CAIRO_LIBS) into that variable in the top-level Makefile fixed the issue for me.

Looking through the source, it looks like liboutput should also be linked with libxml2, but there are presently no observable problems caused by it. However, the Gentoo bug report that started my investigation looks like it might have been caused by that, so if liboutput is indeed using libxml2 stuff, I think the libxml2 libs should also be appended to src_output_liboutput_la_LIBADD to prevent similar issues in the future.

Michael Orlitzky <mjo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by blp (Posted a comment)
  • -email is unavailable- added by mjo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-02-17 blp StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code