Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

How to Install and Use the Mold Linker on Linux (2026 Guide)

If you write C++ or Rust on Linux, there is a good chance the slowest part of your edit-compile-run loop is not the compiler. It is the mold linker stage — the final step where the linker stitches hundreds of object files into one binary. On a big project that step can take a minute or more, every single rebuild. Mold is a drop-in replacement for the default GNU linker that was built from day one to make linking parallel, and it routinely finishes in seconds where GNU ld needs minutes. Version 3.0, released on 5 October 2026, rewrites the whole linker in Rust and sets its sights on eventually becoming Linux’s default linker.

This guide shows you how to install mold on Linux, point GCC, Clang, and Cargo at it, and measure the difference. Everything below was verified against the official mold 3.0 release notes and independent benchmarks on 8 October 2026.

What the Mold Linker Does (and Why It Is So Fast)

A linker is the last step of a build. Your compiler turns each source file into an object file; the linker combines those pieces — plus libraries — into the executable you can actually run. On Linux, the default is GNU ld, which is decades old and mostly serial: it does one thing at a time, on one core.

Mold was designed by Rui Ueyama (who also wrote LLVM’s lld linker) around a simple idea: every major linker pass should be a parallel loop. On modern multi-core machines that pays off enormously, especially for debug builds, where object files are bloated with debug symbols and the linker has to chew through gigabytes of them. Mold’s August 2026 benchmark suite reports:

  • Chromium 145: mold 1.65s vs LLVM lld 16.64s — 10.1x faster
  • TensorFlow 2.21: mold 3.15s vs lld 50.73s — 16.1x faster
  • ClickHouse 26.1: mold 0.98s vs lld 6.62s — 6.7x faster

Daniel Lemire benchmarked the new mold 3.0 release linking Node.js (a ~160 MB executable) on a 64-core server: GNU ld took 2.52s, gold took 1.46s, and mold 3.0 took 0.49s on one thread and 0.13s with 8 threads — roughly 24x faster than GNU ld when allowed to use the machine.

Two seconds saved per link sounds trivial until you multiply it by every rebuild you do in a day. For developers on large C++ or Rust codebases, the link step is often the biggest single wait in the debug loop.

Mold 3.0: What Changed in October 2026

Mold 3.0.0, released 5 October 2026, is the first version written in Rust. Version 2.42.1 was the last C++ release, and 3.0 is described by the project as a drop-in replacement for it: the same command-line options, the same target architectures, and the same output (apart from bug fixes). Linking speed remains on par with 2.42.1, so the benchmark numbers above carry over.

What the rewrite buys you:

  • Memory safety. Mold processes millions of relocations across gigabytes of object files. The old C++ code could read out of bounds on corrupted input files and crash with a segmentation fault; the Rust version bounds-checks those reads and stops with a clean panic instead.
  • Bug fixes. The rewrite fixed many compatibility bugs along the way, including crashes with statically linked executables, corrupted output when the output file was also an input, and several nondeterministic-output cases.
  • A simpler build. Mold no longer depends on Intel’s oneTBB library, and CMake has been replaced by Cargo.

More important than any single fix is the stated goal: mold 3.x aims to close the remaining compatibility gaps with GNU ld — particularly linker-script support — so Linux distributions can adopt mold as the default linker. Linker scripts control how kernels and firmware are linked, and without them mold cannot replace /usr/bin/ld system-wide. That work is now underway.

How to Install Mold on Linux

Mold is packaged by every major distribution. You have three routes — pick whichever fits your situation. The safest default is your package manager.

Option 1: Install from your distro’s repositories

Mold ships in the default repositories of Ubuntu 24.04+, Debian, Fedora, and Arch:

# Ubuntu / Debian
sudo apt update && sudo apt install -y mold

# Fedora
sudo dnf install -y mold

# Arch Linux
sudo pacman -S mold

Then verify:

mold --version

One caveat: distribution packages lag behind releases. As of this writing they ship a 2.x version — fine for trying mold, but not the new Rust-based 3.0. If you specifically want 3.0, use option 2 or 3.

Option 2: Use the official prebuilt binary (mold 3.0)

Every mold release ships prebuilt binaries for x86-64, ARM64, ARM32, RISC-V, PPC64LE, s390x, and LoongArch, attached to the release page at github.com/rui314/mold/releases. Download the tarball for your architecture, extract it, and you get a standalone mold binary plus its companion wrapper library — no dependencies to install. Drop it in /usr/local/bin or ~/.local/bin.

