From: Tom Stellard Date: Wed, 22 Jan 2020 22:06:56 +0000 (+0000) Subject: [cmake] Fix clang builds with BUILD_SHARED=ON and CLANG_LINK_CLANG_DYLIB=ON X-Git-Tag: llvmorg-12-init~17142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df839cfda09dbadc26b8be635f27da75f1f27190;p=platform%2Fupstream%2Fllvm.git [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: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68520 --- diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index a0fc8f6..16fc8a0c 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -14,9 +14,17 @@ foreach (lib ${clang_libs}) list(APPEND _OBJECTS $) endif() list(APPEND _DEPS $) - list(APPEND _DEPS $) + get_target_property(interface ${lib} LINK_LIBRARIES) + if (interface) + list(APPEND _DEPS ${interface}) + endif() endforeach () +# 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 +list(FILTER _DEPS EXCLUDE REGEX "^clang") if (CLANG_LINK_CLANG_DYLIB) set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN) endif()