[CMake] Add accurate dependency specifications

Summary:
This patch adds accurate dependency specifications to the mail LLDB libraries and tools.

In all cases except lldb-server, these dependencies are added in addition to existing dependencies (making this low risk), and I performed some code cleanup along the way.

For lldb-server I've cleaned up the LLVM dependencies down to just the minimum actually required. This is more than lldb-server actually directly references, and I've left a todo in the code to clean that up.

Reviewers: labath, zturner

Subscribers: lldb-commits, danalbert, srhines, ki.stfu, mgorny, jgosnell

Differential Revision: https://reviews.llvm.org/D29333

llvm-svn: 293686
This commit is contained in:
Chris Bieneman 2017-01-31 20:43:05 +00:00
parent eb1ad400f9
commit 494f277af5
17 changed files with 250 additions and 178 deletions

View File

@ -20,4 +20,16 @@ add_lldb_library(lldbBreakpoint
Watchpoint.cpp
WatchpointList.cpp
WatchpointOptions.cpp
LINK_LIBS
lldbCore
lldbExpression
lldbInterpreter
lldbSymbol
lldbTarget
lldbPluginCPlusPlusLanguage
lldbPluginObjCLanguage
LINK_COMPONENTS
Support
)

View File

@ -29,4 +29,19 @@ add_lldb_library(lldbCommands
CommandObjectWatchpoint.cpp
CommandObjectWatchpointCommand.cpp
CommandObjectLanguage.cpp
LINK_LIBS
lldbBreakpoint
lldbCore
lldbDataFormatters
lldbExpression
lldbHost
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
lldbPluginExpressionParserClang
LINK_COMPONENTS
Support
)

View File

@ -69,5 +69,24 @@ add_lldb_library(lldbCore
ValueObjectSyntheticFilter.cpp
ValueObjectVariable.cpp
VMRange.cpp
LINK_LIBS
lldbBreakpoint
lldbDataFormatters
lldbExpression
lldbHost
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
lldbPluginProcessUtility
lldbPluginCPlusPlusLanguage
lldbPluginObjCLanguage
lldbPluginObjectFileJIT
lldbPluginExpressionParserClang
LINK_COMPONENTS
Support
Demangle
)

View File

@ -16,4 +16,14 @@ add_lldb_library(lldbDataFormatters
TypeValidator.cpp
ValueObjectPrinter.cpp
VectorType.cpp
LINK_LIBS
lldbCore
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
LINK_COMPONENTS
Support
)

View File

@ -21,4 +21,18 @@ add_lldb_library(lldbExpression
DEPENDS
${tablegen_deps}
LINK_LIBS
lldbCore
lldbHost
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
lldbPluginExpressionParserClang
LINK_COMPONENTS
Core
ExecutionEngine
Support
)

View File

@ -55,6 +55,10 @@ add_host_subdirectory(posix
posix/ConnectionFileDescriptorPosix.cpp
)
if(NOT LLDB_DISABLE_PYTHON)
list(APPEND LLDB_PLUGINS lldbPluginScriptInterpreterPython)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_host_subdirectory(windows
windows/ConnectionGenericFileWindows.cpp
@ -110,6 +114,7 @@ else()
macosx/cfcpp/CFCString.cpp
)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
add_host_subdirectory(linux
linux/AbstractSocket.cpp
@ -120,6 +125,7 @@ else()
linux/ProcessLauncherLinux.cpp
linux/ThisThread.cpp
)
list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_host_subdirectory(android
android/HostInfoAndroid.cpp
@ -157,7 +163,20 @@ if (${get_python_libdir})
endif()
endif()
add_lldb_library(lldbHost ${HOST_SOURCES})
add_lldb_library(lldbHost
${HOST_SOURCES}
LINK_LIBS
lldbCore
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
${LLDB_PLUGINS}
LINK_COMPONENTS
Support
)
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
target_link_libraries(lldbHost kvm)

View File

@ -1,5 +1,36 @@
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
endif()
if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
endif()
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessWindowsCommon
ws2_32
rpcrt4
)
endif ()
add_lldb_library(lldbInitialization
SystemInitializerCommon.cpp
SystemInitializer.cpp
SystemLifetimeManager.cpp
LINK_LIBS
lldbCore
lldbHost
lldbPluginInstructionARM
lldbPluginInstructionMIPS
lldbPluginInstructionMIPS64
lldbPluginObjectContainerBSDArchive
lldbPluginObjectContainerMachOArchive
lldbPluginObjectFileELF
lldbPluginObjectFilePECOFF
lldbPluginProcessGDBRemote
${EXTRA_PLUGINS}
LINK_COMPONENTS
Support
)

View File

