Unable to build llvmlite==0.45.0rc2 on RHEL 9.6 with GCC 11 or clang 20
Reporting a bug
- [X] I have tried using the latest released version of llvmlite (most recent is visible in the change log (https://github.com/numba/llvmlite/blob/main/CHANGE_LOG).
- [ ] I have included a self contained code sample to reproduce the problem. i.e. it's possible to run as 'python bug.py'.
@stuartarchibald pinged me on #1234 to test the new build system. I'm currently unable to build the latest rc on RHEL 9.6 with our internal build of llvm20 and either system GCC 11 or clang from LLVM 20.
environment
RHEL 9.6 x86_64. The llvm20 build is an internal backport of llvm20 from RHEL 9.7 dev.
$ rpm -qa gcc llvm20 clang20 python3.12 redhat-release
redhat-release-9.6-0.1.el9.x86_64
python3.12-3.12.9-1.el9_6.2.x86_64
gcc-11.5.0-5.el9_5.x86_64
llvm20-20.1.3-2.1.el9ai.x86_64
clang20-20.1.3-2.1.el9ai.x86_64
My build env has the recommended CMAKE prefix to pick up llvm20:
$ export CMAKE_PREFIX_PATH=/usr/lib64/llvm20/lib/cmake
Tests builds are with llvmlite-0.45.0rc2.tar.gz
build with GCC 11
$ python3.12 -m build -v -w .
...
* Getting build dependencies for wheel...
running egg_info
writing llvmlite.egg-info/PKG-INFO
writing dependency_links to llvmlite.egg-info/dependency_links.txt
writing top-level names to llvmlite.egg-info/top_level.txt
reading manifest file 'llvmlite.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'llvmlite.egg-info/SOURCES.txt'
* Building wheel...
running bdist_wheel
/tmp/build-env-7c6h0dqh/bin/python /work/llvmlite-0.45.0rc2/ffi/build.py
-- Found LLVM 20.1.3
-- Using LLVMConfig.cmake in: /usr/lib64/llvm20/lib/cmake/llvm
-- SVML not found
-- LLVMLITE_USE_RTTI not set, inheriting RTTI flags from LLVM as: ON.
-- -fno-rtti is not in CXXFLAGS, nothing to do.
-- Testing for LLVM component IntelJITEvents
-- LLVM_COMPONENTS: mcjit;orcjit;OrcDebugging;AsmPrinter;AllTargetsCodeGens;AllTargetsAsmParsers
-- LLVMLITE_SHARED is OFF, using static linkage against LLVM
-- LLVM assertions state detected as 'off'
-- LLVM target link libraries: LLVMMCJIT;LLVMOrcJIT;LLVMOrcDebugging;LLVMAsmPrinter;LLVMX86CodeGen;LLVMAMDGPUCodeGen;LLVMPowerPCCodeGen;LLVMNVPTXCodeGen;LLVMSystemZCodeGen;LLVMAArch64CodeGen;LLVMBPFCodeGen;LLVMWebAssemblyCodeGen;LLVMX86AsmParser;LLVMAMDGPUAsmParser;LLVMPowerPCAsmParser;LLVMSystemZAsmParser;LLVMAArch64AsmParser;LLVMBPFAsmParser;LLVMWebAssemblyAsmParser
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /work/llvmlite-0.45.0rc2/ffi/build
[ 5%] Linking CXX shared library libllvmlite.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o): in function `llvm::orc::FailedToMaterialize::FailedToMaterialize(std::shared_ptr<llvm::orc::SymbolStringPool>, std::shared_ptr<llvm::DenseMap<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> >, llvm::DenseMapInfo<llvm::orc::JITDylib*, void>, llvm::detail::DenseMapPair<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> > > > >)':
(.text+0x96a): undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o): in function `llvm::orc::FailedToMaterialize::~FailedToMaterialize()':
(.text+0xb38): undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o): in function `llvm::orc::FailedToMaterialize::log(llvm::raw_ostream&) const':
(.text+0xbe9): undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o): in function `llvm::orc::AsynchronousSymbolQuery::handleComplete(llvm::orc::ExecutionSession&)':
(.text+0x1f63): undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o): in function `llvm::orc::ReExportsMaterializationUnit::materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >)':
(.text+0x429f): undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
/usr/bin/ld: /usr/lib64/llvm20/lib/libLLVMOrcJIT.a(Core.cpp.o):(.text+0x6bb9): more undefined references to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)' follow
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/llvmlite.dir/build.make:451: libllvmlite.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:272: CMakeFiles/llvmlite.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
clang 20
$ rm -rf llvmlite-0.45.0rc2
$ tar xf llvmlite-0.45.0rc2.tar.gz
$ cd llvmlite-0.45.0rc2
$ CC=/usr/lib64/llvm20/bin/clang CXX=/usr/lib64/llvm20/bin/clang++ python3.12 -m build -v -w .
...
Running: cmake -G Unix Makefiles /work/llvmlite-0.45.0rc2/ffi
-- The C compiler identification is Clang 20.1.3
-- The CXX compiler identification is Clang 20.1.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/llvm20/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/llvm20/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_FFI_CALL
-- Performing Test HAVE_FFI_CALL - Success
-- Found FFI: /usr/lib64/libffi.so
-- Looking for histedit.h
-- Looking for histedit.h - found
-- Found LibEdit: /usr/include (found version "2.11")
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11")
-- Found zstd: /usr/lib64/libzstd.so
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.13")
-- Found LLVM 20.1.3
-- Using LLVMConfig.cmake in: /usr/lib64/llvm20/lib/cmake/llvm
-- Looking for include file llvm/IR/SVML.inc
-- Looking for include file llvm/IR/SVML.inc - not found
-- SVML not found
-- Performing Test HAVE_FLTO
-- Performing Test HAVE_FLTO - Failed
CMake Error at CMakeLists.txt:103 (message):
-flto flag is not supported by the compiler
-- Configuring incomplete, errors occurred!
-
kind: "try_compile-v1"
backtrace:
- "/usr/share/cmake/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)"
- "/usr/share/cmake/Modules/Internal/CheckCompilerFlag.cmake:18 (cmake_check_source_compiles)"
- "/usr/share/cmake/Modules/CheckCXXCompilerFlag.cmake:34 (cmake_check_compiler_flag)"
- "CMakeLists.txt:101 (check_cxx_compiler_flag)"
checks:
- "Performing Test HAVE_FLTO"
directories:
source: "/work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7"
binary: "/work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7"
cmakeVariables:
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "/usr/bin/clang-scan-deps-20"
CMAKE_CXX_FLAGS: "-fPIC"
CMAKE_CXX_FLAGS_DEBUG: "-g"
CMAKE_EXE_LINKER_FLAGS: ""
CMAKE_MODULE_PATH: "/usr/lib64/llvm20/lib/cmake/llvm"
buildResult:
variable: "HAVE_FLTO"
cached: true
stdout: |
Change Dir: '/work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7'
Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_2aa7d/fast
/usr/bin/gmake -f CMakeFiles/cmTC_2aa7d.dir/build.make CMakeFiles/cmTC_2aa7d.dir/build
gmake[1]: Entering directory '/work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7'
Building CXX object CMakeFiles/cmTC_2aa7d.dir/src.cxx.o
/usr/bin/ccache /usr/lib64/llvm20/bin/clang++ -DHAVE_FLTO -I/usr/lib64/llvm20/include -fPIC -std=gnu++17 -flto -MD -MT CMakeFiles/cmTC_2aa7d.dir/src.cxx.o -MF CMakeFiles/cmTC_2aa7d.dir/src.cxx.o.d -o CMakeFiles/cmTC_2aa7d.dir/src.cxx.o -c /work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7/src.cxx
Linking CXX executable cmTC_2aa7d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2aa7d.dir/link.txt --verbose=1
/usr/lib64/llvm20/bin/clang++ -fPIC CMakeFiles/cmTC_2aa7d.dir/src.cxx.o -o cmTC_2aa7d
CMakeFiles/cmTC_2aa7d.dir/src.cxx.o: file not recognized: file format not recognized
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_2aa7d.dir/build.make:100: cmTC_2aa7d] Error 1
gmake[1]: Leaving directory '/work/llvmlite-0.45.0rc2/ffi/build/CMakeFiles/CMakeScratch/TryCompile-tgDPE7'
gmake: *** [Makefile:127: cmTC_2aa7d/fast] Error 2
exitCode: 2
PS: undefined references to std::__glibcxx_assert_fail... is a known bug in GCC and libstd++. We have had the same issue with other Python packages that use libraries from LLVM, e.g. symengine. The problem goes away when compiling with clang instead of GCC.
The detection code for HAVE_FLTO is broken for clang. clang -flto generated LLVM IR bitcode instead of native ELF objects. The intermediate representation code cannot be linked directly. It has to go through an additional step.
@tiran thank you for the report, I've marked this as needtriage for now. What is your hunch here, is this something that must be fixed within the llvmlite tree? Or is this is something broken in Fedora?
The package builds fine with Fedora 42's GCC 15.2 and LLVM 20. It does not build with old GCC 11 from RHEL 9.
Let's treat the Clang build issue as a separate problem. I'm going to open a new bug.
I have created #1294 for the Clang HAVE_FLTO issue. I do not need a fix for the std::__glibcxx_assert_fail issue if you address the Clang build issue. #1293 just applies to users with old GCC version, #1294 affects everybody that use Clang instead of GCC as C/C++ compiler.
@tiran just following up here. With the merge of https://github.com/numba/llvmlite/pull/1334 -- can this now be closed?