mold
-
requires
tbb
to build -
uses 12 GB when building and basically freezes the build process (mold should speed up linking times and reduce the overall bootstrap time but building mold takes up all the saved time and more…)
-
randomly segfaults producing undebuggable errors:
-
Check if it can link the kernel now
-
LTO works now
-
It does not add
libgcc
to all binaries -
Don’t forget to include
mold
in your compiler’s custom search directory
Notes
- You can pass linker flags like this by using a single
-Wl
, checkoutput.txt
:
- MOLD flags:
- BFD flags:
Custom GCC Search Directory
- Custom built GCCs have custom search directories. Even though I have version
12.2.0
, adding-fuse-ld=mold
was not sufficient for my customgcc
to find the host’smold
(provided by distribution’s package manager) or my custommold
(as I was getting the following errorcollect2: fatal error: cannot find 'ld' mold
, which is why I had to add-B/path/to/directory/where/custom/mold/is
to myCFLAGS
along with-fuse-ld=mold
to get it working. - Most packages linked just fine, until I stumbled upon packages which used
autoreconf
andlibtool
to create.la
files. Apparentlylibtool
likes to strip flags when linking. This was troublesome because I am passing-B/path/to/directory/where/custom/mold/is
in myCFLAGS
and it was being removed, so my customgcc
could no longer findmold
, giving the same error as above. - You can workaround this by modifying
GCC_EXEC_PREFIX
which is not desirable for many reasons. - The solution I found was to provide a symbolic link to
mold
in the search directories of the custom builtgcc
(which can be listed by runninggcc -print-search-dirs
). - The symbolic link was installed in
/custom/toolchain/tuple/bin
wherebinutils
already keeps its hardlinks to../../bin
includingld.bfd
, which is why I issued the commandln -fs ../../bin/mold /custom/toolchain/tuple/bin/ld.mold
.