picolld
picolld is the ELF port of lld (ld.lld) extracted from llvm-project as a standalone project, without LTO.
It builds with only a C++17 compiler and CMake: no llvm-project checkout, llvm-config, or llvm-tblgen is needed.
The upstream commit is recorded in utils/UPSTREAM.
Building
cmake -S . -B out -G Ninja
ninja -C out
out/bin/ld.lld --version
Options:
-DPICOLLD_ENABLE_ZLIB=ON|OFF|AUTO, -DPICOLLD_ENABLE_ZSTD=ON|OFF|AUTO (default AUTO): compressed debug sections.
-DPICOLLD_ENABLE_ASSERTIONS=ON: enable assertions.
-DLLD_VERSION=x.y.z, -DLLD_VENDOR=name: the version string printed by --version and written to .comment.
Tested on Linux (GCC 16, Clang 24). Other Unix-like hosts such as macOS and the BSDs should work but are untested; Windows hosts are not supported.
All ELF targets are supported (AArch64, AMDGPU, ARM, AVR, Hexagon, LoongArch, MIPS, MSP430, PowerPC, RISC-V, SPARC, SystemZ, x86).
Differences from upstream ld.lld
- No LTO. LLVM bitcode input files (including bitcode archive members) are rejected with an error.
LTO options (
--lto-*, --thinlto-*, -plugin, and the -plugin-opt= forms that GCC and Clang pass) are accepted and ignored, so compiler driver invocations keep working.
--plugin-opt=-<llvm-option> and --plugin-opt=mcpu= are ignored as well (upstream forwards them to LLVM's code generator), and --help still lists the LTO options.
With --fat-lto-objects, the native code in fat LTO objects is linked.
-mllvm accepts only options registered by the vendored Support library.
--irpgo-profile (temporal profiles for --bp-startup-sort=function) is not supported; the balanced partitioning compression options work.
- Only the ELF driver is included (no COFF, Mach-O, MinGW, or WebAssembly).
Output matches upstream ld.lld from the same commit byte for byte; this was checked on clang Release (--gc-sections, also with --bp-compression-sort=both), clang Debug (--gdb-index), and Firefox Debug for AArch64 links, at --threads=1 and --threads=8.
Layout
lld/ and llvm/ mirror the llvm-project paths of the vendored files, which are listed in utils/files.txt.
The vendored LLVM code is the subset of ADT, Support, BinaryFormat, Object, Option, DebugInfo/DWARF, Demangle, and TargetParser that lld/ELF transitively needs, plus single files from MC (StringTableBuilder.cpp) and TransformUtils (CodeLayout.cpp).
Local modifications live in patches/:
lld.patch removes LTO from lld/ELF and lld/Common, drops --irpgo-profile support (ProfileData depends on LLVM IR), and makes lld.cpp an ELF-only main.
llvm.patch reduces createBinary to archives (other formats would pull in IR, MC, and TextAPI), removes the ObjectFile-backed and dump/verify parts of DWARFContext (lld uses its own DWARFObject), and removes StringRef::getAsDouble (APFloat needs LLVM libc headers).
Generated files are checked in: lld/ELF/Options.inc (from Options.td) and llvm/include/llvm/TargetParser/*Def.inc (from target .td files).
Updating from upstream
utils/sync.py --llvm-project ~/llvm-project --llvm-build ~/llvm-project/build
This copies the files in utils/files.txt, applies patches/*.patch, regenerates the TableGen outputs with the build's llvm-tblgen, and updates the default LLD_VERSION.
If a patch no longer applies, fix the tree by hand, then rewrite the patches:
utils/sync.py --llvm-project ~/llvm-project --update-patches
If the build fails because upstream started using a new header or source file, add its path to utils/files.txt and sync again.
Testing
lld's lit tests live in llvm-project.
utils/check-lld-elf.py runs lld/test/ELF against picolld using tools (FileCheck, llvm-mc, ...) from an LLVM build of the same commit (ninja lld-test-depends):
utils/check-lld-elf.py --llvm-project ~/llvm-project --llvm-bin ~/llvm-project/build/bin --timeout 30 -q
At the upstream commit in utils/UPSTREAM, 1848 tests pass and 194 fail; upstream ld.lld passes all of them in the same harness.
The failures are the tests that use bitcode, DTLTO, fat LTO objects, --irpgo-profile, --plugin-opt=-<llvm-option> (lto-plugin-ignore.s), or --lto-sample-profile with --reproduce (reproduce-lto.s).