I'm writing a custom pass for LLVM/Clang, and recompiling tends to take a while and use a lot of memory. I've heard that the gold linker (1) takes less time and (2) uses less memory than the standard ld linker.
Is there a way to pass flags into the LLVM/Clang build process and change to the gold linker? As per this answer, I've been attempting to use an override file, but I don't seem to be having a lot of success.
I'll also note that I'm compiling the latest Clang/LLVM build (4.0) using Clang 3.9; I don't mind switching back to GCC if necessary but would rather avoid it.
Post-4.0 (after commit rL292047), you should set LLVM_USE_LINKER
to gold
like so:
cmake ... -DLLVM_USE_LINKER=gold ...
Refer to http://llvm.org/docs/CMake.html#llvm-specific-variables
While you can still use gold
, these days (October 2021) you should probably use lld
if it's present in your host toolchain. If your host toolchain is a clang+llvm distribution from llvm.org, it probably will. If your host toolchain is from a linux distribution's package manager, it will likely be available but installed as a separate independent package.
cmake ... -DLLVM_ENABLE_LLD=ON ...