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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Fangrui Song via cfe-dev
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
[hidden email]
http://milianw.de
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (849 bytes) Download Attachment