Skip to content

Releases: rui314/mold

mold 1.4.1

18 Aug 08:46
Compare
Choose a tag to compare

mold 1.4.1 is a maintenance release of the high-speed linker. This release contains the following improvements and bug fixes.

Note for those who create mold binary packages: if you are building mold for binary distribution, please link the bundled libtbb statically (which is default) or rebuild your distro's libtbb package with my patch so that mold's Link-Time Optimization (LTO) works reliably under heavy load.

New features

  • mold/macOS is now available as an alpha feature. We do not recommend using it for anything serious though. Starting from this version, we accept not only mold/Unix issues but also mold/macOS ones on our GitHub Issues. Feel free to file a bug if you encounter any problem.
  • We started supporting CMake in addition to Make to build mold. Our long-term plan is to migrate from Make to CMake because we want to support Windows eventually and CMake provides a better Windows support than Make does. (e6a0e67)

Bug fixes and compatibility improvements

  • There was a bug that mold accidentally exported a hidden symbol from an executable if a shared library linked to that executable happened to define the same symbol. This caused a build issue with Blender (#606). The bug has been fixed. (b163068)
  • --hash-style=both is now the default if no --hash-style option is given. Previously, --hash-style=sysv was the default. This change shouldn't affect most users because the compiler driver (cc, gcc, clang, etc.) always passes --hash-style to the linker. We made this change because GNU ld defaults to --hash-style=both.
  • Alias symbols defined by the --defsym option now have the same scope as the aliased symbols. Previously, alias symbols defined by --defsym were always hidden and never be exported as dynamic symbols. (5dd1227)
  • mold now accepts foo = bar-style linker script directive to define symbol aliases. Previously, such statement was treated as a syntax error. This change was made to link mariadb-connector-c correctly (f0e1237)
  • Symbols in mergeable string sections now have correct output section indices instead of SHN_UNDEF. (a595c48)
  • [ARM32] Previously, calling a function from ARM code to Thumb code caused a program crash due to bug #442. This issue has been fixed. (053b90b)

Acknowledgements

mold is an open-source project, and we accept donations via GitHub Sponsors and OpenCollective. We thank you to everybody who sponsors our project. In particular, we'd like to acknowledge the following organizations and people who have sponsored $32/mo or more during this release cycle:

mold 1.4.0

05 Aug 02:54
Compare
Choose a tag to compare

mold 1.4.0 is a new release of the high-speed linker. This release contains a few new features and general stability/compatibility improvements as shown below.

Note for those who create mold binary packages: if you are building mold for binary distribution, please link the bundled libtbb statically (which is default) or rebuild your distro's libtbb package with my patch so that mold's Link-Time Optimization (LTO) works reliably under a heavy load.

New features

  • Initial support for the 32-bit RISC-V (RV32) has landed. (d9db6bc)
  • mold now demangles Rust symbols in error messages thanks to @eddyb's rust-demangle.c. (22e1bba)
  • --export-dynamic-symbol and --export-dynamic-symbol-list are now supported for the sake of compatibility with LLVM lld. With these options, you can specify symbols that should be exported using glob pattern. (e115aae)
  • [x86-64] PLT entries created by mold now always begins with ENDBR64 instruction to improve compatibility with Intel IBT (Indirect Branch Tracking.) (e3e371d)

Bug fixes and compatibility improvements

  • mold now defines __dso_handle symbol. The lack of this linker-synthesized symbol caused a link error with GCC in some environments (#507). (764d757)

Acknowledgements

mold is an open-source project, and we accept donations via GitHub Sponsors and OpenCollective. We thank you to everybody who sponsors our project. In particular, we'd like to acknowledge the following organizations and people who have sponsored $32/mo or more during this release cycle:

mold 1.3.1

01 Jul 08:27
Compare
Choose a tag to compare

mold 1.3.1 is a maintenance release of the high-speed linker. This release contains the following minor bug fixes.

Bug fixes and compatibility improvements

  • mold now supports .preinit_array sections. Without this, AddressSanitizer didn't work in some environments. (3b75398)
  • [ARM32] R_ARM_MOVT_PREL and R_ARM_PREL31 relocations are now handled correctly so that mold no longer emit spurious "recompile with -fPIC" errors. (5294300)

Acknowledgements

mold is an open-source project, and we accept donations via GitHub Sponsors and OpenCollective. We thank you to everybody who sponsors our project. In particular, we'd like to acknowledge the following organizations and people who have sponsored $32/mo or more during this release cycle:

mold 1.3.0

18 Jun 04:05
Compare
Choose a tag to compare

mold 1.3.0 is a new release of the high-speed linker. This release contains a few new features and general stability/compatibility improvements as shown below.

Note for those who create mold binary packages: if you are building mold for binary distribution, please link the bundled libtbb statically (which is default) or rebuild your distro's libtbb package with my patch so that mold's Link-Time Optimization (LTO) works reliably under a heavy load.

Bug fixes and compatibility improvements

  • The --icf=safe option has been supported. This option enables a feature to find and deduplicate identical code that can be merged safely. For C++ programs, it typically reduces the output binary size by a few percent. --icf=safe needs to be used with a compiler that supports .llvm_addrsig section; if a compiler does not support it, --icf=safe doesn't do any harm but cannot optimize a given program at all. That section is supported by LLVM/Clang at the moment, and we are working on adding it to GCC. (#484, 27908af)
  • LTO now works reliably under a heavy load. mold used to abort occasionally under such condition on Linux due to a spurious failure of pthread_create(2). (d8a8877)
  • mold now prints out undefined symbol errors in a format similar to LLVM lld. (13816a1)
  • mold now prints out a better error message for the disk full situation. (5969260)
  • mold can now build GCC 12 with LTO. (708ad63)
  • Fixed an LTO issue on 32-bits hosts such as i686. (920266b)
  • mold is now AddressSanitizer and UndefinedSanitizer clean. (fafb75b, 3499ee6)
  • mold used to create broken debug info on 32-bits hosts (#490). The bug has been fixed. (0abd0a4)
  • mold used to accept not only a single dash but also double dashes for single-letter options. For example, --S was accidentally accepted as an alias for-S. This is unconventional, and such options are no longer accepted. (232dafa)
  • --color-diagnostics is now an alias for --color-diagnostics=auto instead of --color-diagnostics=always for compatibility with LLVM lld.
  • pkg-config is no longer needed to build mold.
  • The --package-metadata option is supported. (#505, e9f6715)

Removed features

  • An experimental --preload flag has been removed. (a85b1f5)

Acknowledgements

mold is an open-source project, and we accept donations via GitHub Sponsors and OpenCollective. We thank you to everybody who sponsors our project. In particular, we'd like to acknowledge the following organizations and people who have sponsored $32/mo or more during this release cycle:

We'd also like to thank HPC Engineering at AWS to donate $5,000 AWS credits to us.

mold 1.2.1

28 Apr 12:09
Compare
Choose a tag to compare

mold 1.2.1 is a new release of the high-speed linker. This release contains the following bug fixes.

Bug fixes and compatibility improvements

  • Various bugs in --gdb-index have been fixed.
  • mold now recognizes --thinlto-cache-dir and --thinlto-cache-policy for the sake of compatibility with LLVM lld. (7ebd071)
  • mold can now handle TLS common symbols. It looks like GCC sometimes creates such symbol for a thread-local variable. (cf850f8)
  • In some edge cases, mold created a non-versioned symbol and a versioned one for the same symbol, even though if one symbol is versioned, all symbols of the same name must be versioned. This bug has been fixed. (8298c0a)
  • mold used to write a PLT address of a symbol instead of its address to .symtab. This bug has been fixed. (e088db7)
  • mold can now handle an input file with more than 219 symbols. (f1f2d40)
  • /usr/local/libexec/mold/ld is now installed as a relative symlink instead of an absolute symlink. (5803c3c)

mold 1.2.0

15 Apr 11:49
Compare
Choose a tag to compare

mold 1.2.0 is a new release of the high-speed linker. The highlight of this release is the 32-bit ARM support. We also added other features, and as always, we fixed many bugs and compatibility issues in this release.

New features

  • The ARM32 target is now supported.
  • --gdb-index is implemented. If this option is given, mold creates an .gdb_index section in an output file to speed up GNU debugger. Users have to compile their object files with -ggnu-pubnames to use this flag. mold used to ignore --gdb-index. (a7475dd)
  • mold now supports the following flags: --start-address, -Tbss, -Tdata, -Ttext, --oformat=binary, --disable-new-dtags

Deprecated features

  • An experimental, mold-specific --preload flag has been marked as deprecated. It's still usable, but a warning message will be displayed if that flag is given.

Bug fixes and compatibility improvements

  • -dy and -dn are now accepted as aliases for -Bdynamic and -Bstatic, respectively. (82e8072)
  • -static-pie now works with older versions of glibc thanks to a few bug fixes. (3d68824, 0884f27)
  • Issues found by UndefinedBehaviorSanizer, AddressSanitizer and ThreadSanitizer are fixed. (bf26753, f4753b3, e1e4e9f)
  • mold used to place sections with very large section alignment requirements to wrong places in an output file. That caused a mysterious crash of a produced binary (#405). That bug was most noticeable when Nvidia-provided object files are given because they tend to contain such sections. This bug has been fixed. (100922b)
  • .ctors and .dtors sections are now recognized by mold, and their contents are sorted with a special rule. This shouldn't affect most build environments because these sections have been superseded by .init_array and .fini_array sections a long time ago. But it looks like some old i386 compilers are still using .ctors and .dtors. (392781a)
  • For a non-position-independent executable, we have to make address-taken PLT entries as "canonical". Marking all PLT entries canonical should be harmless in theory, so we did so. However, some programs, notably Qt library, assume that non-address-taken PLTs can never be canonical (#352). For the sake of compatibility with such programs, we now make PLTs canonical only when their addresses are taken. (e0bc74a)
  • mold now defines _TLS_MODULE_BASE_ symbol. A reference to this symbol can occur if -mtls-dialect=gnu2 is given to a compiler. The flag tells the compiler to use TLSDESC mechanism instead of the regular TLS access mechanism to access thread-local variables. (5feab82)
  • libbacktrace sometimes fail to read compressed debug sections in mold-generated files due to a bug. We not only fix that libbacktrace's bug (ianlancetaylor/libbacktrace#87) but also implemented a workaround to mold (ba63479) so that mold works with older versions of libbacktrace.
  • [ARM64] mold now recognizes R_AARCH64_LD_PREL_LO19 relocation. (146ddd7)
  • [RISCV64] The correct semantics of R_RISCV_ALIGN is implemented. (0daf623)

mold 1.1.1

08 Mar 01:04
Compare
Choose a tag to compare

mold 1.1.1 is a maintenance release of the high-performance linker. It contains the following new features, bug fixes and performance improvements including memory usage reduction.

New features

  • The --dependency-file option has been added. The option is analogous to the compiler's -MM option; it generates a text file containing dependency information in the Makefile format, so that you can include a generated file into a Makefile to automate the file dependency management. (a054bcd)
  • mold has gained the --reverse-sections option. If the option is given, mold reverses the list of input sections before assigning them the addresses in an output file. This option is useful to find a bug in global initializers (e.g. constructors of global variables.) In C++, the execution order of global initializers is guaranteed only within a single compilation unit (they are executed from top to bottom.) If two global initializers are in different object files, they can be executed in any order. Reversing the execution order of the global initializers in different input files should help you identify a bug in your program. If your program does not work with -Wl,--reverse-sections, your program depends on the undefined behavior.
  • --shuffle-sections now takes an optional seed for the random number generator in the form of --shuffle-sections=<number>. (8f21cc3)
  • mold now supports the following LTO-related options for compatibility with LLVM lld: --disable-verify, --lto-O, --lto-cs-profile-file, --lto-cs-profile-generate, --lto-debug-pass-manager, --lto-emit-asm, --lto-obj-path, --lto-partitions, --lto-pseudo-probe-for-profiling, --lto-sample-profile, --no-legacy-pass-manager, --no-lto-legacy-pass-manager, --opt-remarks-filename, --opt-remarks-format, --opt-remarks-hotness-threshold, --opt-remarks-passes, --opt-remarks-with_hotness, --save-temps, --thinlto-emit-imports-files, --thinlto-index-only, --thinlto-index-only, --thinlto-jobs, --thinlto-jobs, --thinlto-object-suffix-replace, --thinlto-prefix-replace (e413433)
  • -noinhibit-exec and --warn-shared-textrel have been supported.

Performance improvements

  • We optimized mold's memory usage by reducing the sizes of frequently-allocated objects. Compared to mold 1.1, we observed ~6% reduction of maximum resident set size (RSS) when linking Chromium. Our maximum RSS is smaller than LLVM lld and GNU gold as far as we tested. We measured maximum RSSes with time -v. (f2d27d8, 7068c0c, 83e05da, 4dae896)
  • If Intel CET-based security-enhanced PLT is enabled (i.e. -z ibtplt is given), mold used to create a PLT section in which each entry is 32 bytes long. We optimized the machine code sequence of the CET-enabled PLT section, so each PLT entry now occupies only 16 bytes, reducing the size of .plt by almost half. (480efde)

Bug fixes and compatibility improvements

  • -static-pie now works with recent versions of glibc. Previously, statically-linked position-independent executable would crash on startup when linked with mold. (3999aa8)
  • Previously, mold sometimes created corrupted output file on x86-64 if an input file containing thread-local variables were compiled with -mcmodel=large (#360). This issue has been fixed. (4aa4bfa)
  • Previously, mold created corrupted debug info section on i386 if an input debug section is also compressed using the compiler -gz option. (#361) This issue has been fixed. (3068364)
  • mold used to create multiple .init_array sections if input files contain both writable and non-writable .int_array sections. That caused an issue that some initializer functions would not be executed on process startup. (#363). This issue has been fixed. (4198627)
  • When building a large program with GCC LTO, mold occasionally failed with "too many open files" error. This issue has been resolved. (e67f460)
  • Previously, mold created a corrupted dynamic relocation table if .got.plt is missing. This issue has been fixed by always creating _GLOBAL_OFFSET_TABLE_ symbol in .got on any target. mold used to try to create the symbol in .got.plt on x86-64 or i386. (eb79859)

mold 1.1

21 Feb 01:19
Compare
Choose a tag to compare

mold 1.1 is a new release of the high-performance linker. It contains a few new major features and various bug fixes.

Starting from this release, we distribute not only source but pre-compiled binaries for Linux. You can download a tar file containing mold executable at the bottom of the page. You can copy the contents of the tar file to /usr/local or just use without installation by directly specifying its full path.

New features

  • Native LTO (link-time optimization) support has been added. mold used to invoke ld.bfd or ld.lld if it encountered a GCC IR (intermediate representation) file or an LLVM IR file to delegate the task to the LTO-capable linkers, respectively. Now, mold handles IR files directly. This feature is implemented using the linker plugin API which is also used by GNU ld and GNU gold. Note that the LTO support has been added for completeness and not for speed. mold is only marginally faster than the other linkers for LTO builds because not linking but code optimization dominates. (46995bc)
  • RISC-V (RV64) is now supported as both host and target platforms. mold can link real-world large programs such as mold itself or LLVM Clang for RISC-V. (e76f7c0)
  • The -emit-relocs option is supported. If the option is given, mold copies relocation sections from input files to an output file. This feature is used by some post-link binary optimization or analysis tools such as Facebook's Bolt. (26fe71d)
  • mold gained the --shuffle-sections option. If the option is given, the linker randomly shuffle the order of input sections before fixing their addresses in the virtual address space. This feature is useful in some situations. First, it can be used as a strong form of ASLR (address space layout randomization). Second, you can enable it when you are benchmarking some other program to get more reliable benchmark numbers, because even the same machine code can vary in performance if they are laid out differently in the virtual address space. You want to make sure that you got good/bad benchmark numbers not by coincidence by shuffling input sections. (7e91897)
  • The --print-dependencies and --print-dependencies=full options were added. They print out dependencies between input files in the CSV format. That is, they print out the information as to which file depends on which file to use which symbol. We added this feature with a few use cases in mind. First, you can use this to analyze why some object file was pulled out from an archive and got linked to an output file. Second, when you want to eliminate all dependencies to some library, you can find all of them very easy with this feature. Note that this is an experimental feature and may change or removed in feature releases of mold. (a1287c2)
  • The following options are added: --warn-once (f24b997), --warn-textrel (6ffcae4)
  • Runtime dependency to libxxhash has been eliminated. (e5f4b96)

Bug fixes and compatibility improvements

  • A PT_GNU_RELRO segment is now aligned up to the next page boundary. Previously, mold didn't align it up, and the runtime loader align it down, so the last partial page would not be protected by the RELRO mechanism. Now, the entire RELRO segment is guaranteed to be read-only at runtime. (0a0f9b3)
  • The .got.plt section is now protected by RELRO if -z now is given. This is possible because writes to .got.plt happen only during process startup if all symbols are resolved on process startup. (73159e2)
  • Previously, mold reported an error if object files created with old GCC (with -fgnu-unique) are mixed with ones created with newer GCC or Clang (with -fno-gnu-unique) (#324). Now, mold accepts such input files. (e65c5d2)
  • mold can now be built with musl libc. (42b7eb8)
  • mold-generated .symtab section now contains section symbols and symbols derived from input shared object files. (e4c03c2, 1550b5a)
  • mold-generated executables can now run under valgrind. Previously, valgrind aborted on startup due to an assertion failure because it didn't expect for an executable to have both .bss and .dynbss sections. mold generated .dynbss to contain copy-relocated symbols. The section has been renamed .copyrel to workaround the valgrind's issue. (0f8bf23)

mold 1.0.3

30 Jan 10:46
Compare
Choose a tag to compare

mold 1.0.3 is a maintenance release of the high-speed linker. It contains only the following bug fix:

  • build-static.sh didn't create a statically-linked mold executable (#315). The problem is now fixed. (601b9e6)

If you are not using build-static.sh to build mold executable, you don't need to upgrade from 1.0.2 to 1.0.3.

mold 1.0.2

23 Jan 08:49
Compare
Choose a tag to compare

mold 1.0.2 is a maintenance release of the high-speed linker. It contains a few new features and various bug fixes as well as performance improvements.

New features

  • mold now automatically falls back to ld.bfd or ld.lld if GCC-based LTO (link time optimization) or LLVM-based LTO are requested, respectively. This is a temporary hack until mold gains native LTO support. (a5029d1)
  • The following flags have been added: -z ibt (9ca6a9d), -z cet-report (31a43a7), -z shstk (e29bd8f), -z ibtplt (fbfa01d)
  • [ARM64] Range extension thunks are now supported. Previously, mold reported "relocation overflow" errors when the output file's text segment is larger than some threshold (~60 MiB). Now, it can link large programs just fine. (9287682)
  • [NetBSD] mold is now usable on NetBSD. (948248b)
  • [x86-64] mold now emits compact 8-byte PLT entries instead of the regular 16-byte PLT entries if -z now is given. (0370e7f)
  • RELR-type packed dynamic relocations are now supported. You can enable it by passing -z pack-dyn-relocs=relr. The good news is that it can typically reduce PIE (position-independent executable) size by a few percent. This is not a negligible saving because PIE is now default on many systems for security reasons. The bad news is that it needs a runtime support. To our knowledge, it's supported only on ChromeOS, Android, Fuchsia and SerenityOS at this moment. We need to wait for a while for other systems to catch up. (bd6afa1)

Performance improvements

  • Version script processor was rewritten with the Aho-Corasick string matching algorithm. If your program uses a version script that contains lots of glob patterns with the * metacharacter, you'll likely to see a significant speedup. (d0c1c4d)
  • Relocation processing for non-memory-allocated sections has been optimized. You'll likely to see a speedup if your binary contains large size of debug info. (d8dc8a6)

Bug fixes and compatibility improvements

  • mold can now link ICC-generated object files with GCC-generated ones even if the -static flag is given. (#271, be6ae07)
  • mold can now handle archive files (.a files) larger than 4 GiB. (bba506d)
  • mold no longer have "GNU gold" in its --version string. We had this identification string for some ./configure scripts that didn't work without it, but it causes other compatibility issue such as #284. Now, mold --version prints out something like mold 1.0.2 (compatible with GNU ld). We still need "GNU ld" for many ./configure scripts. (cea6a56)
  • Symbol resolution algorithm has been completely rewritten. The previous implementation was non-deterministic in some edge cases, meaning that outcomes from multiple runs of the linker with the same command line parameters could be different due to thread scheduling randomness or some other internal randomness. Now it is guaranteed to be deterministic. (ce5749c)
  • mold now try to pull out an object file from an archive if it's needed to resolve an undefined symbol with a common symbol. mold used to ignore common symbols in archives, so it could fail with an unresolved symbol error even if the undefined symbol could be resolved using a file in an archive. (27d8361)
  • mold no longer converts .ctors/.dtors sections into .init_array/.fini_array sections. mold used to convert them but in a wrong way. Since .ctors/.dtors have been superseded by .init_array/.fini_array long ago, it should be fine to stop doing this now. (4348417)
  • [i386] mold now ignores some legacy symbols in an i386 CRT files to avoid duplicate symbol errors. (#270, 0c19046)