Skip to content
Latchkey

mold "-fuse-ld=mold not found" / cannot find mold in CI

The build asked the compiler to link with mold via -fuse-ld=mold, but mold is not on the runner, or the compiler predates -fuse-ld=mold support and cannot resolve it. The link step fails before producing a binary.

What this error means

Linking fails with "collect2: fatal error: cannot find \"mold\"", "unknown argument: -fuse-ld=mold", or "-fuse-ld=mold: not found".

mold
collect2: fatal error: cannot find 'mold'
compilation terminated.

Common causes

mold is not installed on the runner

The compiler flag names mold but the binary is absent, so the driver cannot invoke the linker.

The compiler is too old for -fuse-ld=mold

Older gcc/clang do not accept -fuse-ld=mold by name; they need a path or the mold -run wrapper instead.

How to fix it

Install mold and use a supported invocation

  1. Install mold from the package manager or a release.
  2. On newer gcc/clang, pass -fuse-ld=mold.
  3. On older compilers, use mold -run or point at the mold path.
Terminal
sudo apt-get update && sudo apt-get install -y mold
# newer toolchains
export LDFLAGS="-fuse-ld=mold"
# older toolchains
mold -run cmake --build build

Set the mold path explicitly

When the name is not recognized, point the driver at the mold binary directly.

Terminal
export LDFLAGS="-fuse-ld=/usr/bin/mold"

How to prevent it

  • Install mold in a setup step before any link that requests it.
  • Match the invocation form to the compiler version.
  • Bake mold into custom images used for link-heavy builds.

Frequently asked questions

What causes ""-fuse-ld=mold: not found""?
The compiler flag names mold but the binary is absent, so the driver cannot invoke the linker.
How do I fix "-fuse-ld=mold: not found"?
Install mold and use a supported invocation

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card