mold

Mold: A Modern Linker 🦠

MIT License

Downloads
262
Stars
13.4K
Committers
100
mold - mold 1.6.0-pre.1

Published by rui314 about 2 years ago

This is a pre-release for those who want to test it before the official 1.6.0 release.

New features

  • [ppc64] mold now supports 64-bit big-endian PowerPC ABI, which is also known as PPC64 ELFv1 or just ppc64. Older PowerPC systems using the processors in the big-endian mode are based on this ABI. Note that modern little-endian PowerPC systems are based on PPC64 ELFv2 ABI (which is also known as ppc64le), which is already supported by mold.
  • [s390x] Linux/s390x is now supported. Linux/s390x is the Linux environment running on IBM z/Architecture mainframes. We do not only port our linker to s390x but also found a couple of issues in the existing GCC toolchain for s390x. So, we are improving the whole IBM mainframe ecosystem!
  • mold now creates smaller output files. It is most noticeable on targets with large page sizes such as PPC64 (on which the common page size is 64 KiB), but even on x86-64, it should save a few kilobytes per an output file.

Bug fixes and compatibility improvements

  • [arm64] mold can now link executables with -static-pie. Previously, executables linked with that flag crashed immediately.
mold - mold 1.5.1

Published by rui314 about 2 years ago

mold 1.5.1 is a new release of the high-speed linker. This version contains only the following bug fix. We recommend upgrading from 1.5.0 if you are being affected by this issue.

  • We changed the memory layout to save both memory and disk space in 1.5.0. Even though the new layout works fine on most systems, the change made the linker to create unusable executables for systems with large pages. Specifically, if you specify a large number for the -z max-page-size option, the loader refused to execute it with the error while loading shared libraries: cannot apply additional memory protection after relocation: Cannot allocate memory error. We reverted our recent commits so that mold creates output files with the same memory layout as it did before 1.5.0. (e62de0b31f0350e425c28532cc8fad16e720c161)

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 - mold 1.5.0

Published by rui314 about 2 years ago

mold 1.5.0 is a new release of the high-speed linker. The highlight of this release is that we start supporting the following four new targets: PPC64LE, SPARC64, RV32BE and RV64BE. mold 1.5.0 also includes various bug fixes, performance and compatibility improvements as shown below.

Starting from this release, we recommend using cmake instead of make to build mold. We will soon stop supporting make, so please migrate early and report issues if you find any.

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

  • PPC64LE and SPARC64 are now supported as new targets. They haven't yet been as well tested as other targets, but they are already able to link mold itself on these platforms. (Note that PPC64LE is very unlikely to work on the most recent POWER10 machines as we didn't have a chance to test it due to a limited availability (POWER10 was released in 2021). If you can support us on this matter, please contact us. We also accept donations, so please consider supporting our project!)
  • RV32BE and RV64BE (32-bit and 64-bit big-endian RISC-V) are now supported as experimental targets. RISC-V is usually little-endian, but there exists a big-endian RISC-V as an extension. You can make gcc to emit code for big-endian RISC-V by passing -mbig-endian. mold can now link object files generated with that option.
  • --compress-debug-sections=zstd is now supported. This is an option to compress debug info embedded to an output file with Zstandard compression algorithm. Compared to the existing --compress-debug-sections=zlib, zstd is faster and gives a higher compression ratio. You probably can't start using zstd compression today though, because other tools such as gdb may not be able to read zstd-compressed debug info yet. But adding this option early makes mold future-proof. (ede7a5aaa3876fd19bb86c427e2033026d2770e2)
  • mold no longer aligns loadable segments to page boundaries to reduce output file size. Previously, we allocated holes between loadable segments. The saving by this change is most visible for small programs. For example, a "hello world" program used to be ~18 KiB on x86-64. It's now 7.2 KiB. (2941d75c717279fcb1df23acf4ed911b3d1e4daa)