This is the fastest way to get exactly mold 3.0, the Rust version.

Option 3: Build mold 3.0 from source

Building from source is different now than it was for 2.x. You no longer need CMake; you need Rust:

  • A C compiler (GCC or Clang) — installable with your system package manager
  • Rust 1.95 or newer — install via rustup if your distro’s Rust is older
  • Git
git clone https://github.com/rui314/mold.git
cd mold
cargo build --release

That produces target/release/mold and its companion target/release/mold-wrapper.so. To install system-wide:

sudo ./install-mold.sh

This installs under /usr/local. Note that the old CMake configuration options are gone entirely — target selection is now done through Cargo features.

How to Use the Mold Linker

Mold is a drop-in replacement: you do not change your code, only which linker the compiler driver invokes. There are four ways to do it, from explicit flags to a zero-config escape hatch.

1. Pass -fuse-ld=mold to Clang or GCC

The cleanest route when you control the build flags:

# Clang (any recent version)
clang -fuse-ld=mold main.c -o main

# GCC 12.1 or later
gcc -fuse-ld=mold main.c -o main

If you are stuck on GCC older than 12.1, -fuse-ld will not accept mold as an argument. The workaround: mold’s installer creates /usr/local/libexec/mold containing an ld symlink to mold. Pass that directory with -B, which tells GCC where to look for its sub-commands:

gcc -B/usr/local/libexec/mold main.c -o main

2. The mold -run escape hatch

Sometimes you cannot easily push a flag through a build system — a Makefile you do not own, a CI pipeline, an old build script. Mold has a trick for exactly that situation: mold -run intercepts every invocation of ld, ld.gold, or ld.lld and redirects it to itself, using LD_PRELOAD behind the scenes:

mold -run make -j$(nproc)
mold -run cargo build

You do not touch any build scripts. If the build works, you get mold’s speed; if it does not, you remove the wrapper and nothing else changed. It is the fastest way to try mold on an existing project.

3. Point Cargo at mold (Rust projects)

For Rust, linking happens through cc/clang, so you route it with a rustflags entry in .cargo/config.toml (per project) or ~/.cargo/config.toml (global):

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

This is a popular combination in the Rust world precisely because debug builds relink on every change, and mold handles debug-info linking several times faster than lld. You can also use mold -run cargo build for a zero-commitment test.

4. Verify mold is actually being used

Build flags can be silently ignored, so check. Mold leaves its identification string in the .comment section of every binary it produces:

readelf -p .comment ./my-binary

If you see mold in the output, you are linked with mold. You can also just time the difference on a full build before and after switching — on a large project you will not need a stopwatch to notice.

Mold vs lld: Which Should You Pick?

LLVM’s lld is the other modern fast linker, and it is already bundled with every LLVM install. The honest comparison:

  • Mold is faster — typically 4–5x faster than lld on large programs, and much faster on debug builds (the August 2026 suite reports a median 4.9x over lld).
  • lld is more portable — mold is Linux-focused; lld works on Linux and macOS.
  • lld is better tested with exotic configs — mold deliberately skipped full linker-script support in 2.x; that gap is what 3.x is closing.

There is also a newer challenger, wild, which has beaten mold on some Rust-specific benchmarks and deserves re-evaluation once it ships 1.0. But for C++ debug builds on Linux, mold remains the fastest production-ready option.

Rule of thumb: if your project builds on Linux, try mold. If you build cross-platform or link kernels and firmware with custom linker scripts, stay on lld until mold 3.x closes the compatibility gap.

When the Mold Linker Won’t Help Much

Mold is not magic for every project. On small programs the link takes fractions of a second regardless, and an independent benchmark found mold only ~1.2x faster than GNU ld on a 500-file toy program. The dramatic numbers live in the multi-gigabyte range: Chromium, Clang, TensorFlow, big Rust workspaces with heavy debug info.

Also keep in mind that 3.0 is a fresh rewrite. The project ran its full test suite on every supported target and built every Gentoo package with it, reporting no regressions — but if you maintain a build that depends on unusual GNU ld behaviour, test the migration on a branch before committing to it. mold -run makes that experiment nearly free.

Further Reading & References

All version numbers, install steps, and benchmark figures verified on 8 October 2026. Mold 3.0.0 was released 5 October 2026.

Leave a Comment