Bug 227891 - print/cups: -Wl,-R/usr/local/lib returned by cups-config changes library search order
Summary: print/cups: -Wl,-R/usr/local/lib returned by cups-config changes library sear...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-01 09:52 UTC by Ting-Wei Lan
Modified: 2018-05-02 13:13 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (tijl)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2018-05-01 09:52:19 UTC
This causes gnome-control-center and gnome-settings-daemon to fail to build in JHBuild because it overrides the library search order specified by LDFLAGS.

gnome-control-center linking failure:
[305/307] Linking target tests/printers/test-canonicalization.
FAILED: tests/printers/test-canonicalization 
clang  -o tests/printers/test-canonicalization 'tests/printers/tests@printers@@test-canonicalization@exe/test-canonicalization.c.o' -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,--no-undefined -Wl,--as-needed -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -O0 -Wl,--start-group panels/printers/libprinters.a -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgthread-2.0 -pthread -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgthread-2.0 -pthread -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -Wl,-R/usr/local/lib -L/usr/local/lib -lcups -lm -L/usr/local/lib -lpolkit-gobject-1 -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/usr/local/lib/samba4 -lsmbclient -Wl,--end-group  
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_par_embedding_levels_ex'
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_bracket'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

gnome-settings-daemon linking failure:
FAILED: plugins/print-notifications/gsd-printer 
clang  -o plugins/print-notifications/gsd-printer 'plugins/print-notifications/plugins@print-notifications@@gsd-printer@exe/gsd-printer.c.o' -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,--no-undefined -Wl,--as-needed -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -O0 -Wl,--start-group gnome-settings-daemon/libgsd.so -Wl,-R/usr/local/lib -L/usr/local/lib -lcups -L/home/lantw44/gnome/devinstall/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -Wl,--end-group -L/home/lantw44/gnome/devinstall/lib -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl '-Wl,-rpath,$ORIGIN/../../gnome-settings-daemon:XXXXXXXXXXXXXXXXXXXXXXXXX' -Wl,-rpath-link,/home/lantw44/gnome/build/gnome-settings-daemon/gnome-settings-daemon  
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_par_embedding_levels_ex'
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_bracket'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

JHBuild sets LDFLAGS to '-L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib', which means the linker is expected to search libraries in the JHBuild prefix before the prefix managed by FreeBSD ports. However, cups-config adds '-Wl,-R/usr/local/lib' to the command line, and the linker searches paths specified by -R and -rpath options before paths specified by -L options. This causes undefined reference error because it picks the old version of fribidi installed by FreeBSD ports instead of the newer one installed in the JHBuild prefix.
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2018-05-01 11:47:31 UTC
Does removing -Wl,-R... from cups-config fix the problem?  It's also possible there's something wrong with libpango.so.  What is the output of "objdump -p /home/lantw44/gnome/devinstall/lib/libpango-1.0.so"?
Comment 2 Ting-Wei Lan 2018-05-01 13:06:29 UTC
Yes, both gnome-settings-daemon and gnome-control-center can be successfully built if I remove -Wl,-R options with this command:

sed -i.bak 's/-Wl,-R[^ ]*//g' build.ninja

Here is the output of objdump. There is no RPATH or RUNPATH set on pango-1.0.so.

$ objdump -p /home/lantw44/gnome/devinstall/lib/libpango-1.0.so

/home/lantw44/gnome/devinstall/lib/libpango-1.0.so:     file format elf64-x86-64-freebsd

Program Header:
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**21
         filesz 0x0000000000055c90 memsz 0x0000000000055c90 flags r-x
    LOAD off    0x0000000000056000 vaddr 0x0000000000256000 paddr 0x0000000000256000 align 2**21
         filesz 0x00000000000029d0 memsz 0x0000000000002ca0 flags rw-
 DYNAMIC off    0x0000000000057b88 vaddr 0x0000000000257b88 paddr 0x0000000000257b88 align 2**3
         filesz 0x00000000000001e0 memsz 0x00000000000001e0 flags rw-
EH_FRAME off    0x000000000004f248 vaddr 0x000000000004f248 paddr 0x000000000004f248 align 2**2
         filesz 0x0000000000001794 memsz 0x0000000000001794 flags r--
   STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
         filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-

Dynamic Section:
  NEEDED               libgobject-2.0.so.0
  NEEDED               libglib-2.0.so.0
  NEEDED               libm.so.5
  NEEDED               libfribidi.so.0
  NEEDED               libc.so.7
  SONAME               libpango-1.0.so.0
  INIT                 0x000000000000e978
  FINI                 0x0000000000042868
  HASH                 0x0000000000000158
  GNU_HASH             0x00000000000012a0
  STRTAB               0x0000000000005600
  SYMTAB               0x0000000000001f58
  STRSZ                0x000000000000363b
  SYMENT               0x0000000000000018
  PLTGOT               0x0000000000257e78
  PLTRELSZ             0x0000000000002178
  PLTREL               0x0000000000000007
  JMPREL               0x000000000000c800
  RELA                 0x0000000000009110
  RELASZ               0x00000000000036f0
  RELAENT              0x0000000000000018
  VERNEED              0x00000000000090d0
  VERNEEDNUM           0x0000000000000002
  VERSYM               0x0000000000008c3c
  RELACOUNT            0x0000000000000228

Version References:
  required from libm.so.5:
    0x077a28b0 0x00 03 FBSD_1.0
  required from libc.so.7:
    0x077a28b0 0x00 02 FBSD_1.0
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-05-01 16:25:35 UTC
A commit references this bug:

Author: tijl
Date: Tue May  1 16:24:38 UTC 2018
New revision: 468766
URL: https://svnweb.freebsd.org/changeset/ports/468766

Log:
  - Update to 2.2.7.
  - Remove -Wl,-R flag from cups-config output to fix out of tree builds of
    Gnome.  The -R flag takes precedence over -L flags when the linker
    searches for dependencies of libraries listed on the command line which
    can be unexpected.  Therefore, config scripts like this should only
    provide -L flags.  An rpath is then typically generated automatically by
    the build system (cmake, libtool,...). [1]

  PR:		227891 [1]
  Reported by:	Ting-Wei Lan <lantw44@gmail.com>

Changes:
  head/print/cups/Makefile
  head/print/cups/distinfo
  head/print/cups/files/patch-configure
Comment 4 Ting-Wei Lan 2018-05-02 13:13:14 UTC
(In reply to commit-hook from comment #3)
Thanks for your patch. I just confirmed that this update does fix build issues for both gnome-settings-daemon and gnome-control-center.