Bug 237692

Summary: lld: linking fails on aarch64 with 'Should not have claimed to be relaxable'
Product: Base System Reporter: Mikael Urankar <mikael>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: dmgk, emaste
Priority: ---    
Version: CURRENT   
Hardware: arm64   
OS: Any   

Description Mikael Urankar freebsd_committer freebsd_triage 2019-05-01 15:24:28 UTC
I'm seeing the following issue when trying to link some lang/go executables on aarch64:

Should not have claimed to be relaxable
UNREACHABLE executed at /usr/src/contrib/llvm/tools/lld/ELF/Target.cpp:176!
cc: error: unable to execute command: Abort trap (core dumped)
cc: error: linker command failed due to signal (use -v to see invocation)

It seems to only be an issue with ld.lld from base/13-current. It works fine with lld from devel/llvm* and surprisingly it also works with ld.lld from base/12-stable.

If someone wants to look into it, I put a tarball and a build script to reproduce the issue:
http://mikael.urankar.free.fr/FreeBSD/go/go_lld_bug.tar.gz

see also:
https://github.com/golang/go/issues/24715#issuecomment-487195099
Comment 1 Ed Maste freebsd_committer freebsd_triage 2019-05-02 13:20:09 UTC
Would you add lld --version info from the working/non-working cases? Most likely this will become an upstream lld bug report.
Comment 2 Mikael Urankar freebsd_committer freebsd_triage 2019-05-02 14:18:38 UTC
Here are the results:

ld.lld from ports:
/usr/local/bin/ld.lld60 --version
LLD 6.0.1 (compatible with GNU linkers)

/usr/local/bin/ld.lld70 --version
LLD 7.0.1 (compatible with GNU linkers)

/usr/local/bin/ld.lld80 --version
LLD 8.0.0 (compatible with GNU linkers)


ld.lld from base:
12.0-release
ld.lld --version
LLD 6.0.1 (FreeBSD 335540-1200005) (compatible with GNU linkers)

12-stable (from a few days ago, for FreeBSD 12.0 (1200507))
ld.lld -version
LLD 8.0.0 (FreeBSD 356365-1200007) (compatible with GNU linkers)

13-current (from a few days ago, for FreeBSD 13.0 (1300021))
ld.lld --version
LLD 8.0.0 (FreeBSD 356365-1300003) (compatible with GNU linkers)

The only failure is with ld.lld from base/13-current.
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2019-05-03 14:04:15 UTC
(In reply to mikael.urankar from comment #2)
It seems to be a problem with debug build of clang/lld, it works on head with this (ie, same as the release or stable branch):

Index: lib/clang/llvm.build.mk
===================================================================
--- lib/clang/llvm.build.mk     (revision 345171)
+++ lib/clang/llvm.build.mk     (working copy)
@@ -17,7 +17,7 @@
 CFLAGS+=       -DLLVM_BUILD_GLOBAL_ISEL
 CFLAGS+=       -D__STDC_LIMIT_MACROS
 CFLAGS+=       -D__STDC_CONSTANT_MACROS
-#CFLAGS+=      -DNDEBUG
+CFLAGS+=       -DNDEBUG
 
 TARGET_ARCH?=  ${MACHINE_ARCH}
 BUILD_ARCH?=   ${MACHINE_ARCH}
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2019-10-15 17:33:57 UTC
it seems to be fixed with LLD 9.0.0 (FreeBSD 372316-1300005)