Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Nov 2016 16:31:17 -0500
From:      Ed Maste <emaste@freebsd.org>
To:        "freebsd-toolchain@freebsd.org" <freebsd-toolchain@freebsd.org>
Subject:   Update on using LLVM's lld linker in the FreeBSD base system
Message-ID:  <CAPyFy2AqrL4zkjZWXv=56yUUBODAaAV9ATbLv-qAHV5VMjo7vA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
LLD developers have made much progress since my last update in August.

Two options used by the FreeBSD build, -dc and -r, are now
implemented. The issues with linker script expression support and
symbol version maps have been addressed. At this point an LLD built
from subversion can link a working FreeBSD-HEAD kernel and world
except for the boot loaders.

Here's an update on the plan I posted previously:

> 1. Update lld along with the Clang/LLVM 3.9 update that dim@ is working on.
> 2. Add the bmake build infrastructure, installing as /usr/bin/ld.lld
> on the same architectures that use Clang (amd64, arm, arm64, i386). I
> don't think there's a need for a WITH_LLD src.conf knob, but will add
> one if desired.

Now complete, with Dimitry's import of Clang 3.9.0 in r309124. There
is a WITH_/WITHOUT_LLD knob, which defaults to on for amd64 and arm64,
and off for all other architectures for now.

> 3. Update lld again (most likely to a snapshot from upstream SVN) once
> it is able to link an unmodified FreeBSD kernel.

This is now possible, but I'm going to wait for 3.9.0 to settle and
for the 3.9.1 update to happen first.

> 4. Modify the boot loader and kernel builds to avoid using features
> not implemented by lld.

There are a few outstanding issues in LLD that prevent linking the
boot loaders, but I'm hopeful that they will be addressed in the near
future.

> 5. Introduce a WITH_LLD_AS_LD knob to have /usr/bin/ld be a ld.lld
> hardlink instead of /usr/bin/ld.bfd.

I've added this already, to allow for testing and experimentation, and
to provide some linker on arm64 image builds that can be used to
bootstrap a later GNU ld or LLVM lld. It defaults to on for arm64 and
off everywhere else. Note that the knob affects the installed linker
(/usr/bin/ld), but does not change the linker actually used to build
world and kernel, which remains GNU ld.

> 6. Request ports exp-runs and issue a call for testing with 3rd party
> software. Fix issues found during this process.

This can start happening any time now for LLD 3.9.0, either by setting
WITH_LLD_AS_LD with poudriere, or by using -fuse-ld=lld in LDFLAGS.

For example,
% cd /usr/src/bin/ls
% LDFLAGS=-fuse-ld=lld make

> 7. Switch /usr/bin/ld to ld.lld by default in head for the Clang-using
> architectures. Add a WITHOUT_LLD_AS_LD knob to switch back to GNU ld.

It's still too early to plan a switch by default.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2AqrL4zkjZWXv=56yUUBODAaAV9ATbLv-qAHV5VMjo7vA>