mold is a faster replacement for existing Unix linkers.
It is several times faster than the LLVM lld and GNU ld linker.
mold
aims to increase developer productivity by minimizing build time, especially in fast debug, edit and rebuild cycles.
Here is a performance comparison of GNU ld, GNU gold, LLVM lld, and mold when linking final debuginfo-enabled executables for large programs on a simulated 16-core, 32-thread machine.
Program (linker output size) | GNU ld | GNU gold | LLVM lld | mold |
---|---|---|---|---|
MySQL 8.3 (0.47 GiB) | 10.84s | 7.47s | 1.64s | 0.46s |
Clang 19 (1.56 GiB) | 42.07s | 33.13s | 5.20s | 1.35s |
Chromium 124 (1.35 GiB) | N/A | 27.40s | 6.10s | 1.52s |
mold supports: x86-64, i386, ARM64, ARM32, 64-bit/32-bit little/big-endian RISC-V, 32-bit PowerPC, 64-bit big-endian PowerPC ELFv1, 64-bit little- endian PowerPC ELFv2, s390x, 64/32-bit LoongArch, SPARC64, m68k, SH-4 and DEC Alpha.
Here is a side-by-side comparison of CPU usage per core for lld (left) and mold (right), linking the same program, a Chromium executable.
If you are using a compiled language like C, C++ or Rust, a compilation consists of two phases.
In the first phase, a compiler compiles the source files into object files (.o
files).
In the second phase, a linker takes all object files and combines them into a single executable or shared library file.
The second phase can be time consuming if the build output is large.
Mold can speed up this process, saving time and avoiding distractions while waiting for a long build to be completed.
The difference is most noticeable during rapid debug, edit, and rebuild cycles.
mold
is available in almost all package manager repositories, example:
And among many others! Use search in your package manager to find it!
If you are going to compile C/C++ files, for example use the flag: fuse-ld=mold
:
If you are going to compile Assembly files, example hello.s
(GNU Assembler - GAS):
Compile normally:
And use the template to link:
Checking if elf
was linked with mold
:
For more information access the repository on GiiHub.