summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2020-02-04 13:06:54 -0800
committerHans Wennborg <hans@chromium.org>2020-02-10 13:34:01 +0100
commite2c0c70101ae4419917b232beae37b3d3a713b0c (patch)
tree45794a98973039b9fc7beb6bbd58ebd427234d47
parenta124bebdd5ff5cf49480956258c322ed9204943c (diff)
downloadbcm5719-llvm-e2c0c70101ae4419917b232beae37b3d3a713b0c.tar.gz
bcm5719-llvm-e2c0c70101ae4419917b232beae37b3d3a713b0c.zip
[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 (cherry picked from commit ebcf25ea8100fc9987fd1edd1975194addc2fc05)
-rw-r--r--clang/tools/clang-shlib/CMakeLists.txt17
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt
index a0fc8f6bfbd..07ee0f0a9a9 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)
OpenPOWER on IntegriCloud