I don’t like to be critical, but I’m having a hard time building LLVM with openmp. I find the documentation to be inconsistent and vague. I’m no fan of autotools but building GCC from source (other than the poorly documented script to get fetch the dependent libs) is really a no-brainer.
I’m on a Rocky 8.9 amd64 machine, building with GCC 14.2.0 that I built myself a couple of days ago.
I don’t have much problem building llvm and clang with the following script
#!/usr/bin/env ksh
export CC=$(which gcc)
export CXX=$(which g++)
cmake
-D CMAKE_BUILD_TYPE=Release
-D LLVM_ENABLE_RTTI=ON
-D LLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;lld;lldb;polly;pstl”
-D CMAKE_INSTALL_PREFIX=${NBK}/foss/clang
-D CMAKE_CXX_LINK_FLAGS=“-L/home/pafloyd/tools/gcc/lib64 -Wl,-rpath,/home/pafloyd/tools/gcc/lib64”
-B build
-S llvm
make -C build -j 16
(it’s a mystery as to why CMake defaults to overriding the PATH and using /usr/bin instead)
The pain really starts when I try to build runtimes. As far as I can tell the runtimes need to be built with clang not GCC (at least, I get a lot of errors trying to build compiler-rt with GCC).
The following script seems to work
#!/usr/bin/env ksh
export CC=${NBK}/foss/clang/bin/clang
export CXX=${NBK}/foss/clang/bin/clang++
#export CC=$(which gcc)
#export CXX=$(which g++)
cmake
-D CMAKE_BUILD_TYPE=Release
-D LLVM_ENABLE_RTTI=ON
-D CMAKE_INSTALL_PREFIX=${NBK}/foss/clang
-D LLVM_ENABLE_RUNTIMES=“libcxx;libcxxabi;libunwind;compiler-rt”
-D LLVM_DIR=${NBK}/foss/llvm-project/llvm
-B build_runtimes
-S runtimes
make -C build_runtimes -j 16
When I add “openmp” to the LLVM_ENABLE_RUNTIMES I get errors
– Cannot find ‘FileCheck’.
CMake Warning at /ams/nobackup/pafloyd/foss/llvm-project/openmp/cmake/OpenMPTesting.cmake:66 (message):
The check targets will not be available!
Call Stack (most recent call first):
/ams/nobackup/pafloyd/foss/llvm-project/openmp/CMakeLists.txt:87 (include)
CMake Error at /ams/nobackup/pafloyd/foss/llvm-project/cmake/Modules/GetClangResourceDir.cmake:16 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
Call Stack (most recent call first):
/ams/nobackup/pafloyd/foss/llvm-project/openmp/CMakeLists.txt:113 (get_clang_resource_dir)
There’s a warning about LTO and then
[100%] Linking CXX executable boo
/home/pafloyd/tools/bin/cmake -E cmake_link_script
CMakeFiles/boo.dir/link.txt --verbose=1
/ams/nobackup/pafloyd/foss/clang/bin/clang++ -flto=thin
CMakeFiles/boo.dir/main.cpp.o -o boo libfoo.a
/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/…/…/…/…/bin/ld:
/ams/nobackup/pafloyd/foss/clang/bin/…/lib/LLVMgold.so: error loading
plugin: /ams/nobackup/pafloyd/foss/clang/bin/…/lib/LLVMgold.so: cannot
open shared object file: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see
invocation)
make[2]: *** [CMakeFiles/boo.dir/build.make:101: boo] Error 1
make[2]: Leaving directory
‘/ams/nobackup/pafloyd/foss/llvm-project/build_runtimes/openmp/libomptarget/CMakeFiles/_CMakeLTOTest-CXX/bin’
make[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/boo.dir/all] Error 2
make[1]: Leaving directory
‘/ams/nobackup/pafloyd/foss/llvm-project/build_runtimes/openmp/libomptarget/CMakeFiles/_CMakeLTOTest-CXX/bin’
make: *** [Makefile:94: all] Error 2
Why is it complaining about LTO and gold? Surely the defaults for both of those is off.