Clang -fuse-ld support?

I am trying to cross-compile libc for RISC-V. During the compilation process, an error message shows up about the host compiler that it doesn’t support the option -fuse-ld=lld. However, it seems like clang really doesn’t support it and it’s not a matter of missing CMake compilation options.

The CMake options used are:

cmake -S llvm -B build -G Ninja
-DLLVM_ENABLE_PROJECTS=“clang;lld”
-DLLVM_ENABLE_RUNTIMES=“libc”
-DDEFAULT_SYSROOT=“/opt/riscv/riscv64-unknown-elf”
-DGCC_INSTALL_PREFIX=“/opt/riscv”
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=“ON”
-DLLVM_PARALLEL_LINK_JOBS=1
-DLLVM_TARGETS_TO_BUILD=“RISCV”
-DLLVM_DEFAULT_TARGET_TRIPLE=“riscv64-unknown-elf”

The error message is the following:

[961/985] Performing configure step for ‘runtimes’
– Could NOT find Terminfo (missing: Terminfo_LIBRARIES Terminfo_LINKABLE)
– Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version “1.2.11”)
– Could NOT find Terminfo (missing: Terminfo_LIBRARIES Terminfo_LINKABLE)
– Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version “1.2.11”)
CMake Error at /home/zach/CS-498/forked/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake:312 (message):
Host compiler does not support ‘-fuse-ld=lld’
Call Stack (most recent call first):
CMakeLists.txt:149 (include)

– Configuring incomplete, errors occurred!

Clang does support it and we’ve used it for RISC-V (including bare-metal) for multiple years. You’ll have to provide more information on what you’re doing and seeing in order to help figure out what you’re doing wrong.

It seems that you are cross-compiling LLVM’s libc using some compiler, and this compiler does not support -fuse-ld=lld . Please check your compiler. Is it some older version of GCC/CLANG ?