[cfe-dev] Mixing different libLLVM versions in one application? (Linux & AMD GPU / radeonsi)

Milian Wolff via cfe-dev cfe-dev at lists.llvm.org
Mon May 18 01:49:01 PDT 2020


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:
https://github.com/JuliaGPU/OpenCL.jl/issues/125
https://github.com/hughperkins/tf-coriander/issues/69

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 

```
CLANG_LINK_CLANG_DYLIB:BOOL=ON
LLVM_BUILD_LLVM_DYLIB:BOOL=ON
LLVM_LINK_LLVM_DYLIB:BOOL=ON
BUILD_SHARED_LIBS:BOOL=OFF
```

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
llvm::cl::GenericOptionValue
```

Cheers
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200518/ce20e875/attachment.sig>


More information about the cfe-dev mailing list