I don’t have any problems building LLVM on Rocky 8.10
I would also like to be able to build it on CentOS 7.9. I’d like to bootstrap it with GCC 13.2 built in-house. It’s a slightly old LLVM version that I’m trying to build, llvmorg-19.1.4.
The working script that I use on Rocky 8.10 is
export GCC_HOME=/path/to/gcc-13.2.0
export PATH=${GCC_HOME}/bin:${PATH}
export CC=$(which gcc)
export CXX=$(which g++)
rm -rf build_test/*
cd build_test
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D LLVM_ENABLE_RTTI=ON \
-D CMAKE_INSTALL_PREFIX=${HOME}/foss/clang \
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;polly;pstl" \
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt;openmp" \
-D CMAKE_CXX_LINK_FLAGS="-L${GCC_HOME}/lib64 -Wl,-rpath,${GCC_HOME}/lib64" \
../llvm
make -j 32
The reason that works on Rocky 8.10 but not CentOS 7.9 is the system headers. I’ve told CMake to link with the GCC libstdc++ that I’m building with but not told it anything about headers. Rocky 8.10 has GCC 8.5 as its system compiler, CentOS 7.9 has GCC 4.8.5.
So I added -D CMAKE_CXX_FLAGS=“-nostdinc++ -isystem${GCC_HOME}/include/c++/13.2.0 -isystem${GCC_HOME}/include/ -isystem${GCC_HOME}/include/c++/13.2.0/x86_64-pc-linux-gnu”
That still works OK on Rocky 8.9 but on CentOS 7.9 I get
[ 81%] Building CXX object compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profile_collector.cpp.o
cd /bla/llvm-project/build_c79/runtimes/runtimes-bins/compiler-rt/lib/xray && /bla/llvm-project/build_c79/./bin/clang++ --target=x86_64-unknown-linux-gnu -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -DXRAY_HAS_EXCEPTIONS=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/wv/pafloyd/foss/llvm-project/compiler-rt/lib/xray/.. -I/wv/pafloyd/foss/llvm-project/compiler-rt/lib/xray/../../include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern -Wno-format -fno-rtti -MD -MT compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profile_collector.cpp.o -MF CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profile_collector.cpp.o.d -o CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profile_collector.cpp.o -c /bla/llvm-project/compiler-rt/lib/xray/xray_profile_collector.cpp
In file included from /bla/llvm-project/compiler-rt/lib/xray/xray_profile_collector.cpp:14:
In file included from /bla/llvm-project/compiler-rt/lib/xray/xray_profile_collector.h:20:
/bla/llvm-project/compiler-rt/lib/xray/xray_function_call_trie.h:142:37: error: no type named ‘byte’ in namespace ‘std’
142 | alignas(NodeAllocatorType) std::byte
Any ideas?