First stable release of the Mold builder developed by LLVM lld

Rui Ueyama, author of the LLVM lld linker and the chibicc compiler, presented the first stable release of the new high-performance Mold linker, which is noticeably faster than the GNU gold and LLVM lld linkers in the speed of linking object files. The project is considered ready for production implementation and can be used as a faster, transparent replacement for the GNU linker on Linux systems. Plans for the next major release include completing support for the macOS platform, after which work will begin on adapting Mold for Windows.

Mold is written in C++ (C++20) and is licensed under AGPLv3, which is compatible with GPLv3, but not compatible with GPLv2, as it requires open changes when developing network services. This choice is explained by the desire to obtain development funding - the author is willing to sell the rights to the code for relicensing under a permissive license, such as MIT, or 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 very high performance - linking is performed at a speed only half as fast as simply copying files with the cp utility. For example, when building Chrome 96 (code size 1.89 GB), it takes 8 seconds to link executable files with debuginfo on an 53-core computer using GNU gold, LLVM lld - 11.7 seconds, and Mold only 2.2 seconds (26 times faster than GNU gold) . When linking Clang 13 (3.18 GB), it takes 64 seconds in GNU gold, 5.8 seconds in LLVM lld, and 2.9 seconds in Mold. When building Firefox 89 (1.64 GB), it takes 32.9 seconds in GNU gold, 6.8 seconds in LLVM lld, and 1.4 seconds in Mold.

First stable release of the Mold builder developed by LLVM lld

Reducing build time can significantly improve the convenience of developing large projects by reducing the wait in the process of generating executable files when debugging and testing changes. The motivation for creating Mold was the frustration of having to wait for linking to complete after each code change, the poor performance of existing linkers on multi-core systems, and the desire to try a fundamentally different linking architecture without resorting to overly 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 techniques for performing intensive calculations while copying files, pre-loading object files into memory, using fast hash tables for character resolution, scanning relocation tables in a separate thread, and deduplicating merged sections that are repeated across different files.

Source: opennet.ru

Add a comment