Skip to content

Commit

Permalink
[CMake] Final dependency cleanup patch!
Browse files Browse the repository at this point in the history
Summary:
This patch removes the over-specified dependencies from LLDBDependencies and instead relies on the dependencies as expressed in each library and tool.

This also removes the library looping in favor of allowing CMake to do its thing. I've tested this patch on Darwin, and found no issues, but since linker semantics vary by system I'll also work on testing it on other platforms too.

Help testing would be greatly appreciated.

Reviewers: labath, zturner

Subscribers: danalbert, srhines, mgorny, jgosnell, lldb-commits

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

llvm-svn: 294515
  • Loading branch information
Chris Bieneman committed Feb 8, 2017
1 parent e7a9820 commit fd2f0cb
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 335 deletions.
166 changes: 2 additions & 164 deletions lldb/cmake/LLDBDependencies.cmake
@@ -1,152 +1,13 @@
set( LLDB_USED_LIBS
lldbBase
lldbBreakpoint
lldbCommands
lldbDataFormatters
lldbHost
lldbCore
lldbExpression
lldbInitialization
lldbInterpreter
lldbSymbol
lldbTarget
lldbUtility

# Plugins
lldbPluginDisassemblerLLVM
lldbPluginSymbolFileDWARF
lldbPluginSymbolFilePDB
lldbPluginSymbolFileSymtab
lldbPluginDynamicLoaderStatic
lldbPluginDynamicLoaderPosixDYLD
lldbPluginDynamicLoaderHexagonDYLD
lldbPluginDynamicLoaderWindowsDYLD

lldbPluginCPlusPlusLanguage
lldbPluginGoLanguage
lldbPluginJavaLanguage
lldbPluginObjCLanguage
lldbPluginObjCPlusPlusLanguage
lldbPluginOCamlLanguage

lldbPluginObjectFileELF
lldbPluginObjectFileJIT
lldbPluginSymbolVendorELF
lldbPluginObjectContainerBSDArchive
lldbPluginObjectContainerMachOArchive
lldbPluginProcessGDBRemote
lldbPluginProcessUtility
lldbPluginPlatformAndroid
lldbPluginPlatformGDB
lldbPluginPlatformFreeBSD
lldbPluginPlatformKalimba
lldbPluginPlatformLinux
lldbPluginPlatformNetBSD
lldbPluginPlatformPOSIX
lldbPluginPlatformWindows
lldbPluginObjectContainerMachOArchive
lldbPluginObjectContainerBSDArchive
lldbPluginPlatformMacOSX
lldbPluginStructuredDataDarwinLog
lldbPluginDynamicLoaderMacOSXDYLD
lldbPluginUnwindAssemblyInstEmulation
lldbPluginUnwindAssemblyX86
lldbPluginAppleObjCRuntime
lldbPluginRenderScriptRuntime
lldbPluginLanguageRuntimeGo
lldbPluginLanguageRuntimeJava
lldbPluginCXXItaniumABI
lldbPluginABIMacOSX_arm
lldbPluginABIMacOSX_arm64
lldbPluginABIMacOSX_i386
lldbPluginABISysV_arm
lldbPluginABISysV_arm64
lldbPluginABISysV_i386
lldbPluginABISysV_x86_64
lldbPluginABISysV_hexagon
lldbPluginABISysV_ppc
lldbPluginABISysV_ppc64
lldbPluginABISysV_mips
lldbPluginABISysV_mips64
lldbPluginABISysV_s390x
lldbPluginInstructionARM
lldbPluginInstructionARM64
lldbPluginInstructionMIPS
lldbPluginInstructionMIPS64
lldbPluginObjectFilePECOFF
lldbPluginOSGo
lldbPluginOSPython
lldbPluginMemoryHistoryASan
lldbPluginInstrumentationRuntimeAddressSanitizer
lldbPluginInstrumentationRuntimeThreadSanitizer
lldbPluginSystemRuntimeMacOSX
lldbPluginProcessElfCore
lldbPluginProcessMinidump
lldbPluginJITLoaderGDB
lldbPluginExpressionParserClang
lldbPluginExpressionParserGo
)
set(LLDB_SYSTEM_LIBS)

# Windows-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessWindowsCommon
list(APPEND LLDB_SYSTEM_LIBS
ws2_32
rpcrt4
)
endif ()

# Linux-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessLinux
lldbPluginProcessPOSIX
)
endif ()

# FreeBSD-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessFreeBSD
lldbPluginProcessPOSIX
)
endif ()

# NetBSD-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessPOSIX
)
endif ()

# Darwin-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
list(APPEND LLDB_USED_LIBS
lldbPluginDynamicLoaderDarwinKernel
lldbPluginObjectFileMachO
lldbPluginProcessMachCore
lldbPluginProcessMacOSXKernel
lldbPluginSymbolVendorMacOSX
)
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)
endif()
Expand Down Expand Up @@ -178,29 +39,6 @@ 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
)

