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

2020-04-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In 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



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-04-13 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

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.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-04-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: beanz, mgorny.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78033

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  clang/tools/clang-shlib/libclang-cpp.exports


Index: clang/tools/clang-shlib/libclang-cpp.exports
===
--- /dev/null
+++ clang/tools/clang-shlib/libclang-cpp.exports
@@ -0,0 +1,2 @@
+_Z*5clang*
+clang_*
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -36,6 +36,8 @@
   set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
 endif()
 
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang-cpp.exports)
+
 add_clang_library(clang-cpp
   SHARED
   ${INSTALL_WITH_TOOLCHAIN}


Index: clang/tools/clang-shlib/libclang-cpp.exports
===
--- /dev/null
+++ clang/tools/clang-shlib/libclang-cpp.exports
@@ -0,0 +1,2 @@
+_Z*5clang*
+clang_*
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -36,6 +36,8 @@
   set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
 endif()
 
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang-cpp.exports)
+
 add_clang_library(clang-cpp
   SHARED
   ${INSTALL_WITH_TOOLCHAIN}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits