libc project can't be built together with other projects

If I add, for example, openmp to the list of projects, CMake errors out:

[…]
– Performing Test HAVE_POSIX_REGEX
– Performing Test HAVE_POSIX_REGEX – success
– Performing Test HAVE_STEADY_CLOCK
– Performing Test HAVE_STEADY_CLOCK
– Performing Test HAVE_STEADY_CLOCK – success
– Configuring done
CMake Error at cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-all” does not exist.
Call Stack (most recent call first):
CMakeLists.txt:987 (add_lit_target)

CMake Error at cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target “check-all” does
not exist.
Call Stack (most recent call first):
CMakeLists.txt:987 (add_lit_target)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-openmp” does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:190 (add_openmp_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/CMakeLists.txt:95 (construct_check_openmp_target)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target “check-openmp”
does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:190 (add_openmp_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/CMakeLists.txt:95 (construct_check_openmp_target)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-ompt” does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/runtime/test/CMakeLists.txt:36 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target “check-ompt” does
not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/runtime/test/CMakeLists.txt:36 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-libomp” does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/runtime/test/CMakeLists.txt:33 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target “check-libomp”
does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/runtime/test/CMakeLists.txt:33 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-libomptarget” does not
exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/libomptarget/test/CMakeLists.txt:15 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target
“check-libomptarget” does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/libomptarget/test/CMakeLists.txt:15 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang” of target “check-libarcher” does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/tools/archer/tests/CMakeLists.txt:29 (add_openmp_testsuite)

CMake Error at /fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1456 (add_dependencies):
The dependency target “clang-resource-headers” of target “check-libarcher”
does not exist.
Call Stack (most recent call first):
/fefs/home/r1050/projects/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1477 (add_lit_target)
/fefs/home/r1050/projects/llvm-project/openmp/cmake/OpenMPTesting.cmake:175 (add_lit_testsuite)
/fefs/home/r1050/projects/llvm-project/openmp/tools/archer/tests/CMakeLists.txt:29 (add_openmp_testsuite)

I normally build clang and LLD along with libc and have not seen any
problems. I added openmp to that list now and could build without any
problems. My CMake line was:

$> cmake ../llvm -G Ninja
-DLLVM_ENABLE_PROJECTS="libc;clang;lld;openmp"
-DLLVM_USE_SANITIZER=Address

Can you share the cmake command line that is causing problems for you?

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/opt/llvm-libc/${now} -DCMAKE_C_COMPILER=armclang -DCMAKE_CXX_COMPILER=armclang++ -DLLVM_ENABLE_PROJECTS=“libc;openmp” -DLLVM_TARGETS_TO_BUILD=“AArch64;NVPTX” ~/projects/llvm-project/llvm

It seems to me that openmp requires clang to be built along with it.
For example, remove libc from the list and you will be able to
reproduce the same errors you are seeing. Add clang and they will go
away.

Shouldn’t a project be independent of other projects?

Shouldn't a project be independent of other projects?

May be there is, but I am not aware of any policy around this. You
should ask the openmp people about why they require clang.