beanz created this revision.
Herald added subscribers: jgosnell, mgorny, srhines, danalbert.

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.


https://reviews.llvm.org/D29352

Files:
  cmake/LLDBDependencies.cmake
  cmake/modules/AddLLDB.cmake
  source/API/CMakeLists.txt
  source/Initialization/CMakeLists.txt
  source/Plugins/Process/Windows/Common/CMakeLists.txt
  tools/intel-mpx/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===================================================================
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -31,8 +31,7 @@
     POST_BUILD
     COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  lldb_link_common_libs(${test_name} EXE)
-  target_link_libraries(${test_name} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
+  target_link_libraries(${test_name} ${LLDB_SYSTEM_LIBS})
   llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})
 endfunction()
 
Index: tools/lldb-server/CMakeLists.txt
===================================================================
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -23,90 +23,6 @@
 
 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 @@
   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
+      ${EXTRA_LLDB_LIBS}
+      ${LLDB_SYSTEM_LIBS}
+
+    LINK_COMPONENTS
+      Support
+)
 
 target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
 
Index: tools/intel-mpx/CMakeLists.txt
===================================================================
--- tools/intel-mpx/CMakeLists.txt
+++ tools/intel-mpx/CMakeLists.txt
@@ -8,16 +8,8 @@
   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)
Index: source/Plugins/Process/Windows/Common/CMakeLists.txt
===================================================================
--- source/Plugins/Process/Windows/Common/CMakeLists.txt
+++ source/Plugins/Process/Windows/Common/CMakeLists.txt
@@ -28,6 +28,8 @@
     lldbHost
     lldbInterpreter
     lldbTarget
+    ws2_32
+    rpcrt4
   LINK_COMPONENTS
     Support
   )
Index: source/Initialization/CMakeLists.txt
===================================================================
--- source/Initialization/CMakeLists.txt
+++ source/Initialization/CMakeLists.txt
@@ -7,11 +7,7 @@
 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
@@ -31,6 +27,7 @@
     lldbPluginObjectFilePECOFF
     lldbPluginProcessGDBRemote
     ${EXTRA_PLUGINS}
+    ${LLDB_SYSTEM_LIBS}
   LINK_COMPONENTS
     Support
   )
Index: source/API/CMakeLists.txt
===================================================================
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -16,6 +16,8 @@
   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
@@ -80,6 +82,21 @@
   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)
Index: cmake/modules/AddLLDB.cmake
===================================================================
--- cmake/modules/AddLLDB.cmake
+++ 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
@@ -61,17 +42,7 @@
   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})
 
Index: cmake/LLDBDependencies.cmake
===================================================================
--- cmake/LLDBDependencies.cmake
+++ 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()
@@ -178,29 +39,6 @@
   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)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to