Bug fixes and compatibility improvements

  • [RISCV] We optimized code so that the link speed for RISC-V is now comparable to the other targets. As an example, linking mold itself (~150 MiB in size) for RV64 used to take ~45 seconds on a simulated 16-core machine. It now takes only ~0.25 seconds. (3ab548971fe3e2d3a5643b88d14d044be2e177c7)
  • mold used to create more than one .rodata section under a certain condition. It's not technically wrong but confused Valgrind. This issue has been resolved. (25c7aee1d928df650b92e1b9f8f9d4f37fd27829)
  • [ARM32] Previously, mold failed to promote remaining undefined symbols to dynamic symbols if symbols are undefined weak. That caused a link failure for libxml (https://github.com/rui314/mold/issues/660). This issue has been resolved. (72e26d9b690221445310202ef0d37f1a8ef6cbd9)
  • mold didn't copy symbol types when creating symbol aliases for the --defsym option. (8c7f31cafae4b859dbd5edf4a0465af4922bb32c)

Removed features

  • --compress-debug-sections=zlib-gnu has been removed. LLVM lld removed that option too as there seems to be no usage of the flag.

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 - mold 1.4.2

Published by rui314 about 2 years ago

mold 1.4.2 is a maintenance release of the high-speed linker. This release includes, but not limited to, 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 and bug fixes

  • [RV32] We've fixed several issues for 32-bit RISC-V. mold can now build complex programs including itself for the target.
  • [ARM32] mold gained range extension thunks so that it can now link programs whose .text is larger than 16 MiB. Previously, mold couldn't link such large programs. We've also fixed general stability issues for ARM32.

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 - mold 1.4.1

Published by rui314 about 2 years ago

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. (e6a0e67a382b8ef70a020e02bbf3b7f367c2f7dc)

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 (https://github.com/rui314/mold/issues/606). The bug has been fixed. (b16306806db76f39678bb7ea433c74f9e1994310)
  • --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. (5dd122710ccd058346a922f94cffb7c595168fe7)
  • 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 (f0e1237b0022d839ba398ba0d57bcace3f1c57de)
  • Symbols in mergeable string sections now have correct output section indices instead of SHN_UNDEF. (a595c4874d83b40d5e595babad0af34ecdcb58d3)
  • [ARM32] Previously, calling a function from ARM code to Thumb code caused a program crash due to bug https://github.com/rui314/mold/issues/442. This issue has been fixed. (053b90b489608ad2715b27b1c6f1bf434329676f)

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 - mold 1.4.0

Published by rui314 about 2 years ago

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. (d9db6bcf4903a4df6581d1729da15df9a8cf87d3)
  • mold now demangles Rust symbols in error messages thanks to @eddyb's rust-demangle.c. (22e1bba58ed93a4798fb288094727cb6b7e149fc)
  • --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. (e115aaef4ccee5bbb73af1b5d1c6b650c956269f)
  • [x86-64] PLT entries created by mold now always begins with ENDBR64 instruction to improve compatibility with Intel IBT (Indirect Branch Tracking.) (e3e371dcd3dc54bce2071ad7b92313075f4c10d7)

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 (https://github.com/rui314/mold/issues/507). (764d7575f7da89508a0aabe4febc9008c5429674)

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 - mold 1.3.1

Published by rui314 over 2 years ago

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. (3b753987860fc6b26385be56db802000c9217fea)
  • [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. (52943009b7dce4a0ebb5943092d47e6e33625401)

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 - mold 1.3.0

Published by rui314 over 2 years ago

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. (https://github.com/rui314/mold/issues/484, 27908af67dd1b989dedca849aceffc54f1b605f0)
  • 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). (d8a8877875d96d0efdb727b4ba600ee3910a333f)
  • mold now prints out undefined symbol errors in a format similar to LLVM lld. (13816a14e1df39650e6c3c5826f036102d4bc54a)
  • mold now prints out a better error message for the disk full situation. (596926008a4042b94a6901e53236ab1856a29e1a)
  • mold can now build GCC 12 with LTO. (708ad63474e38a61ed1d6784636b71e84bd4ae00)
  • Fixed an LTO issue on 32-bits hosts such as i686. (920266bce443eae83b78cd947d635ff5aa629d73)
  • mold is now AddressSanitizer and UndefinedSanitizer clean. (fafb75b0e5206fa3453fcba883bc42a7f15d50d9, 3499ee6ac7c0fbb25ed47b7a2abfa2dc9638ae44)
  • mold used to create broken debug info on 32-bits hosts (https://github.com/rui314/mold/issues/490). The bug has been fixed. (0abd0a40db85ee847ec9606a62fc419c86c738f5)
  • 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. (232dafa8d01f787ac069706de571c1614fcbf9df)
  • --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. (https://github.com/rui314/mold/issues/505, e9f6715c6ef01b5bf02dc8bf36bce8af4f07b44e)

Removed features

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

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 - mold 1.2.1

Published by rui314 over 2 years ago

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. (7ebd071273691a5cc095203f6542b2b13ec6642c)
  • mold can now handle TLS common symbols. It looks like GCC sometimes creates such symbol for a thread-local variable. (cf850f8993210185e57c329ce14a361b7e51cbe0)
  • 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. (8298c0ad16a4ab9cf95efe4ada43bbba9f33941d)
  • mold used to write a PLT address of a symbol instead of its address to .symtab. This bug has been fixed. (e088db72e006e8f1bcbc7c9561a3e22777cd33ff)
  • mold can now handle an input file with more than 219 symbols. (f1f2d40469a3a501c573b1181e0e4362c030a9bf)
  • /usr/local/libexec/mold/ld is now installed as a relative symlink instead of an absolute symlink. (5803c3c200f301adc3abdb66df16d3d669712d70)
mold - mold 1.2.0

Published by rui314 over 2 years ago

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. (https://github.com/rui314/mold/commit/a7475dd5e35bd57cfdf5958e1e473a84576cf717)
  • 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. (82e80721ac2ca9ed899bcf09ca1b56469e537e38)
  • -static-pie now works with older versions of glibc thanks to a few bug fixes. (3d68824dead842bc218e9cc883c3c71c5ce7c8da, 0884f279e04a6ec061c4529f5f782065bcfe560a)
  • Issues found by UndefinedBehaviorSanizer, AddressSanitizer and ThreadSanitizer are fixed. (bf26753bbd42809fa5ff51c8b9479644cf42f9c1, f4753b34bf836dfe98a8b0032d81c0324c31e343, e1e4e9fd9ef287f001d42fa5af6183e8f721ddeb)
  • 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 (https://github.com/rui314/mold/issues/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. (100922b650cbe114f165c7269a9b6d2ad39d74f7)
  • .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. (392781a0e2ae005a9a728d48f222b2fa3a919a72)
  • 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 (https://github.com/rui314/mold/issues/352). For the sake of compatibility with such programs, we now make PLTs canonical only when their addresses are taken. (e0bc74ad8a8af2588d26a6b8947b7b7f3d07b562)
  • 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. (5feab826de522fd5d6d7dee05ec7ae9ede347576)
  • libbacktrace sometimes fail to read compressed debug sections in mold-generated files due to a bug. We not only fix that libbacktrace's bug (https://github.com/ianlancetaylor/libbacktrace/pull/87) but also implemented a workaround to mold (ba6347996bf2aecab39188dd0b549960c5ba86d9) so that mold works with older versions of libbacktrace.
  • [ARM64] mold now recognizes R_AARCH64_LD_PREL_LO19 relocation. (146ddd711c61a4e7bb5102e604b10410d75e2f81)
  • [RISCV64] The correct semantics of R_RISCV_ALIGN is implemented. (0daf6233fbd672b372440bd7b43bc70c64af7945)
mold - mold 1.1.1

Published by rui314 over 2 years ago

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. (a054bcd4ff1e0381d0f942c1bc0ba4e82e888e0e)
  • 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>. (8f21cc386e555de212899c8ab0b4674c77616f60)
  • 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 (e4134337529b16443b6232de211b2ec5860d88e5)
  • -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. (f2d27d8d242762307646045bad3707cf25493ed6, 7068c0cd0f87e598af0f12dbfce1e044e0894eb3, 83e05dae284cc748596c937afe5290da01f24154, 4dae89672698ffc3692d2abef9108e98fbf05b02)
  • 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. (480efdedf0ccf0eb86239e93bfbb36e8438dc294)

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. (3999aa8b1857ed57a721f7f110a5e35940376923)
  • Previously, mold sometimes created corrupted output file on x86-64 if an input file containing thread-local variables were compiled with -mcmodel=large (https://github.com/rui314/mold/issues/360). This issue has been fixed. (4aa4bfa4a6e46af59ee5f83cf42d4f23f02cc348)
  • Previously, mold created corrupted debug info section on i386 if an input debug section is also compressed using the compiler -gz option. (https://github.com/rui314/mold/issues/361) This issue has been fixed. (30683645c247aa47146d97ecf19b6de2436deb32)
  • 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. (https://github.com/rui314/mold/issues/363). This issue has been fixed. (41986279deb2ec77f69d027cc38cda23c9d2adf1)
  • When building a large program with GCC LTO, mold occasionally failed with "too many open files" error. This issue has been resolved. (e67f460bfdf4a6aa5221efdf0f3547c05b3a2152)
  • 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. (eb79859ea244eaa9a91477643e609cb173144859)
mold - mold 1.1

Published by rui314 over 2 years ago

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. (46995bcfc3e3113133620bf16445c5f13cd76a18)
  • 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. (e76f7c0d474e667cc0eccac5281709664539b714)
  • 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. (26fe71d64c3af2812b6349a0098d857ce2419156)
  • 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. (7e918971545df3a4c90d1eaef116fc58da97da3c)
  • 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. (a1287c26b97d207850e88bc8147c85e63bdff92a)
  • The following options are added: --warn-once (f24b99750102eb32f717a9a4153a7cb14120220b), --warn-textrel (6ffcae428622c216b5f77384a7456fa248981d7c)
  • Runtime dependency to libxxhash has been eliminated. (e5f4b967ed9339fc215dadcef62d656c6d98228a)

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. (0a0f9b3ad5ef787fa4d318846ba1641ffc180769)
  • 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. (73159e241d6c34d76857fe0bfaf0da5069b412c4)
  • 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) (https://github.com/rui314/mold/issues/324). Now, mold accepts such input files. (e65c5d2a1c2484927beb98669c552433b7dc98fd)
  • mold can now be built with musl libc. (42b7eb87a1194f2aac36d55930be325c2dac2044)
  • mold-generated .symtab section now contains section symbols and symbols derived from input shared object files. (e4c03c238e656cd10955acb424b50ccdec1bd9a5, 1550b5affffd221a9c23de740252174a504c2949)
  • 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. (0f8bf23bcf52d119ac329d28dce5d562235f6503)
mold - mold 1.0.3

Published by rui314 over 2 years ago

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

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 - mold 1.0.2

Published by rui314 almost 3 years ago

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. (a5029d19a8fb70f77cb85f5ad58222d385abf716)
  • The following flags have been added: -z ibt (9ca6a9dc5e060e1283f9c3b413665640b02f1de5), -z cet-report (31a43a7ba69f5ed0b22163dcd51f667055525831), -z shstk (e29bd8f42b5571494138d22036fb2a4a2a2b55d2), -z ibtplt (fbfa01dcd1f5c7a38a78ea6350d3635e1189b0e5)
  • [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. (92876820cb7f621d5fd3581874aee49b4a8ed881)
  • [NetBSD] mold is now usable on NetBSD. (948248b732cea40057d1a66fd128f72dad87e09d)
  • [x86-64] mold now emits compact 8-byte PLT entries instead of the regular 16-byte PLT entries if -z now is given. (0370e7f1b355cf577ee3b462148337ece3671e0b)
  • 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. (bd6afa1b23218c70877d318e8aac722298f931a8)

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. (d0c1c4db19b41d7b7720640c68faf7c79828437a)
  • 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. (d8dc8a67875bd49498612fb5c803116c220393d9)

Bug fixes and compatibility improvements

  • mold can now link ICC-generated object files with GCC-generated ones even if the -static flag is given. (https://github.com/rui314/mold/issues/271, be6ae07ac181eb783f2d7428572a5e0aab879efa)
  • mold can now handle archive files (.a files) larger than 4 GiB. (bba506d6b4ba90b6857e95a3b6028b2985396629)
  • 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 https://github.com/rui314/mold/issues/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. (cea6a569afa544826c91fda7ef0f9941f50c9459)
  • 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. (ce5749ce2fdb41488f0b0608d3fcc5cb016d9683)
  • 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. (27d836180fb7868bf7cd6e87917e0c09531dd945)
  • 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. (4348417dd8df5ca19d3c173f9447f72a0fe39985)
  • [i386] mold now ignores some legacy symbols in an i386 CRT files to avoid duplicate symbol errors. (https://github.com/rui314/mold/issues/270, 0c1904672186bb9a395259cf71a276cff462fcbb)
mold - mold 1.0.1

Published by rui314 almost 3 years ago

mold 1.0 is a maintenance release of the high-speed linker. It contains a few new features and various bug fixes.

New features

  • make install now creates /usr/local/libexec/mold/ld as a symlink to the mold executable. We do this for GCC. By passing -B/usr/local/libexec/mold, you can tell GCC to use ld inside that directory instead of /usr/bin/ld. (e8dcecfff0391af8d04d00845c36070a628e8c02)
  • xxHash library is now included in the mold's source tree as a subtree for ease of building. If you want to link against a libxxhash in a system library directory, pass SYSTEM_XXHASH=1 to make. (665bffa52f3fc979c608c72f3fdf2f8280eeb13b)
  • The extern "C++" directive is now supported in the dynamic list. (7aa5c393e4bc1d35509f9ee7cc2980314359f89c)
  • --color-diagnostics is supported. mold used to ignore that flag. (6e290aab3e2bf445df46d117832579bf6ab2aa1c)
  • Not only * but also ? are now treated as special characters in the version script wildcard pattern. (31b0248b05e433c0589fe2736e61852515427d9a)
  • The --threads=N option has been added as an alias for --thread-count=N. (f9ff04866e9926b343d71d45facdb693ef37928d)
  • The following option has been added: --defsym (f6e800655b3ed6a5118017d4cdfddbba3b4fbf40), -z nodefaultlib (8c86c2849697dd2a5747b075fa818ebead6b09e1), -z separate-code, -z noseparate-code and -z separate-lodable-segments (5601cf42366a20e04b080923fe535ab502929732), -z max-page-size (f3766cda81f395adc84f79f2ab057a747172a1ef)

Bug fixes and compatibility improvements

  • mold now issue a warning instead of an error for an unknown -z option. (8bc57363c8ea90c8bdc99274a03da1e347030255)
  • mold previously created a PT_NOTE segment for non-SHF_ALLOC note segments. This is a wrong behavior because we should create segments only for memory-allocated sections. This problem has been fixed. (76407a66468802f42889fd161f1aa5a6c301dc9f)
  • Previously, a version script can affect symbol visibility of undefined symbols when they are promoted to dynamic symbols. This is a semantically incorrect behavior and caused a libQt build failure (https://github.com/rui314/mold/issues/151). The issue has been fixed. (36633895e58c9cbb089ad80c64d9208a06e2baba)
  • Previously, mold silently turned unresolved undefined symbols into absolute symbols with value 0 if -shared, -z defs and -warn-undefined-symbols are specified. Even though this behavior makes sense, it's not compatible with GNU ld which promotes such symbols into dynamic symbols. This incompatibility causes a link failure for Firefox. Since 1.0.1, mold behaves the same as GNU ld. (04ccd4dbdd77f6bc10508b19ab12e46cc9c32731)
  • Previously, mold applied wrong values for relocations against Initial-Exec thread-local variables. That caused a link failure for Mesa 3D graphics library (https://github.com/rui314/mold/issues/197). The issue has been resolved. (d1161137d9de64892e193cecda16fdf2f585351f)
  • GCC 7 has a bug that it emits incorrect relocations against thread-local variables under a certain condition. That bug was unnoticed because existing linkers silently produces an output that works fine in most cases but is technically corrupted. mold used to check for that error condition and report an error. Now, mold does not report it as an error for the sake of bug-compatibility with GCC 7. I don't think relaxing the error check will cause any new issue to existing GCC 7 users, because if it does, they would have been experiencing the issue with existing linkers already. (d9606d65b5da7e7af4c1858a121264e80e58ef49)
  • If an output file has more than one sections for thread-local BSS, they were laid out in such that they are overlapping with each other. This bug caused a runtime error for programs compiled with DMD, a compiler for the D language (https://github.com/rui314/mold/issues/126). This layout issue has been resolved. (https://github.com/rui314/mold/commit/b151de6684a9b48381cc6340fa10b6e1cfc1a8c5)
  • Previously, mold failed to look up correct files under --sysroot in some conditions. That caused a link failure for ClickHouse (https://github.com/rui314/mold/issues/150). This bug has been fixed. (135f17c5aa930fdd2441080a086f0a6379774c57)
mold - mold 1.0

Published by rui314 almost 3 years ago

mold 1.0 is the first stable and production-ready release of the high-speed linker. On Linux-based systems, it should "just work" as a faster drop-in replacement for the default GNU linker for most user-land programs. If you are building a large executable which takes a long time to link, mold is worth a try to see if it can shorten your build time. mold is easy to build and easy to use. For more details, see README.

mold is created by a person who knows very well as to how the Unix linker should behave, as I'm also the original creator of the current version of the LLVM lld linker.

There's no fancy new features in 1.0. Actually, 1.0 is very similar to 0.9.6. That being said, we'd like to make it clear by incrementing a major version number that mold for Linux is now stable.

Future plans

We are currently working on mold for macOS, and once it's complete, we'll release it as mold 2.0. After that, we'll work on mold for Windows and release it as 3.0.

mold 1.0's source tree has code for mold for macOS, but that's pre-alpha. Do not use it unless you know what you are doing.

Changes since mold 0.9.6

mold - mold 0.9.6

Published by rui314 about 3 years ago

mold 0.9.6 is a maintenance release of the mold linker. This release contains only a single change to fix the following issue:

  • mold used to create dynamic relocations for imported symbols when creating a position-dependent executable. That worked fine in an environment in which position-independent code (PIC) is enabled by default such as recent versions of most Linux distros. However, it failed with the "recompile with -fPIC" error if PIC was disabled and a dynamic relocation was created in a read-only section. mold 0.9.6 fixed the issue by creating copy relocations and PLTs for such symbols. (https://github.com/rui314/mold/issues/116)
mold - mold 0.9.5

Published by rui314 about 3 years ago

mold 0.9.5 is a maintenance release of the mold linker.

Highlights of mold 0.9.5

  • In 0.9.4, we changed the mold's behavior on remaining weak undefined symbols, so that they would be resolved to address zero if we were creating a shared object file with the -z defs option. Now, such symbols will be promoted to dynamic symbols so that they'll get another chance to be resolved at run-time. This change fixes a regression of Firefox build failure (https://github.com/rui314/mold/issues/114), which depends on this particular linker behavior to export symbols from libxul.so.
  • mold can now be built on macOS. Note that mold is still able to produce only ELF (Unix) files — so you can use it for cross compilation on macOS for Linux, but you can't use mold for macOS native development.
  • Relocation overflow are now reported as errors on AArch64 and i386. Previously, such relocations were silently producing incorrect output.
mold - mold 0.9.4

Published by rui314 about 3 years ago

mold is a new linker that is optimized for modern multi-core machines. mold is command-line compatible with the other major linkers, GNU ld, GNU gold and LLVM lld, yet it is several times faster than them. Its goal is to increase programmer productivity by speeding up program build time, especially for rapid edit-build-test-debug cycles.

Highlights of mold 0.9.4

  • mold -run now intercepts invocations of ld, ld.lld and ld.gold wherever they are in the directory hierarchy. Previously, they were intercepted only if they were in /usr/bin. This change was made because it is not uncommon to install a compiler toolchain into a directory other than the system bin directory.
  • AArch64 (Arm 64-bit) support has been significantly improved. mold can now link many real-world programs including itself for AArch64.
  • Fix an issue that relocation addends were not handled correctly for i386.
  • mold is now able to link LLVM compiler-rt's CRT files.
  • Fix an issue that a dynamic relocation was created for a read-only section if the relocation refers an unresolved weak symbol.
  • Undefined weak symbols are now always resolved to address 0 instead of being promoted to dynamic symbols.
mold - mold 0.9.3

Published by rui314 over 3 years ago

mold is a new linker that is optimized for modern multi-core machines. mold is command-line compatible with the other major linkers, GNU ld, GNU gold and LLVM lld, yet it is several times faster than them. Its goal is to increase programmer productivity by speeding up program build time, especially for rapid edit-build-test-debug cycles.

Highlights of mold 0.9.3

  • The --sysroot option is improved so that it's behavior is compatible with GNU ld.
  • Intel TBB concurrency library is now statically-linked to the mold executable.
  • mold gained the initial AArch64 (ARM64) support. It is still in alpha and not usable for production though.
  • mold can now be built with musl libc instead of with GNU libc.
  • The VERSION linker script command is now supported.
  • mold is now even faster for object files containing a lot of mergeable string contents. Clang-13 with debug info is an example of such input. mold used to take ~3.6 seconds to link it on a simulated 10-core machine. mold v0.9.3 can link it in ~2.3 seconds. That is ~35% speedup.
  • Other various minor compatibility issues have been fixed.
Package Rankings
Top 4.09% on Proxy.golang.org
Top 5.37% on Alpine-edge
Top 1.42% on Alpine-v3.18
Top 15.9% on Spack.io
Top 13.2% on Formulae.brew.sh
Top 8.18% on Alpine-v3.17
Badges
Extracted from project README
Packaging status