This is because the host compiler either does not understand the option, or lld (llvm’s linker) is not installed. The name of that compiler will be printed somewhere at the start of the cmake output.
Assuming that is some gcc or clang, it’s unlikely to not handle the option at all. More likely that lld is not installed.
So you can either remove the cmake option that enabled -fuse-ld=, which is usually LLVM_USE_LINKER or ENABLE_LLD. Though I don’t see either in your cmake options. Perhaps your compiler already defaults to using lld but lld is not installed?
To install it, you can get it from apt if you are on something like Ubuntu. A quick way to test this is working is to compile a simple hello world with the -fuse-ld= option.
$ sudo apt install lld
<...>
The following additional packages will be installed:
lld-10
The following NEW packages will be installed:
lld lld-10
<...>
$ gcc /tmp/test.c -fuse-ld=lld -o /dev/null
If you’re on some other Linux or OS, we can figure out the equivalent.
Much more likely, the instruction page link in the original post has:
# Using clang and lld speeds up the build, we recomment adding:
# -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON
This is a suggestion and commented out, but if they tried it and then re-invoked cmake without it but without wiping out the build directory, it can lead to the reported issue.
For people who run into this topic. I just fixed this issue on a Mac by switching from the built-in Apple Clang version 15 (with the associated lld etc) to Homebrew Clang version 17. So maybe updating the clang/clang++/lld versions may help.
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - broken
CMake Error at /usr/local/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/usr/local/opt/llvm/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/Users/chendongsheng/github/cds_llvm/code/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-Jj3QlO'