[Lldb-commits] [lldb] r284466 - [cmake] Make dependencies of lldb libraries private, take 2
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 18 03:26:58 PDT 2016
Author: labath
Date: Tue Oct 18 05:26:57 2016
New Revision: 284466
URL: http://llvm.org/viewvc/llvm-project?rev=284466&view=rev
Log:
[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
Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
lldb/trunk/tools/argdumper/CMakeLists.txt
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/lldb-mi/CMakeLists.txt
Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=284466&r1=284465&r2=284466&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Tue Oct 18 05:26:57 2016
@@ -4,7 +4,7 @@ function(lldb_link_common_libs name targ
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")
Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt?rev=284466&r1=284465&r2=284466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt Tue Oct 18 05:26:57 2016
@@ -1,4 +1,4 @@
-set(LLVM_PRIVATE_LINK_COMPONENTS
+set(LLVM_LINK_COMPONENTS
DebugInfoPDB)
add_lldb_library(lldbPluginSymbolFilePDB
Modified: lldb/trunk/tools/argdumper/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/argdumper/CMakeLists.txt?rev=284466&r1=284465&r2=284466&view=diff
==============================================================================
--- lldb/trunk/tools/argdumper/CMakeLists.txt (original)
+++ lldb/trunk/tools/argdumper/CMakeLists.txt Tue Oct 18 05:26:57 2016
@@ -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)
Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=284466&r1=284465&r2=284466&view=diff
==============================================================================
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Tue Oct 18 05:26:57 2016
@@ -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})
Modified: lldb/trunk/tools/lldb-mi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/CMakeLists.txt?rev=284466&r1=284465&r2=284466&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt Tue Oct 18 05:26:57 2016
@@ -1,3 +1,5 @@
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
set(LLDB_MI_SOURCES
MICmdArgContext.cpp
MICmdArgSet.cpp
More information about the lldb-commits
mailing list