root
root copied to clipboard
`-Dbuiltin_llvm=OFF` conflicts with use of 3D graphics (via Mesa built with LLVM)
Check duplicate issues.
- [X] Checked for duplicates
Description
Reproducer fails with an error
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Comparing libCling.so from ROOT with and without external LLVM, it looks like there are many more symbols from llvm:: namespace re-exported (from LLVM static libs).
https://gist.github.com/veprbl/24958db267b8c00bcbf2213b642454fb
(outputs of nm --dynamic --with-symbol-versions prefix/lib/libCling.so | awk '{print $3;}'
)
A decent workaround given in https://discourse.llvm.org/t/can-something-be-done-with-the-inconsistency-in-registered-commandline-options-error/1720/9 to version all symbols in ROOT using a --version-script, but I'm wondering what is so special about the builtin_llvm=ON
build that prevents symbols from being exported and aliased.
Reproducer
echo 'TCanvas c; TGLSAViewer vv(&c);' | root
ROOT version
------------------------------------------------------------------
| Welcome to ROOT 6.30/04 https://root.cern |
| (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Jan 31 2024, 08:17:06 |
| From heads/master@tags/v6-30-04 |
| With g++ (GCC) 13.2.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Installation method
nix/nixpkgs
Operating system
Linux
Additional context
cc @stephanlachnit @hahnjo
With builtin_llvm=ON
, all of our build system magic in interpreter/CMakeLists.txt
applies, in particular
https://github.com/root-project/root/blob/779ecb965abcb0658fc7a3524e2d1448a2504bff/interpreter/CMakeLists.txt#L134-L148
We do this because ROOT requires an exact version of LLVM and we want to avoid at all costs that its symbols interfere with another LLVM library that lives in the same process, with potentially a different version...
See also https://github.com/root-project/root/issues/12156
But interestingly while I don't get that particular error, there are indeed still some LLVM symbols exported:
nm --dynamic /path/to/libCling.so | awk '{print $3;}' | c++filt | grep llvm
Can we use the -exclude-libs option in the link command for libCling?
Can we use the -exclude-libs option in the link command for libCling?
Any suggestion on how we can implement this in CMake? Adding --exclude-libs=ALL
fails at runtime:
IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime8internal15setValueNoAllocEPvS2_S2_cPKv' unresolved while linking [cling interface function]!
You probably want to collect all transitive dependencies like the way we do here:
https://github.com/root-project/root/blob/2a6bdc7029881ff2d2a90e65ebbcb3017e50a613/interpreter/CMakeLists.txt#L535-L566
Everything that starts with libLLVM
or libclang
can be filtered out in the --exclude-libs
flags..