Is it possible to compile & link Clang/LLVM using

2019-07-04 16:55发布

问题:

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.

回答1:

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