Mold, a modern Linker superior to GNU gold and LLVM lld

Rui Ueyama, author of the LLVM lld composer and chibicc compiler, unveiled ago little the fruits of his new work and presented the first stable version of the new «high-linker the Mold», which stands out for being far ahead of the link rate of the GNU gold and LLVM lld object file linkers.

Currently, the project considered ready for production deployments and it can be used as a faster transparent replacement for the GNU linker on Linux systems.

About Mold

Mold supports all the features of the GNU linker and it has a very high performance, since the links it makes are only twice as slow as simply copying files with the cp utility.

For example, when compiling Chrome 96 (code size 1,89 GB), linking executable files with debuginfo on an 8-core computer takes 53 seconds with GNU Gold, LLVM lld takes 11,7 seconds, and Mold only 2,2 seconds (26 times faster than GNU gold).

Also, when linking Clang 13 (3,18 GB), GNU gold takes 64 seconds, LLVM lld takes 5,8 seconds and Mold takes 2,9 seconds and when linking Firefox 89 (1,64 GB), GNU gold takes 32,9, 6,8 seconds, LLVM lld takes 1,4 seconds and Mold takes XNUMX seconds.

mold 1.0 is the first stable and production-ready version of the high-speed linker. On Linux-based systems, it should "just work" as a faster direct replacement for the default GNU linker for most user programs. If you're creating a large executable that takes a long time to link, it's worth testing the template to see if it can shorten compile time. The mold is easy to build and use.

In this way the reducing compilation time significantly improves the convenience of developing large projects by reducing the wait time in the executable file generation process when debugging and testing changes.

The motivation for creating Mold was the annoyance of having to wait for the link to complete after each code change, as well as the low efficiency of existing linkers in multicore systems and the desire to test a fundamentally different link architecture without resorting to unnecessarily complicated models such as incremental linking.

The high performance of linking an executable file from a large number of compiler-prepared object files in Mold is achieved through the use of faster algorithms, the active parallelization of operations between available CPU cores, and the use of data structures more efficient.

For example, Mold implements a technique to perform computationally intensive concurrent with file copying, proactively loading object files into memory, using fast hash tables when resolving characters, scanning relocation tables in a separate sequence, and deduplicating sections that are repeated in different files.

Finally, it should be noted that Mold is written in C ++ 20 and is distributed under the AGPLv3 license, which is GPLv3 compliant, but not GPLv2 compliant as it requires openness changes when developing network services. This choice is explained by the desire to receive funding for development: the author is ready to sell the rights to the code to re-license under a permissive license such as MIT, or to provide a separate commercial license for those who are not satisfied with the AGPL.

As for future plans that they have, it is mentioned that currently working on the Mold for macOS  (although this version 1.0 support is already added but is still considered alpha) and once it is complete, the support will be released in version 2.0 of Mold and after that it is mentioned that it will work in Mold for Windows and will be implemented in version 3.0.

Si you want to know more about this project or you want to compile it to be able to use it on your system, you can check the details and / or the compilation instructions In the following link.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.