[PATCH] D78033: [cmake] Restrict symbols exported from libclang-cpp

Pirama Arumuga Nainar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 13 23:57:19 PDT 2020


pirama added a comment.

In D78033#1978612 <https://reviews.llvm.org/D78033#1978612>, @beanz wrote:

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

1. We could build `libLLVM` by default, but don't install it unless requested.
2. 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()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78033/new/

https://reviews.llvm.org/D78033





More information about the cfe-commits mailing list