First stable release of the Mold linker developed by the developer LLVM lld

Share on Facebook Share on Twitter Pinterest LinkedIn Tumblr

Rui Ueyama, author compositor LLVM lld and compiler chibicc , introduced the first stable release of the new high-linker the Mold , well ahead of the binding rate of object files linkers GNU gold and LLVM lld. The project is considered ready for production deployments and can be used as a faster transparent replacement for GNU linker on Linux systems. The plans for the next significant release include bringing support for the macOS platform to readiness, after which work will begin to adapt Mold for Windows.

Mold is written in C ++ (C ++ 20) and is distributed under the AGPLv3 license, which is compatible with GPLv3, but not compatible with GPLv2, since it requires opening changes when developing network services. This choice is explained by the desire to receive funding for the development – the author is ready to sell the rights to the code for relicensing under a permissive license such as MIT, or to provide a separate commercial license for those who are not satisfied with the AGPL.

Mold supports all the features of the GNU linker and has a very high performance – linking is performed at a speed only twice as slow as simply copying files with the cp utility. For example, when building 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 takes only 2.2 seconds (26 times faster than GNU gold) … When linking Clang 13 (3.18 GB), GNU gold takes 64 seconds, LLVM lld takes 5.8 seconds, and Mold takes 2.9 seconds. When linking Firefox 89 (1.64 GB), GNU gold takes 32.9 seconds, LLVM lld takes 6.8 seconds, and Mold takes 1.4 seconds.

Reducing the build time allows you to significantly improve the convenience of developing large projects by reducing the waiting time in the process of generating executable files when debugging and testing changes. The motivation for creating Mold was the annoyance of having to wait for the link to complete after each change to the code, as well as the low efficiency of existing linkers on multi-core systems and the desire to try out a fundamentally different link architecture without resorting to unnecessarily complicated models such as incremental linking.

High performance of linking an executable file from a large number of compiler-prepared object files in Mold is achieved by using faster algorithms, active parallelization of operations between available CPU cores, and the use of more efficient data structures. For example, Mold implements a technique for performing intensive computations simultaneously with copying files, proactively loading object files into memory, using fast hash tables when resolving characters, scanning relocation tables in a separate stream, and deduplicating sections that are repeated in different files.

Write A Comment

Exit mobile version