Switch clang build to LLVM's lld linker
Posted: Wed Mar 25, 2026 10:32 pm
I recall that a long while ago I tested using lld with the Windows build and it was noticeably faster at linking producing a working executable. I didn't suggest switching at the time because when I tested on Linux, the Oolite binary segfaulted. Now that I've established that the Linux problem was down to the SpiderMonkey static library being compiled on very old gcc, I think it would be safe to switch for clang builds on both platforms. The Windows clang build always had a recently compiled SpiderMonkey and now the Linux build does too (built on Ubuntu 22 to retain compatibility for older systems).
It seems to make logical sense to use the LLVM linker with the LLVM compiler especially for Obj-C. lld is said to be between 2 and 10 times faster than bfd although it is less noticeable on my machine with Linux than with Windows from what I remember. lld is said to use less RAM. On Linux, the lld linked binary for deployment is slightly smaller than the bfd linked one. Not sure if that's also true for Windows. A big help is that lld's error messages are easier to understand than bfd's.
Setting the linker is done like this:
Replace lld with bfd for the default GNU linker.
It seems to make logical sense to use the LLVM linker with the LLVM compiler especially for Obj-C. lld is said to be between 2 and 10 times faster than bfd although it is less noticeable on my machine with Linux than with Windows from what I remember. lld is said to use less RAM. On Linux, the lld linked binary for deployment is slightly smaller than the bfd linked one. Not sure if that's also true for Windows. A big help is that lld's error messages are easier to understand than bfd's.
Setting the linker is done like this:
Code: Select all
ADDITIONAL_LDFLAGS += -fuse-ld=lld