June 2017 update on using LLVM's lld linker in the FreeBSD base system

Ed Maste emaste at freebsd.org
Tue Jul 4 14:23:56 UTC 2017


On 12 June 2017 at 17:21, Ed Maste <emaste at freebsd.org> wrote:
> Another update on using LLD as the FreeBSD base system linker:

Since "amd64" and "arm64" look similar, let me clarify one point:

arm64 -- 64-bit ARM -- is built with, and has as /usr/bin/ld, LLD
4.0.0. This is true in HEAD and in stable/11 (and hence the upcoming
11.1)

amd64 -- 64-bit x86 -- is built with, and has as /usr/bin/ld, GNU BFD
ld 2.17.50. LLD is installed as ld.lld; adding -fuse-ld=lld to CFLAGS
can be used to test linking various software with LLD. Also, the amd64
linker will not change in stable/11.

> Then the ports infrastructure
> can automatically use ld.bfd, until the issue is addressed in the
> individual port or in LLD. It will be something like
> "USES=linker:not_lld" or "LLD_UNSAFE=yes" or so.

Still waiting on this; once it is ready I expect to switch amd64 to LLD.

> Outstanding issues with i386 and 32-bit arm prevent us from turning it
> on for those architectures right now. The LLVM tracking bug in
> http://llvm.org/pr23214 depends on those individual issues; i386
> should be relatively straightforward, while arm needs more work.

i386 still needs investigation, but progress has been made on 32-bit
arm. andrew@ booted an lld-linked arm kernel/userland to the login
prompt, with a few workarounds. Note that this is specifically for
armv7. LLD does not currently support earlier ARM architectures.
TARGET_ARCH=armv7 support is in discussion/planning, and for now I
assume that we'd initially switch only it to LLD. TARGET_ARCH=arm and
TARGET_ARCH=armv6 will continue to use ld.bfd.

It appears we are on a credible path to enable LLD by default in 12.0
for the tier-1 and almost tier-1 architectures of i386, amd64, armv7,
arm64.


More information about the freebsd-toolchain mailing list