if ( NOT LLDB_DISABLE_PYTHON )
set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
if (CLANG_CL)
Expand Down
29 changes: 0 additions & 29 deletions lldb/cmake/modules/AddLLDB.cmake
@@ -1,22 +1,3 @@
function(lldb_link_common_libs name targetkind)
if (NOT LLDB_USED_LIBS)
return()
endif()

if(${targetkind} MATCHES "SHARED")
set(LINK_KEYWORD PRIVATE)
endif()

if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
if (LLDB_LINKER_SUPPORTS_GROUPS)
target_link_libraries(${name} ${LINK_KEYWORD}
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
else()
target_link_libraries(${name} ${LINK_KEYWORD} ${LLDB_USED_LIBS})
endif()
endif()
endfunction(lldb_link_common_libs)

function(add_lldb_library name)
# only supported parameters to this macro are the optional
# MODULE;SHARED;STATIC library type and source files
Expand Down Expand Up @@ -61,17 +42,7 @@ function(add_lldb_library name)
if (PARAM_OBJECT)
add_library(${name} ${libkind} ${srcs})
else()
if (PARAM_SHARED AND LLDB_LINKER_SUPPORTS_GROUPS)
set(start_group -Wl,--start-group)
set(end_group -Wl,--end-group)
endif()
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
${start_group}
${LLDB_USED_LIBS}
${end_group}
${start_group}
${CLANG_USED_LIBS}
${end_group}
${PARAM_LINK_LIBS}
DEPENDS ${PARAM_DEPENDS})

Expand Down
17 changes: 17 additions & 0 deletions lldb/source/API/CMakeLists.txt
Expand Up @@ -16,6 +16,8 @@ if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
endif()

get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)

add_lldb_library(liblldb SHARED
SBAddress.cpp
SBAttachInfo.cpp
Expand Down Expand Up @@ -80,6 +82,21 @@ add_lldb_library(liblldb SHARED
SBUnixSignals.cpp
SystemInitializerFull.cpp
${LLDB_WRAP_PYTHON}

LINK_LIBS
lldbBase
lldbBreakpoint
lldbCore
lldbDataFormatters
lldbExpression
lldbHost
lldbInitialization
lldbInterpreter
lldbSymbol
lldbTarget
${LLDB_ALL_PLUGINS}
LINK_COMPONENTS
Support
)

if (LLVM_ENABLE_WERROR)
Expand Down
7 changes: 2 additions & 5 deletions lldb/source/Initialization/CMakeLists.txt
Expand Up @@ -7,11 +7,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
endif()

if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
list(APPEND LLDB_USED_LIBS
lldbPluginProcessWindowsCommon
ws2_32
rpcrt4
)
list(APPEND EXTRA_PLUGINS lldbPluginProcessWindowsCommon)
endif ()

add_lldb_library(lldbInitialization
Expand All @@ -31,6 +27,7 @@ add_lldb_library(lldbInitialization
lldbPluginObjectFilePECOFF
lldbPluginProcessGDBRemote
${EXTRA_PLUGINS}
${LLDB_SYSTEM_LIBS}
LINK_COMPONENTS
Support
)
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Process/CMakeLists.txt
Expand Up @@ -10,9 +10,9 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_subdirectory(Windows/Common)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(MacOSX-Kernel)
add_subdirectory(mach-core)
endif()
add_subdirectory(gdb-remote)
add_subdirectory(Utility)
add_subdirectory(mach-core)
add_subdirectory(elf-core)
add_subdirectory(minidump)
2 changes: 2 additions & 0 deletions lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
Expand Up @@ -28,6 +28,8 @@ add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN
lldbHost
lldbInterpreter
lldbTarget
ws2_32
rpcrt4
LINK_COMPONENTS
Support
)
12 changes: 2 additions & 10 deletions lldb/tools/intel-mpx/CMakeLists.txt
Expand Up @@ -8,16 +8,8 @@ add_library(lldb-intel-mpxtable SHARED
IntelMPXTablePlugin.cpp
)

target_link_libraries(lldb-intel-mpxtable PUBLIC liblldb)

if (LLDB_LINKER_SUPPORTS_GROUPS)
target_link_libraries(lldb-intel-mpxtable PUBLIC
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
else()
target_link_libraries(lldb-intel-mpxtable PUBLIC ${LLDB_USED_LIBS})
endif()
llvm_config(lldb-intel-mpxtable ${LLVM_LINK_COMPONENTS})

target_link_libraries(lldb-intel-mpxtable
PUBLIC liblldb LLVMSupport)

install(TARGETS lldb-intel-mpxtable
LIBRARY DESTINATION bin)

0 comments on commit fd2f0cb

Please sign in to comment.