summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2016-10-18 10:26:57 +0000
committerPavel Labath <labath@google.com>2016-10-18 10:26:57 +0000
commit01a955a341a7518bfbcba56f97ecf232b09fd7f6 (patch)
tree61124172b0cd54a8f810c72decaf61529a65f4d0
parentecf79300dd78b561f138c5d543b6d27d9ab766de (diff)
downloadbcm5719-llvm-01a955a341a7518bfbcba56f97ecf232b09fd7f6.tar.gz
bcm5719-llvm-01a955a341a7518bfbcba56f97ecf232b09fd7f6.zip
[cmake] Make dependencies of lldb libraries private, take 2
Summary: The dependencies of our libraries (only liblldb, really) we marked as public, which caused all their dependencies to be repeated when linking any executables to them. This is a problem because then all the .a files could end up being linked twice, once to liblldb and once again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out, our build actually depends on this behavior: - on windows, lldb does not have getopt, so it pulls it from inside liblldb, even though getopt is not a part of the exported interface of liblldb (maybe some of the bsd variants have this problem as well) - lldb-mi uses llvm, which again is not exported by liblldb This change does not actually fix these problems (that is going to be a hard one), but it does make them explicit by moving this magic from add_lldb_library to the places the executable targets are defined. That way, I can link the additional .a files only on targets that really need it, and the other targets can build cleanly and make sure we don't regress further. It also fixes the LLVM_LINK_LLVM_DYLIB build on linux. Reviewers: zturner, beanz Subscribers: ki.stfu, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D25680 llvm-svn: 284466
-rw-r--r--lldb/cmake/modules/AddLLDB.cmake21
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt2
-rw-r--r--lldb/tools/argdumper/CMakeLists.txt10
-rw-r--r--lldb/tools/driver/CMakeLists.txt13
-rw-r--r--lldb/tools/lldb-mi/CMakeLists.txt2
5 files changed, 33 insertions, 15 deletions
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 6e9f4e13c5f..af678670629 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -4,7 +4,7 @@ function(lldb_link_common_libs name targetkind)
endif()
if(${targetkind} MATCHES "SHARED")
- set(LINK_KEYWORD PUBLIC)
+ set(LINK_KEYWORD PRIVATE)
endif()
if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
@@ -56,19 +56,20 @@ macro(add_lldb_library name)
if (PARAM_OBJECT)
add_library(${name} ${libkind} ${srcs})
else()
- llvm_add_library(${name} ${libkind} DISABLE_LLVM_LINK_LLVM_DYLIB ${srcs})
-
- lldb_link_common_libs(${name} "${libkind}")
-
if (PARAM_SHARED)
if (LLDB_LINKER_SUPPORTS_GROUPS)
- target_link_libraries(${name} PUBLIC
- -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
+ llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
+ -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group
+ -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group
+ )
else()
- target_link_libraries(${name} PUBLIC ${CLANG_USED_LIBS})
+ llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
+ ${LLDB_USED_LIBS} ${CLANG_USED_LIBS}
+ )
endif()
+ else()
+ llvm_add_library(${name} ${libking} ${srcs})
endif()
- llvm_config(${name} ${LLVM_LINK_COMPONENTS} ${LLVM_PRIVATE_LINK_COMPONENTS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
if (PARAM_SHARED)
@@ -101,7 +102,7 @@ endmacro(add_lldb_library)
macro(add_lldb_executable name)
cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK" "" "" ${ARGN})
- add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARG_UNPARSED_ARGUMENTS})
+ add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
set_target_properties(${name} PROPERTIES
FOLDER "lldb executables")
diff --git a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
index 79d8a25d697..55aaadaf191 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_PRIVATE_LINK_COMPONENTS
+set(LLVM_LINK_COMPONENTS
DebugInfoPDB)
add_lldb_library(lldbPluginSymbolFilePDB
diff --git a/lldb/tools/argdumper/CMakeLists.txt b/lldb/tools/argdumper/CMakeLists.txt
index 87ea89c8f1b..ce595721eef 100644
--- a/lldb/tools/argdumper/CMakeLists.txt
+++ b/lldb/tools/argdumper/CMakeLists.txt
@@ -1,8 +1,16 @@
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
add_lldb_executable(lldb-argdumper INCLUDE_IN_FRAMEWORK
argdumper.cpp
)
-target_link_libraries(lldb-argdumper liblldb)
+if (LLDB_LINKER_SUPPORTS_GROUPS)
+ target_link_libraries(lldb-argdumper -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
+else()
+ target_link_libraries(lldb-argdumper ${LLDB_USED_LIBS})
+endif()
+llvm_config(lldb-argdumper ${LLVM_LINK_COMPONENTS})
+
install(TARGETS lldb-argdumper
RUNTIME DESTINATION bin)
diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt
index 2d4f905323e..b4b67061045 100644
--- a/lldb/tools/driver/CMakeLists.txt
+++ b/lldb/tools/driver/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
add_lldb_executable(lldb
Driver.cpp
Platform.cpp
@@ -18,9 +20,14 @@ if ( LLDB_CAN_USE_DEBUGSERVER )
endif()
target_link_libraries(lldb liblldb)
-# TODO: why isn't this done by add_lldb_executable?
-#target_link_libraries(lldb ${LLDB_USED_LIBS})
-#llvm_config(lldb ${LLVM_LINK_COMPONENTS})
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+ # Windows does not have getopt support, so it relies on the one provided by
+ # liblldb. However, getopt is not a part of the liblldb interfact, so we have
+ # to link against the constituent libraries manually. Note that this is
+ # extremely scary as it introduces ODR violations, and it should go away as
+ # soon as possible.
+ target_link_libraries(lldb ${LLDB_USED_LIBS})
+endif()
set_target_properties(lldb PROPERTIES VERSION ${LLDB_VERSION})
diff --git a/lldb/tools/lldb-mi/CMakeLists.txt b/lldb/tools/lldb-mi/CMakeLists.txt
index 01ad483e4a4..296d0b8547f 100644
--- a/lldb/tools/lldb-mi/CMakeLists.txt
+++ b/lldb/tools/lldb-mi/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
set(LLDB_MI_SOURCES
MICmdArgContext.cpp
MICmdArgSet.cpp
OpenPOWER on IntegriCloud