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
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
Created attachment 185680 [details] databases/postgresql*: set LLD_UNSAFE
*** Bug 220580 has been marked as a duplicate of this bug. ***
Worked around by r456635, https://svnweb.freebsd.org/changeset/ports/456635
@ed is this a work-around or a proper fix? Can we close this issue? Palle
*** Bug 221827 has been marked as a duplicate of this bug. ***
I've verified that it works after Ed's commit
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.
Closing the PR since Ed's work around is committed. Thanks!