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 4.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

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

Status

amd64

Fully functional for base system kernel + world. Work on the ports tree in progress.

arm64

Almost fully functional, excluding boot loaders, rescue. WIP lld patches needed for kernel.

i386

Kernel and userland link completes. Kernel modules fail. Output not yet tested.

arm

Build fails on target libc.

mips64

Links userland. Kernel link fails. Output not yet tested.

mips

Links userland. Kernel link fails. Output not yet tested.

powerpc64

Build fails on target libc.

powerpc

Build fails on target libc.

sparc64

No support

riscv

No support

TODO

Missing options relevant to FreeBSD:

-d / -dc / -dp
--fatal-warnings / --no-fatal-warnings
--no-warn-mismatch
--warn-shared-textrel

WIP patches

lld

FreeBSD

Links

LLD (last edited 2017-03-12 00:35:01 by EdMaste)