Bug 217753

Summary: lld [llvm 4.0.0] Linker won't link on aarch64 (Error: Failed to open a.out)
Product: Base System Reporter: Wolfgang Meyer <wolfgang.meyer>
Component: armAssignee: freebsd-arm (Nobody) <freebsd-arm>
Status: Closed DUPLICATE    
Severity: Affects Only Me CC: toolchain
Priority: ---    
Version: CURRENT   
Hardware: arm64   
OS: Any   
Attachments:
Description Flags
Output for verbose compilation/linking (cc -v -Wl,--verbose conftest.c) none

Description Wolfgang Meyer 2017-03-13 13:17:26 UTC
Created attachment 180774 [details]
Output for verbose compilation/linking (cc -v -Wl,--verbose conftest.c)

When trying to compile C sources on 12-CURRENT (aarch64) with the newly integrated LLVM 4.0 toolchain the compilation fails with ld giving an error on failing to open the executable file to be produced by the compilation. An empty file with the executable name and a .tmpXXXXXXX suffix is produced by the linking process.

This has been observed using poudriere jails with a FreeBSD 12-CURRENT for aarch64 after integration of the llvm 4.0 toolchain (tested with base r314564 and base r315016) running on an amd64 host using qemu-user-static for arm64 execution.

How to reproduce:
Build poudriere jail for HEAD and aarch64 architecture.
Enter jail and try to compile typical configure test source (referred to as conftest.c):

  int main()
  {
    ;
    return 0;
  }

Compilation:
>cc conftest.c
Output:
/usr/bin/ld: error: failed to open a.out: Unknown error -1
cc: error: linker command failed with exit code 1 (use -v to see invocation)

An empty a.out.tmpXXXXXXX is produced.

This happens with qemu-aarch64-static 2.6.90.g20160728_1 ( ports r424575 ).
With qemu-aarch64-static 2.8.50.g20170307 ( ports r435636 ) I get a qemu error:
/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-c0989c8/tcg/tcg.c:2017: tcg fatal error
cc: error: unable to execute command: Abort trap (core dumped)
cc: error: linker command failed due to signal (use -v to see invocation)

Using lld 3.9.0 on aarch64 poudriere jails works fine with either qemu-emulated execution.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2017-03-15 15:30:10 UTC
Marking dup unless you can reproduce without qemu-user-static. lld works fine on aarch64 reference machines[1].

[1] https://www.freebsd.org/internal/machines.html

*** This bug has been marked as a duplicate of bug 217189 ***