@ -43,4 +43,15 @@ add_lldb_library(lldbInterpreter
Options.cpp
Property.cpp
ScriptInterpreter.cpp
LINK_LIBS
lldbCommands
lldbCore
lldbDataFormatters
lldbHost
lldbTarget
lldbUtility
LINK_COMPONENTS
Support
)

View File

@ -36,4 +36,25 @@ add_lldb_library(lldbSymbol
Variable.cpp
VariableList.cpp
VerifyDecl.cpp
LINK_LIBS
clangAST
clangBasic
clangFrontend
lldbCore
lldbDataFormatters
lldbExpression
lldbHost
lldbTarget
lldbUtility
lldbPluginExpressionParserClang
lldbPluginExpressionParserGo
lldbPluginSymbolFileDWARF
lldbPluginSymbolFilePDB
lldbPluginObjectContainerBSDArchive
lldbPluginCPlusPlusLanguage
lldbPluginObjCLanguage
LINK_COMPONENTS
Support
)

View File

@ -58,4 +58,20 @@ add_lldb_library(lldbTarget
ThreadSpec.cpp
UnixSignals.cpp
UnwindAssembly.cpp
LINK_LIBS
lldbBreakpoint
lldbCore
lldbExpression
lldbHost
lldbInterpreter
lldbSymbol
lldbUtility
lldbPluginExpressionParserClang
lldbPluginCPlusPlusLanguage
lldbPluginObjCLanguage
lldbPluginProcessUtility
LINK_COMPONENTS
Support
)

View File

@ -16,4 +16,12 @@ add_lldb_library(lldbUtility
StringLexer.cpp
TaskPool.cpp
UriParser.cpp
LINK_LIBS
lldbCore
lldbHost
lldbTarget
LINK_COMPONENTS
Support
)

View File

@ -2,12 +2,9 @@ include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
argdumper.cpp
LINK_LIBS
lldbCore
lldbUtility
)
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})

View File

@ -33,7 +33,12 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
)
endif ()
add_library(lldbDebugserverCommon
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_library(COCOA_LIBRARY Cocoa)
add_subdirectory(MacOSX)
endif()
add_lldb_library(lldbDebugserverCommon
debugserver.cpp
DNBArch.cpp
DNBBreakpoint.cpp
@ -58,11 +63,13 @@ add_library(lldbDebugserverCommon
RNBSocket.cpp
SysSignal.cpp
TTYState.cpp
LINK_LIBS
lldbHost
${COCOA_LIBRARY}
)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(lldbDebugserverCommon ${COCOA_LIBRARY})
add_subdirectory(MacOSX)
endif()

View File

@ -28,14 +28,6 @@ add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
)
set(DEBUGSERVER_USED_LIBS
lldbDebugserverCommon
lldbUtility
lldbDebugserverMacOSX_I386
lldbDebugserverMacOSX_X86_64
lldbDebugserverMacOSX_DarwinLog
)
add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
HasAVX.s
CFBundle.cpp
@ -51,6 +43,12 @@ add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
OsLogger.cpp
${generated_mach_interfaces}
${DEBUGSERVER_VERS_GENERATED_FILE}
LINK_LIBS
lldbDebugserverCommon
lldbDebugserverMacOSX_I386
lldbDebugserverMacOSX_X86_64
lldbDebugserverMacOSX_DarwinLog
)
set_source_files_properties(
@ -59,8 +57,6 @@ set_source_files_properties(
PROPERTIES LANGUAGE C COMPILE_FLAGS "-x assembler-with-cpp"
)
target_link_libraries(debugserver ${DEBUGSERVER_USED_LIBS})
set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL ""))

View File

