We're migrating to lld as the base system linker in FreeBSD, and for testing and development it's useful to be able to explicitly choose a linker for testing via -fuse-ld=<linker> flag, regardless of what the system linker is. Clang supports arbitrary linkers, and -fuse-ld=bfd, -fuse-ld=lld, and -fuse-ld=gold all work. GCC supports only -fuse-ld=bfd and -fuse-ld=gold. Upstream support for -fuse-ld=lld did not go anywhere: https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00155.html. Debian has patched GCC to add -fuse-ld=lld: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/patches/gcc-fuse-ld-lld.diff?revision=9366&view=markup Can we apply the patch to FreeBSD's GCC as well?
I've been thinking about this on and off (not ignoring it, though I should have given you feedback). And given the relatively limited amount of contribution we have around GCC on FreeBSD (including my own bandwidth and skills) and how strenuous maintaining at the base level has been proving, I'd prefer not to pick up extra complexity - both in terms of options and local patches. That said, when/if this becomes available upstream, happy to look into it again, and in fact just yesterday a patch for GCC 9 was submitted upstream, cf. https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01240.html and I'll keep an eye on that.
Patch brought in PR 233174
(In reply to Ed Maste from comment #2) For riscv64-gcc that is, and it is the patch that was committed upstream. Perhaps we can apply it to the main gcc ports?
(In reply to Ed Maste from comment #3) > For riscv64-gcc that is, and it is the patch that was committed upstream. > Perhaps we can apply it to the main gcc ports? I'll do so for lang/gcc8 which soon is going to become the default flavor or GCC in the Ports Collection.
A commit references this bug: Author: gerald Date: Sun Nov 25 21:08:01 UTC 2018 New revision: 485902 URL: https://svnweb.freebsd.org/changeset/ports/485902 Log: Add support for -fuse-ld=lld, backported from GCC mainline which is going to become GCC 9 (in form of files/patch-fuse-ld=lld borrowed from devel/riscv64-gcc). PR: 227302 Changes: head/lang/gcc8/Makefile head/lang/gcc8/files/patch-fuse-ld=lld
lang/gcc8 is patched now.
Does it actually work? $ pkg install gcc8 $ ktrace -i gcc8 -fuse-ld=lld -Wl,--version [...] GNU ld (GNU Binutils) 2.30 [...] $ kdump -r | fgrep -A1 lld 48521 collect2 NAMI "/usr/local/bin/ld.lld" 48521 collect2 RET access -1 errno 2 No such file or directory