[clang] ebcf25e - [cmake] Fix clang builds with BUILD_SHARED=ON and CLANG_LINK_CLANG_DYLIB=ON
Tom Stellard via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 4 14:16:36 PST 2020
Author: Tom Stellard
Date: 2020-02-04T14:15:16-08:00
New Revision: ebcf25ea8100fc9987fd1edd1975194addc2fc05
URL: https://github.com/llvm/llvm-project/commit/ebcf25ea8100fc9987fd1edd1975194addc2fc05
DIFF: https://github.com/llvm/llvm-project/commit/ebcf25ea8100fc9987fd1edd1975194addc2fc05.diff
LOG: [cmake] Fix clang builds with BUILD_SHARED=ON and CLANG_LINK_CLANG_DYLIB=ON
Summary:
We were linking all the clang objects and shared libraries into
libclang-cpp.so, which was causing the command line options to be
registered twice.
Reviewers: beanz, mgorny
Reviewed By: beanz, mgorny
Subscribers: merge_guards_bot, mgorny, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68520
Added:
Modified:
clang/tools/clang-shlib/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt
index a0fc8f6bfbde..07ee0f0a9a92 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -14,7 +14,22 @@ foreach (lib ${clang_libs})
list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
endif()
list(APPEND _DEPS $<TARGET_PROPERTY:${lib},INTERFACE_LINK_LIBRARIES>)
- list(APPEND _DEPS $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
+
+ # clang libraries are redundant since we are linking all the individual
+ # object files into libclang-cpp.so, so filter them out from _DEPS.
+ # This avoids problems with LLVM global data when building with
+ # BUILD_SHARED_LIBS=ON
+ # FIXME: We could use list(FILTER) with cmake >= 3.6
+ # FIXME: With cmake >= 3.15 we could use the generator expression
+ # $<FILTER:list,INCLUDE|EXCLUDE,regex>
+ get_target_property(interface ${lib} LINK_LIBRARIES)
+ if (interface)
+ foreach(lib ${interface})
+ if (NOT ${lib} MATCHES "^clang")
+ list(APPEND _DEPS ${lib})
+ endif()
+ endforeach()
+ endif()
endforeach ()
if (CLANG_LINK_CLANG_DYLIB)
More information about the cfe-commits
mailing list