@ -1,8 +1,25 @@
include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
(CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
# These targets do not have getopt support, so they rely on the one provided by
# liblldb. However, getopt is not a part of the liblldb interface, 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.
set(host_lib lldbHost)
endif()
add_lldb_tool(lldb
Driver.cpp
Platform.cpp
LINK_LIBS
liblldb
${host_lib}
LINK_COMPONENTS
Support
)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
@ -19,16 +36,5 @@ if ( LLDB_CAN_USE_DEBUGSERVER )
add_dependencies(lldb debugserver)
endif()
target_link_libraries(lldb liblldb)
if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
(CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
# These targets do not have getopt support, so they rely on the one provided by
# liblldb. However, getopt is not a part of the liblldb interface, 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})

View File

@ -1,4 +1,16 @@
set(LLDB_MI_SOURCES
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
add_definitions( -DIMPORT_LIBLLDB )
list(APPEND extra_libs lldbHost)
endif ()
if (HAVE_LIBPTHREAD)
list(APPEND extra_libs pthread)
endif ()
# We need to include the llvm components we depend on manually, as liblldb does
# not re-export those.
set(LLVM_LINK_COMPONENTS Support)
add_lldb_tool(lldb-mi
MICmdArgContext.cpp
MICmdArgSet.cpp
MICmdArgValBase.cpp
@ -72,23 +84,14 @@ set(LLDB_MI_SOURCES
MIUtilString.cpp
MIUtilThreadBaseStd.cpp
MIUtilVariant.cpp
LINK_LIBS
liblldb
${host_lib}
${extra_libs}
LINK_COMPONENTS
Support
)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
add_definitions( -DIMPORT_LIBLLDB )
list(APPEND LLDB_MI_SOURCES
${LLDB_SOURCE_ROOT}/Host/common/GetOptInc.cpp
)
endif ()
# We need to include the llvm components we depend on manually, as liblldb does
# not re-export those.
set(LLVM_LINK_COMPONENTS Support)
add_lldb_tool(lldb-mi ${LLDB_MI_SOURCES})
target_link_libraries(lldb-mi liblldb)
if (HAVE_LIBPTHREAD)
target_link_libraries(lldb-mi pthread)
endif ()
set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION})

View File

@ -23,90 +23,6 @@ endif ()
include_directories(../../source)
set( LLDB_USED_LIBS
lldbBase
lldbBreakpoint
lldbCommands
lldbDataFormatters
lldbHost
lldbCore
lldbExpression
lldbInitialization
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility
# Plugins
lldbPluginDisassemblerLLVM
lldbPluginSymbolFileDWARF
lldbPluginSymbolFilePDB
lldbPluginSymbolFileSymtab
lldbPluginDynamicLoaderPosixDYLD
lldbPluginCPlusPlusLanguage
lldbPluginGoLanguage
lldbPluginJavaLanguage
lldbPluginObjCLanguage
lldbPluginObjCPlusPlusLanguage
lldbPluginOCamlLanguage
lldbPluginObjectFileELF
lldbPluginObjectFileJIT
lldbPluginSymbolVendorELF
lldbPluginPlatformPOSIX
lldbPluginObjectContainerBSDArchive
lldbPluginObjectContainerMachOArchive
lldbPluginProcessGDBRemote
lldbPluginProcessUtility
lldbPluginObjectContainerMachOArchive
lldbPluginObjectContainerBSDArchive
lldbPluginPlatformMacOSX
lldbPluginUnwindAssemblyInstEmulation
lldbPluginUnwindAssemblyX86
lldbPluginAppleObjCRuntime
lldbPluginCXXItaniumABI
lldbPluginInstructionARM
lldbPluginInstructionARM64
lldbPluginInstructionMIPS
lldbPluginInstructionMIPS64
lldbPluginObjectFilePECOFF
lldbPluginExpressionParserClang
lldbPluginExpressionParserGo
)
# Linux-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessLinux
lldbPluginProcessPOSIX
)
endif ()
# Darwin-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
list(APPEND LLDB_USED_LIBS
lldbPluginObjectFileMachO
)
endif()
set( CLANG_USED_LIBS
clangAnalysis
clangAST
clangBasic
clangCodeGen
clangDriver
clangEdit
clangFrontend
clangLex
clangParse
clangRewrite
clangRewriteFrontend
clangSema
clangSerialization
)
set(LLDB_SYSTEM_LIBS)
if (NOT LLDB_DISABLE_LIBEDIT)
list(APPEND LLDB_SYSTEM_LIBS edit)
@ -142,54 +58,25 @@ if (LLVM_BUILD_STATIC)
endif()
endif()
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
interpreter
asmparser
bitreader
bitwriter
codegen
demangle
ipo
selectiondag
bitreader
mc
mcjit
core
mcdisassembler
executionengine
runtimedyld
option
support
coverage
target
)
add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
Acceptor.cpp
lldb-gdbserver.cpp
lldb-platform.cpp
lldb-server.cpp
LLDBServerUtilities.cpp
)
# The Darwin linker doesn't understand --start-group/--end-group.
if (LLDB_LINKER_SUPPORTS_GROUPS)
target_link_libraries(lldb-server
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
target_link_libraries(lldb-server
-Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
else()
target_link_libraries(lldb-server ${LLDB_USED_LIBS})
target_link_libraries(lldb-server ${CLANG_USED_LIBS})
endif()
if(NOT LLVM_LINK_LLVM_DYLIB)
# This is necessary in !LLVM_LINK_LLVM_DYLIB as LLDB's libs do not track their
# dependencies properly. It is conditional because in a LLVM_LINK_LLVM_DYLIB
# build it would introduce duplicate symbols (add_lldb_tool links to libLLVM,
# and this would add the individual .a files as well).
llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
endif()
LINK_LIBS
lldbBase
lldbCore
lldbHost
lldbInitialization
lldbInterpreter
${LLDB_SYSTEM_LIBS}
LINK_COMPONENTS
Support
MCJIT # TODO: Remove this after the plugins are updated
)
target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})