logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·30.10.26
← Back to news

Mold Linker Version 3.0.0 Release – Rewritten in Rust

Original article
github.com|142 points|64 comments|by roflcopter69|Oct 5, 2026

Announcement: Mold Linker v3.0.0 — Now Powered by Rust

@rui314

The high-speed linker, mold, has reached a major milestone with the release of version 3.0.0. As previously hinted at in the 2.42.1 notes, the project has undergone a complete architectural transformation: mold has been rewritten from C++ in Rust.

🎯 Strategic Objectives

The primary goals for the 3.x series are:

  • Closing Compatibility Gaps: Specifically improving support for linker scripts to align more closely with GNU ld.
  • Distribution Readiness: Preparing the tool for adoption as the standard default linker across various Linux distributions.

Note on Compatibility: Mold 3.0.0 maintains parity with previous versions regarding target architectures, command-line arguments, and general output, with the exception of the specific bug fixes detailed below.

Verification Process

To ensure a seamless transition, the developers employed a rigorous validation strategy:

  1. Execution of the full test suite across all supported targets.
  2. Comparative analysis of linker output using a vast array of real-world workloads and option permutations.
  3. Successful builds of the entire Gentoo package set.

🛡️ Safety and Stability

The migration to Rust significantly enhances the linker's resilience when handling malformed or corrupted input files.

VersionBehavior on Corrupted InputResult
C++ VersionPotential out-of-bounds memory readsSegmentation Fault (Crash)\text{Segmentation Fault (Crash)}Segmentation Fault (Crash)
Rust VersionStrict bounds-checkingControlled Panic\text{Controlled Panic}Controlled Panic

🛠️ Build and Installation Guide

The build pipeline has been overhauled. Please follow these updated instructions:

Compilation Steps

  • Execute cargo build --release to compile the binary.
  • Run ./install-mold.sh to perform the installation.

Environment Variables:

  • PREFIX and DESTDIR: Supported by the installation script.
  • MOLD_LIBDIR: If libraries are installed in a non-standard path (e.g., /usr/lib64 instead of $PREFIX/lib), this variable must be set during both the build and install phases so mold -run can locate mold-wrapper.so.

Dependencies and Allocation

  • Memory Allocation: By default, it statically links mimalloc 3.5.3. To switch to the system's allocator, use: --features system-allocator
  • Compression/Hashing: Includes zstd and BLAKE3, and links the system zlib if present. To force the use of the system's zstd via pkg-config, set: ZSTD_SYS_USE_PKG_CONFIG=1

Build System Changes

Note: install-test-deps.sh is now only required for those running the test suite.


🐛 Bug Fixes & Compatibility Enhancements

💥 Crash Fixes

  • Resolved crashes occurring during the creation of statically-linked executables when using --default-symver or version scripts.
  • Fixed a corruption/crash issue when the output file was also listed as an input (e.g., mold -r -o foo.o foo.o bar.o).
  • Fixed crashes associated with --icf=all when combined with --emit-relocs.
  • Fixed crashes in --noinhibit-exec when referencing symbols in discarded COMDAT groups.

⚙️ Logic and Behavioral Improvements

  • Section GC: --gc-sections will no longer strip functions designated by --fini or --init.
  • Symbol Handling: Common symbols with identical names but varying sizes now adopt the largest size and most stringent alignment (matching lld and GNU ld).
  • ICF: --icf=safe no longer folds functions that are exported from shared libraries.
  • Versioning:
    • Versioned references (e.g., foo@VER) in shared libraries no longer trigger the inclusion of unversioned foo members from archives.
    • In version scripts, if a symbol appears in multiple nodes, the first occurrence now takes precedence.
  • Determinism: Eliminated non-deterministic output in several areas:
    • --repro and --dependency-file.
    • Dynamic relocations.
    • -r when handling numerous COMDAT groups with the same name.

🛠️ Relocatable (-r) and Relocation Fixes

  • Relocatable Bugs: Fixed issues where C++ exceptions failed in subsequent input files, symbols were erroneously removed by -s, -x, or -X, and data was dropped by --gc-sections.
  • Section Headers: Corrected sh_link for SHF_LINK_ORDER sections (such as .ARM.exidx).
  • DWARF: Fixed crashes when using --strip-debug with DWARF type units.
  • Address Accuracy: Corrected silent address errors for R_ARM_REL32 and R_X86_64_GOTOFF64 (GOT-relative relocations) against shared library symbols.
  • Diagnostics: PC-relative relocation errors in position-independent output now provide clear explanations and remediation steps.

⚠️ Error Handling (Now failing explicitly instead of crashing)

The following scenarios now trigger a formal error:

  • --defsym values exceeding 64 bits64\text{ bits}64 bits.
  • --defsym aliasing a symbol already defined in a shared library.
  • Undefined non-weak hidden symbols in shared libraries (or when using --unresolved-symbols=ignore-all).
  • Allocated sections that are simultaneously compressed.
  • Combining --strip-all with --emit-relocs.

⌨️ CLI and Environment

  • GNU Parity: Single-dash options are now parsed identically to GNU ld.
  • Argument Parsing: The following flags no longer consume the subsequent argument:
    • --thinlto-index-only
    • --lto-pseudo-probe-for-profiling
    • --dynamic-list-data
  • New Options: Added support for --no-color-diagnostics.
  • Paths: Fixed relative path handling for --repro, --chroot, and -C.
  • Resources: Reserved 8 GiB8\text{ GiB}8 GiB of virtual address space at startup →\rightarrow→ Removed reservation, enabling compatibility with ulimit -v.
  • Environment: MOLD_JOBS now functions correctly even if XDG_RUNTIME_DIR is an empty string.

🏗️ Miscellaneous & Architecture Specifics

  • Debug Files: .gnu_debuglink sections are no longer included in files created via --separate-debug-file.
  • Symbols: Removed redundant symbols: __start_EHDR, __stop_EHDR, __start_PHDR, and __stop_PHDR.
  • Architecture Fixes:
    • [AArch64/PPC32/ARM32]: Fixed range extension thunks for static function calls in different sections (critical for large binaries like Chromium ARM64 debug builds).
    • [AArch64]: Added support for R_AARCH64_GOT_LD_PREL19 and R_AARCH64_TSTBR14.
    • [ARM32]: Expanded support for various relocation types (e.g., R_ARM_...).