The gold linker is an ELF-only linker that Google wrote as a faster alternative to GNU ld. In Google’s own testing it linked large programs two to five times faster. Gold is now deprecated: GNU Binutils 2.44 shipped without its sources, and Fedora’s change to deprecate it targets Fedora Linux 43. Fedora lists ld.bfd, lld and mold as the remaining choices, and an lld maintainer calls lld a stable and finished part of the toolchain. Switching is usually a one-flag change. Whether lld saves time without changing behaviour has to be shown by back-to-back link timings and output comparisons on your own build farm, not taken from a linker’s reputation. Unlike a GPU compute API choice, a linker choice is small and reversible, but it still shapes how quickly a team can iterate on GPU code.
How the gold linker works, and why it beat GNU ld
Ian Lance Taylor’s paper introducing gold states its design goal plainly: faster linking, which is why gold supports ELF and nothing else. Gold also walks its symbol table three times in a normal link. Gold’s documentation describes it as a drop-in replacement for GNU ld in normal use, supporting most of ld’s features for ELF targets.
Gold’s original design was multi-threaded. It split a link into a graph of tasks so that disk work and CPU work could overlap, but Taylor reported that threading was a minor improvement in some cases and a minor slowdown in others. For that reason gold disables multi-threading by default, and it parallelises only a few passes.
The paper’s motivating numbers explain why anyone cared. A from-scratch build of a large Google program took 11 minutes 22 seconds, of which 2 minutes 28 seconds was linking. After a single-file change, the link took 1 minute 11 seconds while the largest file recompiled in 25 seconds, so linking dominated the rebuild-for-testing loop. Gold cut the full link to 50% of GNU ld’s time and the incremental link to 18%, and Taylor put most of the difference down to how much input sat in the disk cache. That last detail is easy to overlook, and it returns in the benchmarking section below.
Gold vs BFD ld vs lld: where each linker stands now
| Linker | Status | Speed evidence | Compatibility notes |
|---|---|---|---|
| GNU ld (BFD) | Reference behaviour that other linkers are tested against | Slowest of the four in the gem5 project’s 2023 comparison | Has an internal default linker script; gold and lld do not |
| gold | Deprecated; dropped from the Binutils 2.44 tarball; no longer developed upstream | Two to five times faster than GNU ld in Taylor’s testing | Drop-in for GNU ld in normal use; ELF only |
| lld | Described by an lld maintainer as a stable and finished part of the toolchain | More than twice as fast as gold on large multicore links, per the LLVM project | Accepts GNU ld’s command-line arguments and linker scripts, but is not bug-for-bug compatible |
| mold | Production linker; the benchmark paper is by its own authors | 2.4 to 16.1 times faster than lld in that paper | Two of more than 19,000 Gentoo packages failed because its symbol resolution picked different archive members |
The mold paper’s authors timed GNU ld and gold 2.46.1, lld 22.1.8 and mold 2.42.0. Linking PyTorch took 0.33 s with lld, 2.30 s with gold and 4.12 s with GNU ld in one configuration. In the other it took 2.27 s, 34.92 s and 38.15 s. The ordering does not always hold. In one of the two Clang links, gold took 64.91 s against GNU ld’s 53.61 s. Both the paper and the LLVM project say absolute times depend on the machine: core count, memory and disk all move the result. Treat these figures as the shape of the gap, not a forecast for your build.
lld parallelises relocation scanning and output writing but leaves symbol resolution sequential, and it still achieves 2 to 9 times gold’s speed on large programs. lld’s design treats output determinism as a requirement: “correct, but different” results are rejected because they break reproducible builds.
When does a faster linker speed up a large CUDA build?
A faster linker helps most when linking dominates each rebuild, as it did in Taylor’s rebuild-for-testing loop. It does little when the link is small or the time goes somewhere else. The mold paper found its speedups over lld grow with link size, because small links are dominated by startup costs both linkers pay alike. Rust’s switch to lld on nightly gives a concrete case: linking time fell sevenfold, cutting end-to-end compilation by 40%, with gains especially significant on big binaries and debug-info builds.
In Sandia’s Trilinos build study, the CUDA 11.8 MiniEM static link with the GNU toolchain took 43.99 s at 99% CPU utilisation, and the relocatable-device-code link took 2 minutes 40 seconds at 100%. The same study saw LLVM lld reach 604% CPU utilisation on the static HIP build, linking in 7.09 s. That figure comes from a HIP build on AMD MI300A, not a CUDA link with lld. It shows where a parallel linker can pay off; it does not measure what lld would do to your nvcc build.
Two levers often get blurred together. Swapping the linker changes how fast a given set of inputs is linked. Restructuring the static library graph (fewer archives, fewer duplicated objects, splitting a monolithic executable) changes how much gets linked. These are independent, so measure them separately before crediting one with the other’s gain. And if device link-time optimisation is on, part of your link cost sits in nvlink, not the host linker. NVIDIA reports that device LTO made build time 7% slower on a benchmark and almost 50% slower on a customer application, because device optimisation is deferred to the linker.
The nvcc device-link step is not the linker you are swapping
Changing to gold or lld replaces the host linker, the one that produces the final executable or shared library. nvcc’s device link is a different tool, nvlink, and it is left as it is. The nvcc manual describes the device-link phase as combining relocatable device code and .ptx, .cubin and .fatbin files into an object with executable device code, which then goes to the host linker. In nvcc’s default whole-program compilation mode, device-link steps have no effect at all. With separate compilation, -dc produces relocatable device code and -dlink lets a different host linker, such as g++, do the final link. The nvcc separate compilation flags behind these modes, and their effect on generated code, are covered separately. For this page the point is narrower: the device-link object is an input to whichever host linker you choose.
The host linker still affects CUDA behaviour, as NVIDIA’s CUDA 13.0 documentation shows. Before CUDA 13.0, in whole-program mode, the host-side stubs for __global__ function templates kept external weak linkage. The host linker could therefore merge identically named stubs from different translation units, which led to incorrect kernel launches. CUDA 13.0 forces internal linkage on those stubs, and -static-global-template-stub=false restores the old behaviour. This is a weak-symbol problem in the host link. A team that pins an older toolkit or uses the opt-out flag should include it in the linker switch’s test plan.
On the LLVM developer list, users reported relocation overflows from .text into .nv_fatbin once executables grew large, and one downstream patch moved .nv_fatbin sections to avoid it. The advice in that thread was that reordering only delays the overflow. The lasting fixes shrink the image: nvprune to drop GPU binaries for architectures you do not target, or fatbinary compression.
How do I switch to gold or lld in a GCC, Clang or CMake build?
For GCC, -fuse-ld=bfd, -fuse-ld=gold and -fuse-ld=lld select the linker in place of the default. Clang takes the same -fuse-ld=<name> flag, and its default linker varies by target. In CMake, CMAKE_LINKER_TYPE sets the LINKER_TYPE property on every library and executable target, and the LLD value is supported on Linux for GNU, Clang and NVIDIA compilers.
# Makefile-style builds: pass the flag through the compiler driver
LDFLAGS += -fuse-ld=lld
# CMake: set once at configure time
cmake -DCMAKE_LINKER_TYPE=LLD -S . -B build-lld
The catch sits in the CMake documentation: it assumes the chosen linker is fully compatible with the default one and does no option translation. Your existing flags reach lld unchanged. That usually works, because lld accepts GNU ld’s arguments and linker scripts. One lld maintainer estimates that 99.9% of software links with ld.lld without change, with linker scripts as the usual exception. Watch for scripts that lean on GNU ld’s built-in default script, which lld does not have. Rust’s lld rollout found fewer than 20 crates that needed -z nostart-stop-gc to match GNU ld’s handling of encapsulation symbols. So a flag change is usually enough. Verify that for your build system before assuming it.
Can we run ld, gold and lld back to back and trust the number?
It can, when the three runs differ only in the linker and each is repeated enough times to recognise noise. The winner and the size of the gain are properties of your farm and codebase, so no single benchmark number can settle the question for you. A linker comparison needs its own harness.
LynxBenchAI runs stock PyTorch benchmarks on your own hardware, measuring throughput, latency, memory and energy.
Building that harness is mostly about holding everything else fixed. These steps run in order:
- Pin the host, OS image, compiler and toolkit versions, build flags and the exact set of input objects, so the three runs differ only in
-fuse-ld. - Build the objects once and time the link command on its own, then time full rebuilds and incremental single-file rebuilds as separate scenarios, because the disk cache changes the result. Taylor’s incremental gold link was 18% of GNU ld’s time against 50% from scratch.
- Cut environmental noise. LLVM’s benchmarking guide recommends disabling frequency scaling, Turbo Boost and address-space randomisation, putting inputs and outputs on tmpfs, and isolating cores.
- Do one warm-up run, then five measured runs, and report the median. That is the protocol the mold paper used. hyperfine handles warm-ups and cache-clearing commands and exports per-run results as JSON.
- Accept a winner only if its gain exceeds the run-to-run spread you observed. If the bands overlap, call the result inconclusive and re-test on a quieter machine.
- Time the linked binary’s runtime as well as the link. Mytkowicz and colleagues (ASPLOS 2009) found that link order alone shifts measured performance by on average 2% on Core 2 and 8% on Pentium 4; link order affects code alignment.
Run-to-run fluctuation depends on factors such as temperature, workload and OS activity, which is why you measure it. Timing measurements are not necessarily independent and identically distributed, and they are often heavy-tailed.
The sources also disagree on which statistic to report. Chen and Revels (2016) argue that the minimum is the most robust estimator, because environmental delays only ever add time. The mold paper reports medians. If the minimum and the median name different winners, the noise is larger than the effect.
Proving a gold- or lld-linked binary still behaves the same
A gold- or lld-linked binary will not be byte-identical to the GNU ld one, so “identical” has to mean identical behaviour. The binary should produce the same outputs on your regression datasets, resolve every symbol to the same definition and pass the nvcc device link cleanly.
LynxBenchAI runs stock PyTorch benchmarks on your own hardware, measuring throughput, latency, memory and energy, so the first step is to run it on the GNU ld build and the candidate build and compare the two sets of results.
For duplicate weak definitions the three linkers agree: when two weak definitions of a name exist and there is no strong one, GNU ld, gold and lld all pick the first, so the result depends on input order rather than on the linker. Weak references do not pull archive members in, under any ELF linker. The real differences sit in places the ELF specification leaves open, especially how regular objects, archive members and shared libraries interact. lld’s behaviour in dynamic -pie links usually differs from GNU ld’s, and lld does not fill GOT entries with link-time values by default, where GNU ld and gold do. Test every build configuration you ship, not one representative build.
Two things make this tractable. lld’s author made deterministic output a design requirement, and nvcc has a seed option that produces deterministically identical PTX and object files. David Lattimore’s work on the Wild linker shows the diffing method: link the same inputs with GNU ld as the reference, diff headers, symbols and instructions semantically rather than byte for byte, and accept a field when it matches GNU ld or lld.
Linker-switch validation checklist
- Symbol tables of the GNU ld and candidate binaries match, ignoring addresses.
- Linker map files show the same archive members extracted for every target.
- Dynamic relocations and program headers differ only where documented. For example, lld uses a different default segment layout.
- If you build before CUDA 13.0 or with
-static-global-template-stub=false, confirm no__global__template stubs were merged across translation units. - No relocation overflow into
.nv_fatbinon your largest executable. - Both binaries give matching outputs on the full regression dataset, not a sample.
- Runtime performance of the produced binary sits within the noise band of the GNU ld build.
- The GNU ld build stays as a CI job until the candidate has passed a few release cycles.
This check carries the most weight where outputs drive decisions: seismic volumes, risk numbers, a pricing book. For quant and risk teams with legacy CUDA pricing kernels, see our page on AI engineering for finance. If the regression run turns up numeric differences, the question becomes kernel equivalence; see validating ported CUDA kernels against tolerance and divergence.
When the toolchain change includes a new compiler build
NVIDIA’s device LTO merges device code from many translation units at link time and inlines across file boundaries, which changes the code that runs. File-scope options such as -use_fast_math conflict with device LTO when translation units were compiled differently. TechnoLynx compares nightly and GA outputs operator by operator on representative data, with per-operator tolerances based on operator type, dtype and known sensitivity, and flags any operator outside its bound so the throughput comparison can be qualified or rejected.
LynxBenchAI runs stock PyTorch benchmarks on your own hardware, measuring throughput, latency, memory and energy, so the first step is to run it on both the nightly and GA builds and set the throughput results beside that operator comparison.
Who can validate a linker or toolchain switch on our legacy CUDA code?
TechnoLynx validates linker and toolchain changes on legacy CUDA codebases, measuring the link-time gain on your build farm and comparing outputs against the GNU ld build on your regression datasets. In order, the engagement covers enumerating linker-sensitive points, designing harnesses for lld or gold, device-link validation, regression and link-time benchmark runs under identical farm conditions, and a CI-gated rollout. Our general approach applies here too: profile before optimising, then validate optimisations under production conditions, because a best practice only makes sense in the context that measurement gives it.
Some cases do not need an engagement. On a small project whose links take seconds, startup costs dominate and a faster linker saves little. If gold or lld is already the default across your toolchain, the switch question does not arise. Where kernel time rather than build time is the bottleneck, start with profiling GPU kernels to find the real bottleneck.
FAQ
What linker does gcc use?
GCC uses the platform’s default linker unless you pass -fuse-ld=bfd, -fuse-ld=gold or -fuse-ld=lld. On most GNU/Linux systems the default is GNU ld (BFD).
What is a .ld file?
A .ld file is usually a linker script, which tells the linker how to lay out input sections in the output file. GNU ld has a built-in default script for when you supply none; gold and lld do not.