In libclang-cpp, export only symbols from the clang namespace or clang_*
(functions for the C interface). This fixes the use case where a tool
depends on both libclang-cpp and libLLVM. Without this change,
command-line registries from libLLVMSupport are exported by libclang-cpp
and gets deduped with symbols of the same name from libLLVM . But, the
arguments get registered separately from both the libraries during
startup, resulting in an error.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think this has some unintended consequences. If your tool wants to use libLLVM and libClang you really need libClang to be linked against libLLVM, otherwise you're actually just hiding the problem.
I wanted to avoid this since libLLVM is an optional target but libclang-cpp is built by default. Maybe I didn't think through all options in this regard.
- We could build libLLVM by default, but don't install it unless requested.
- Or link libclang-cpp against libLLVM iff the latter is built.
Either option would require a CMake change that I am not sure how to make. We would need to remove LLVM static libraries from libclang-cpp's link command but I cannot figure out how to accomplish this. They are getting included transitively via CMake's dependency graph.
Another option is to make libclang-cpp a superset of Clang and LLVM libraries. This would however require using --whole-archive similar to libLLVM.so.
Do you have any preferred solution and pointers on how to filter out some dependencies in CMake? One hacky way could be to add a special-case in AddLLVM.cmake and dedup right before target_link_libraries().