Mixing different libLLVM versions in one application? (Linux & AMD GPU / radeonsi)

Hey all,

probably to noones surprise, strange issues occur when one links different
libLLVM versions into a single application:

: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
# return code 1

See also:

In my case, I'm trying to run KDevelop which links against libclang (the C
library). This works fine as long as I use my system libraries, but as soon as
I use a selfcompiled libclang, I run into the above error. The reason is that
I'm using an AMD GPU and libradeonsi links against libLLVM:

ldd /usr/lib/dri/radeonsi_dri.so | grep LLVM
        libLLVM-10.so => /usr/lib/libLLVM-10.so (0x00007f53153af000)

This essentially binds every GPU-using application to this version of LLVM.

Is there any way to workaround this situation, maybe by enabling a namespaced
or versioned build of LLVM/clang?

For now, I'm going to stick to the 10.x branch and compile with


This at least gives me a library I can use as a drop-in replacement for my
system libLLVM. I first tried with `BUILD_SHARED_LIBS=ON` for build-speed
reasons, but that gave me:

$ CUSTOM_LLVM_PREFIX=/home/milian/projects/compiled/llvm
$ LD_LIBRARY_PATH=$CUSTOM_LLVM_PREFIX/lib nm /usr/lib/dri/radeonsi_dri.so
nm: /usr/bin/../lib/bfd-plugins/LLVMgold.so: undefined symbol: 
_ZTIN4llvm2cl18GenericOptionValueE, version LLVM_10
$ c++filt _ZTIN4llvm2cl18GenericOptionValueE