root icon indicating copy to clipboard operation
root copied to clipboard

`-Dbuiltin_llvm=OFF` conflicts with use of 3D graphics (via Mesa built with LLVM)

Open veprbl opened this issue 1 year ago • 6 comments

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

veprbl avatar Feb 20 '24 18:02 veprbl

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...

hahnjo avatar Feb 21 '24 07:02 hahnjo

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

stephanlachnit avatar Feb 21 '24 08:02 stephanlachnit

Can we use the -exclude-libs option in the link command for libCling?

vgvassilev avatar Feb 24 '24 21:02 vgvassilev

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]!

veprbl avatar Feb 29 '24 21:02 veprbl

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..

vgvassilev avatar Mar 02 '24 19:03 vgvassilev