2021-08-25 22:22:10 -06:00
|
|
|
mold
|
2021-08-14 23:26:16 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
|
|
|
mold is a multi-threaded, high-performance linker that is several times faster
|
|
|
|
than the industry-standard ones, namely, GNU ld, GNU gold or LLVM lld. It is
|
|
|
|
developed as a drop-in replacement for these linkers and command-line compatible
|
2021-08-21 07:09:11 -06:00
|
|
|
with them with a few exceptions. [0]
|
2021-08-14 23:26:16 -06:00
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
Upstream: $/rui314/mold
|
2021-08-14 23:26:16 -06:00
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
|
|
|
|
[000] Index
|
2021-08-14 23:26:16 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
2021-08-25 22:22:10 -06:00
|
|
|
* Installation ........................................................... [001]
|
|
|
|
* Setup .................................................................. [002]
|
|
|
|
* Usage .................................................................. [003]
|
|
|
|
* Troubleshooting ........................................................ [004]
|
|
|
|
* Package Fails To Link With Mold ...................................... [005]
|
|
|
|
* References ............................................................. [006]
|
2021-08-14 23:26:16 -06:00
|
|
|
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
[001] Installation
|
|
|
|
________________________________________________________________________________
|
2021-08-14 23:26:16 -06:00
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
| |
|
|
|
|
| $ kiss b mold |
|
|
|
|
| |
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
[002] Setup
|
2021-08-14 23:26:16 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
To use mold as the system linker one of the following methods must be used.
|
|
|
|
The first solution is recommended as it removes all possibility of the prior
|
|
|
|
linker being executed by mistake.
|
2021-08-14 23:26:16 -06:00
|
|
|
|
|
|
|
1. Use the alternatives system to set mold as the system linker.
|
|
|
|
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
| |
|
2021-08-21 07:09:11 -06:00
|
|
|
| $ kiss a mold /usr/bin/ld |
|
2021-08-14 23:26:16 -06:00
|
|
|
| |
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
|
|
|
|
2. Add --ld-path to CFLAGS/CXXFLAGS (Clang > 12.0)
|
|
|
|
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
| |
|
2021-08-21 07:09:11 -06:00
|
|
|
| $ export CFLAGS="$CFLAGS --ld-path=/usr/bin/mold" |
|
|
|
|
| $ export CXXFLAGS="$CXXFLAGS --ld-path=/usr/bin/mold" |
|
2021-08-14 23:26:16 -06:00
|
|
|
| |
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
|
|
|
|
3. Add -B to CFLAGS/CXXFLAGS (GCC)
|
|
|
|
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
| |
|
2021-08-21 07:09:11 -06:00
|
|
|
| $ export CFLAGS="$CFLAGS -B/usr/lib/mold" |
|
|
|
|
| $ export CXXFLAGS="$CXXFLAGS -B/usr/lib/mold" |
|
2021-08-14 23:26:16 -06:00
|
|
|
| |
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
[003] Usage
|
2021-08-14 23:26:16 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
Mold does not yet support all use cases. It can not be used to link the Linux
|
|
|
|
kernel (due to lack of linker script support) and It has no support for LTO
|
|
|
|
(Link Time Optimization).
|
|
|
|
|
|
|
|
With mold as the default linker, running the package manager as normal should
|
|
|
|
result in its usage. To verify that mold is being used, disable binary stripping
|
|
|
|
(KISS_STRIP=0) and run the following command on a newly built executable.
|
2021-08-14 23:26:16 -06:00
|
|
|
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
| |
|
|
|
|
| $ readelf -p .comment /path/to/exe |
|
|
|
|
| |
|
|
|
|
+------------------------------------------------------------------------------+
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
If 'mold' appears in the output, everything is setup correctly.
|
2021-08-14 23:26:16 -06:00
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
|
|
|
|
[004] Troubleshooting
|
2021-08-14 23:26:16 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
2021-08-21 07:09:11 -06:00
|
|
|
|
2021-08-25 22:22:10 -06:00
|
|
|
--[005] Package Fails To Link With Mold ----------------------------------------
|
2021-08-21 07:09:11 -06:00
|
|
|
|
|
|
|
If a package in the official repositories fails to link with mold, open an
|
|
|
|
issue. If a package in a third-party repository fails to link with mold, open
|
|
|
|
an issue in their tracker. If a package you maintain fails to link (and the
|
|
|
|
issue is in the linker), open an issue upstream.
|
|
|
|
|
|
|
|
|
|
|
|
[006] References
|
|
|
|
________________________________________________________________________________
|
|
|
|
|
|
|
|
[0] $/rui314/mold
|
|
|
|
|
|
|
|
|