Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2017 15:39:00 -0500
From:      Ed Maste <emaste@freebsd.org>
To:        FreeBSD Ports <freebsd-ports@freebsd.org>
Subject:   Ports and LLVM's lld linker
Message-ID:  <CAPyFy2A6nbR%2BKpp=WpJ45xsUHEE0PhN1%2B7KRQfZ1U68wrr0E=A@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
We're making good progress on using LLVM's lld linker as FreeBSD's
/usr/bin/ld, so I'd like to raise awareness of the new linker within
the ports community.

Why do we need a new linker? Compared to GNU ld 2.17.50 currently in
the FreeBSD base system, lld brings:

* AArch64 (arm64) support
* Link Time Optimization (LTO)
* New ABI support
* Other linker optimizations
* Much faster link times
* Maintained code base

There are a pair of src.conf build knobs, WITH_LLD_BOOTSTRAP and
WITH_LLD_IS_LD, which control whether lld is used to link during
buildworld, and whether lld is installed as /usr/bin/ld. You can also
switch the linker by making /usr/bin/ld a symlink to either ld.bfd or
ld.lld.

These build knobs are enabled by default on arm64 as of FreeBSD 11.1.
I have been using lld as /usr/bin/ld on my amd64 laptop and desktop
for over a year. (Note that there are a few outstanding issues on
i386, and lld is not yet fully as the system linker there. I expect
that both i386 and 32-bit arm will be fully working in time for
FreeBSD 12.0.)

For the ports tree we've been iterating on exp-runs using lld, in PR
214864. A number of issues have been identified during this process,
and we've added a LLD_UNSAFE option that can be set in a port's
Makefile to fall back to GNU ld (either /usr/bin/ld.bfd or by
depending on the binutils port if /usr/bin/ld.bfd does not exist).

Note that there's currently a bug in pkg (PR223776) which causes
issues registering shared libraries linked by lld; once it's resolved
I'd like to encourage port maintainers who are willing to experiment
with FreeBSD-current test environment to enable WITH_LLD_IS_LD and
ensure that their ports work as expected. I'm happy to help work
through any issues that are found.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2A6nbR%2BKpp=WpJ45xsUHEE0PhN1%2B7KRQfZ1U68wrr0E=A>