Use mold as default linker
While we can parallelize compile processes easily, the linker in use, namely bfd is currently single threaded. While gold improved this behavior, mold is by far the quickest [0].
But there are downsides as well: Mold supports only a small subset of linker scripts, also some packages hard depend on bfd and write their tests specifically for the behavior of bfd. This leads to a list of incompatible packages first shared with gentoo [1].
Due to these issues, replacing /usr/bin/ld has been discarded, instead
the required LDFLAGS have been added.
Broken packages can be worked around by setting
LDFLAGS="${LDFLAGS//fuse-ld=mold /}"
Go packages built with -extldflags=${LDFLAGS}
need to quote the flag
due to the introduced whitespace in LDFLAGS:
go build -ldflags "-v \"-extldflags=${LDFLAGS}\""
[0] https://github.com/rui314/mold/raw/main/docs/comparison.png [1] https://docs.google.com/spreadsheets/u/1/d/1LnyrUw79oY5DxBNfXGmlxr2-0n4V0AA06BzbO2cdhZg/htmlview#gid=0
Binaries can be checked for mold linking with readelf -p .comment <binary>
. Mold adds a line similar to
[ 0] mold 1.8.0 (a49a201695edd294ed4d97231c9dc5a994275dd2; compatible with GNU ld)
When this MR gets merged:
-
Add mold to [core] -
Add mold as dependency of devtools -
Add mold to group base-devel