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

60.8. lld21-21.1.8

LLD 21 libraries and linker, installed under /usr/lib/llvm21 for zig

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

About

LLD of the 21 series, installed under /usr/lib/llvm21 beside llvm21 for zig, which embeds the linker: lld’s libraries are static archives (liblldELF.a, liblldCOFF.a, liblldMachO.a, liblldWasm.a and the rest), and zig links them into its own binary. The ld.lld, lld-link, ld64.lld and wasm-ld programs under the prefix’s bin are on no PATH; the system’s linkers are lld’s. How the slot is kept apart from the system copy is in A second version beside the first.

The port carries three of the series’ per-component tarballs: lld’s, the shared cmake one, and libunwind’s, for one header. lld’s CMake files read the shared modules from ../cmake, so the mv line in build.sh gives the unpacked cmake-<version>.src that name.

Sources

Dependencies

Depends on: llvm21, zlib, zstd, libxml2.

Required by (1): zig.

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 lld21'

What kpkg does

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

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/lld21
echo 'd9524c5ee952500a2af92c27042a0d90ab089962af47816d4c85d0ebf76373d1  lld21-21.1.8.tar.xz' | sha256sum -c -
echo '85735f20fd8c81ecb0a09abb0c267018475420e93b65050cc5b7634eab744de9  cmake-21.1.8.src.tar.xz' | sha256sum -c -
echo '03e8adc6c3bdde657dcaedc94886ea70d1f7d551d622fcd8a36a8300e5c36cbc  libunwind-21.1.8.src.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/lld21
SRC=$SRC_ROOT/lld21-21.1.8
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lld21-21.1.8.tar.xz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf cmake-21.1.8.src.tar.xz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf libunwind-21.1.8.src.tar.xz -C "$SRC_ROOT"

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 recipe’s helpers _prefix, series and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mv $SRC_ROOT/cmake-${version}.src $SRC_ROOT/cmake
_unwind_inc=$SRC_ROOT/libunwind-${version}.src/include

cmake -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=$_prefix \
	-D CMAKE_BUILD_TYPE=Release \
	-D CMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
	-D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -I$_unwind_inc -DNDEBUG" \
	-D LLVM_DIR=$_prefix/lib/cmake/llvm \
	-D LLVM_INCLUDE_TESTS=OFF \
	-Wno-dev

cmake --build build
DESTDIR=$PKG cmake --install build

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/lld21, 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 lld21-21.1.8-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/lld21, and runs the triggers its paths call for.

Contents

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

Notes

zig holds no NEEDED entry for any liblld library, because the archives are linked into it; a change to this port reaches zig only when zig is rebuilt.