Building CLANG from Source with GCC and Gold

Hello all,

I am trying to do some work on clang on a Linux system, and the default linker, ld is requiring far too much memory to link the program. I want to try using Gold or perhaps LLD, but I have been unable to configure the CMake files properly to change the Linker.

I have attempted to edit the CMake variables like so:
cmake -DCMAKE_LINKER=/usr/bin/ld.gold -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -G "Unix Makefiles" ../llvm
``


but was ultimately unsuccessful. I get the error:
/usr/bin/ld.gold: -Werror=date-time: unknown option

so I removed the <FLAGS> option to bypass the this problem, which results in the error:
/usr/bin/ld.gold: -Wl,-allow-shlib-undefined: unknown option

Has anyone been able to build CLANG with a non-default linker on Linux? How did you configure your CMake files to do so? 

Thanks

Hello all,

I am trying to do some work on clang on a Linux system, and the default
linker, ld is requiring far too much memory to link the program. I want to
try using Gold or perhaps LLD, but I have been unable to configure the
CMake files properly to change the Linker.

I have attempted to edit the CMake variables like so:
cmake -DCMAKE_LINKER=/usr/bin/ld.gold -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER>
<FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET>
<LINK_LIBRARIES>" -G "Unix Makefiles" ../llvm

but was ultimately unsuccessful. I get the error:
/usr/bin/ld.gold: -Werror=date-time: unknown option

so I removed the <FLAGS> option to bypass the this problem, which results in the error:
/usr/bin/ld.gold: -Wl,-allow-shlib-undefined: unknown option

Has anyone been able to build CLANG with a non-default linker on Linux? How did you configure your CMake files to do so?

I use -DLLVM_ENABLE_LLD=TRUE to link with lld.

I used to use gold; I think I used something like -DLLVM_USE_LINKER=ld.gold