Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

60.9. lld-23.1.2

Linker from the LLVM project

Version 23.1.2, release 1
Shelf toolchain — The native compilers, the linker, the C library, and the LLVM family
Phase 31_compilers (Compilers), 10 of 22 in build order
Licence Apache-2.0 WITH LLVM-exception
Homepage https://lld.llvm.org/
Build time 12.2 SBU
Installed size 58.7 MiB in 34 files
Recipe ports/core/toolchain/lld/kpkgbuild

About

LLD, LLVM’s linker, in all its flavours: ld.lld for ELF, lld-link for Windows COFF, ld64.lld for Mach-O and wasm-ld for WebAssembly, with lld itself choosing among them by the name it is run as. The system linker stays binutils’ ld; nothing makes lld the default, and a port that wants it names it in its own recipe. The browsers (chromium, firefox-esr, librewolf), thunderbird, webkitgtk and webkitgtk6, wine (for its Windows-side code), qemu and limine depend on it.

The build is standalone, against the installed llvm. lld’s own libraries (liblldELF.a, liblldCOFF.a and the rest) are installed as static archives with their CMake package, /usr/lib/cmake/lld, for a program that embeds the linker.

Sources

Dependencies

Depends on: llvm, zlib, zstd, libxml2.

Required by (9): chromium, firefox-esr, librewolf, limine, qemu, thunderbird, webkitgtk, webkitgtk6, wine.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/31_compilers/phase.env && kpkg install lld'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/toolchain/lld.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/toolchain/lld
echo 'c98bbef08a2b4c2613cd50e9aa9ae7b69b1fe6c16b2c40373bc0ab6116fdf78a  lld-23.1.2.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/lld
SRC=$SRC_ROOT/lld-23.1.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lld-23.1.2.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

cmake -S lld -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_BUILD_TYPE=Release \
	-D CMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
	-D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -DNDEBUG" \
	-D LLVM_TARGETS_TO_BUILD='X86;AMDGPU;BPF;NVPTX;WebAssembly' \
	-D LLVM_LINK_LLVM_DYLIB=OFF \
	-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
install -Dm644 lld/docs/ld.lld.1 -t "$PKG/usr/share/man/man1"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/lld, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf lld-23.1.2-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/lld, and runs the triggers its paths call for.

Contents

Installed programs: ld.lld, ld64.lld, lld, lld-link, wasm-ld.

Installed libraries: liblldCOFF.a, liblldCommon.a, liblldELF.a, liblldMachO.a, liblldMinGW.a, liblldWasm.a.

Installed directories: /usr/include/lld, /usr/lib/cmake/lld, /usr/share/licenses/lld.

Short descriptions

ld.lld ELF linker from the LLVM project

Notes

The manual page ld.lld.1 is in the source tree, but upstream’s install does not copy it, so the recipe installs it by hand.