Bug 219758 - databases/postgresql96-contrib: linker error: can't create dynamic relocation
Summary: databases/postgresql96-contrib: linker error: can't create dynamic relocation
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: pgsql
URL:
Keywords: patch
: 220580 221827 (view as bug list)
Depends on:
Blocks: 214864
  Show dependency treegraph
 
Reported: 2017-06-03 18:06 UTC by O. Hartmann
Modified: 2018-07-05 01:39 UTC (History)
4 users (show)

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


Attachments
databases/postgresql*: set LLD_UNSAFE (1.50 KB, patch)
2017-08-22 20:37 UTC, Ed Maste
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2017-06-03 18:06:28 UTC
On 12-CURRENT ( FreeBSD 12.0-CURRENT #42 r319513: Sat Jun  3 07:37:24 CEST 2017 amd64, WITH_LLD_IS_LD=yes) as host and recent poudriere (3.1.19) and jail version 12.0-CURRENT 1200031, updated 2017-06-01 16:39:02, port databases/postgresql96-contrib fails to build due to linker error shown below:

[...]
cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -pipe -O3  -fstack-protector -fno-strict-aliasing -fPIC -DPIC -L../../src/port -L../../src/common -lpthread -L/usr/local/lib -L/usr/local/lib -lpthread -L/usr/local/lib -fstack-protector -L/usr/local/lib -L/usr/lib  -L/usr/local/lib -Wl,--as-needed -Wl,-R'/usr/local/lib' -L../../src/port -lpgport  -shared -o timetravel.so timetravel.o
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strcasecmp): can't create dynamic relocation R_X86_64_PC32 against symbol '__mb_sb_limit' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strcasecmp): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strcasecmp): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strncasecmp): can't create dynamic relocation R_X86_64_PC32 against symbol '__mb_sb_limit' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strncasecmp): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_strncasecmp): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_toupper): can't create dynamic relocation R_X86_64_PC32 against symbol '__mb_sb_limit' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_toupper): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_toupper): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_toupper): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_toupper): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_tolower): can't create dynamic relocation R_X86_64_PC32 against symbol '__mb_sb_limit' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_tolower): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_tolower): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_tolower): can't create dynamic relocation R_X86_64_PC32 against symbol '_CurrentRuneLocale' defined in /lib/libc.so.7
/usr/bin/ld: error: pgstrcasecmp.c:(function pg_tolower): can't create dynamic relocation R_X86_64_32 against symbol '_DefaultRuneLocale' defined in /lib/libc.so.7
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [../../src/Makefile.port:16: timetravel.so] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/databases/postgresql96-contrib/work/postgresql-9.6.3/contrib/spi'
gmake[1]: *** [Makefile:94: all-spi-recurse] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/postgresql96-contrib/work/postgresql-9.6.3/contrib'
*** Error code 2
Comment 1 Ed Maste freebsd_committer 2017-08-22 20:37:23 UTC
Confirmed with LLD 5.0.0 in FreeBSD-current:

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_PC32 against symbol: __mb_sb_limit in readonly segment
>>> defined in /lib/libc.so.7
>>> referenced by pgstrcasecmp.c
>>>               pgstrcasecmp.o:(pg_strcasecmp) in archive ../../src/port/libpgport.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_PC32 against symbol: _CurrentRuneLocale in readonly segment
>>> defined in /lib/libc.so.7
>>> referenced by pgstrcasecmp.c
>>>               pgstrcasecmp.o:(pg_strcasecmp) in archive ../../src/port/libpgport.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_32 against symbol: _DefaultRuneLocale in readonly segment
>>> defined in /lib/libc.so.7
>>> referenced by pgstrcasecmp.c
>>>               pgstrcasecmp.o:(pg_strcasecmp) in archive ../../src/port/libpgport.a
Comment 2 Ed Maste freebsd_committer 2017-08-22 20:37:52 UTC
Created attachment 185680 [details]
databases/postgresql*: set LLD_UNSAFE
Comment 3 Ed Maste freebsd_committer 2017-12-07 15:42:38 UTC
*** Bug 220580 has been marked as a duplicate of this bug. ***
Comment 4 Ed Maste freebsd_committer 2017-12-18 18:01:07 UTC
Worked around by r456635, https://svnweb.freebsd.org/changeset/ports/456635
Comment 5 Palle Girgensohn freebsd_committer 2017-12-20 21:03:03 UTC
@ed is this a work-around or a proper fix? Can we close this issue?

Palle
Comment 6 Palle Girgensohn freebsd_committer 2017-12-20 21:04:20 UTC
*** Bug 221827 has been marked as a duplicate of this bug. ***
Comment 7 Palle Girgensohn freebsd_committer 2017-12-20 21:05:56 UTC
I've verified that it works after Ed's commit
Comment 8 Ed Maste freebsd_committer 2017-12-20 21:18:27 UTC
LLD_UNSAFE is really a workaround - we just cause things to build as they do in the absence of lld as /usr/bin/ld, while further investigation happens.

At least the "can't create dynamic relocation ... in readonly segment" issue stems from different defaults in ld.bfd and ld.lld -- bfd defaults to -z notext (allow relocations against readonly segments) while lld defaults to -z text (relocations in readonly segments are an error). It may be that adding "LDFLAGS+= -Wl,-z,notext" (and removing LLD_UNSAFE) will let the port build with lld.

I think it's fine to close this PR if you like; we can later iterate on finding the ports marked with LLD_UNSAFE and trying to switch them to linking with lld.
Comment 9 Palle Girgensohn freebsd_committer 2017-12-20 21:43:57 UTC
Closing the PR since Ed's work around is committed. Thanks!