Background

lld, part of the LLVM family of projects, is a high-performance linker for the ELF, COFF, and Mach-O object formats. This page describes the ongoing project to use lld as FreeBSD's base system linker.

In-tree LLD

FreeBSD-CURRENT contains LLD 5.0.0. To build world and kernel with LLD, and install LLD as /usr/bin/ld, add to /etc/src.conf:

WITH_LLD_IS_LD=yes
WITH_LLD_BOOTSTRAP=yes

WITH_LLD_BOOTSTRAP=yes uses lld as the linker for building the FreeBSD world, and has no effect on the linker installed in /usr/bin/ld. WITH_LLD_IS_LD=yes installes lld as /usr/bin/ld, and has no effect on the linker used for building world.

Upstream LLD

Build upstream lld

git clone https://github.com/llvm-mirror/llvm
cd llvm/tools
git clone https://github.com/llvm-mirror/lld
mkdir ../build && cd ../build
cmake -G "Unix Makefiles" ../
make -j8

Make lld the default linker

cd build/bin
ln -s lld ld
setenv PATH /path/to/llvm/build/bin:$PATH
setenv LD /path/to/llvm/build/bin
rehash

To check if the changes took effect:

davide@rabbit1:/home/davide/llvm/build/bin $ ld --help | head -n 1
OVERVIEW: LLVM Linker

Per-arch status

Architecture

World

Kernel

/usr/bin/ld

amd64

OK

OK

bfd

arm64

OK

OK

LLD

i386

lld-linked libc assertion failure

OK

bfd

arm

libc fails to link

LLD targets v7l+

bfd

armv6

libc fails to link

LLD targets v7l+

bfd

armv7

libc fails to link

OK

bfd

mips64

Most links, untested

Link fails

bfd

mips

Most links, untested

Link fails

bfd

powerpc64

libc fails to link

Untested

bfd

powerpc

libc fails to link

Untested

bfd

sparc64

no support

no support

bfd

riscv

no support

no support

bfd

TODO

WIP patches

lld

MIPS

ARM

FreeBSD

Known Issues

A FreeBSD ports exp-run is tracked in PR214864.

Links

LLD (last edited 2017-10-27 20:53:18 by EdMaste)