beanz updated this revision to Diff 86461.
beanz added a comment.

Updates based on post commit feedback from labath.

He was right on both points. LLVM libs should be done through LINK_COMPONENTS, 
and I messed up lldb-server's dependencies.


https://reviews.llvm.org/D29333

Files:
  source/Breakpoint/CMakeLists.txt
  source/Commands/CMakeLists.txt
  source/Core/CMakeLists.txt
  source/DataFormatters/CMakeLists.txt
  source/Expression/CMakeLists.txt
  source/Host/CMakeLists.txt
  source/Initialization/CMakeLists.txt
  source/Interpreter/CMakeLists.txt
  source/Symbol/CMakeLists.txt
  source/Target/CMakeLists.txt
  source/Utility/CMakeLists.txt
  tools/argdumper/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  tools/driver/CMakeLists.txt
  tools/lldb-mi/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt

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
+      ${LLDB_SYSTEM_LIBS}
+
+    LINK_COMPONENTS
+      Support
+      MCJIT # TODO: Remove this after the plugins are updated
+)
 
 target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
 
Index: tools/lldb-mi/CMakeLists.txt
===================================================================
--- tools/lldb-mi/CMakeLists.txt
+++ tools/lldb-mi/CMakeLists.txt
@@ -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 @@
   MIUtilString.cpp
   MIUtilThreadBaseStd.cpp
   MIUtilVariant.cpp
-  )
 
-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})
+  LINK_LIBS
+    liblldb
+    ${host_lib}
+    ${extra_libs}
 
-target_link_libraries(lldb-mi liblldb)
-if (HAVE_LIBPTHREAD)
-  target_link_libraries(lldb-mi pthread)
-endif ()
+  LINK_COMPONENTS
+    Support
+  )
 
 set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION})
Index: tools/driver/CMakeLists.txt
===================================================================
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -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 @@
   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})
 
Index: tools/debugserver/source/MacOSX/CMakeLists.txt
===================================================================
--- tools/debugserver/source/MacOSX/CMakeLists.txt
+++ tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -28,14 +28,6 @@
           ${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,16 +43,20 @@
   OsLogger.cpp
   ${generated_mach_interfaces}
   ${DEBUGSERVER_VERS_GENERATED_FILE}
+
+  LINK_LIBS
+    lldbDebugserverCommon
+    lldbDebugserverMacOSX_I386
+    lldbDebugserverMacOSX_X86_64
+    lldbDebugserverMacOSX_DarwinLog
   )
 
 set_source_files_properties(
   HasAVX.s
   # Necessary since compilation will fail with stand-alone assembler
   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 ""))
Index: tools/debugserver/source/CMakeLists.txt
===================================================================
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -33,7 +33,12 @@
     )
 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 @@
   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()
+
+
+
 
Index: tools/argdumper/CMakeLists.txt
===================================================================
--- tools/argdumper/CMakeLists.txt
+++ tools/argdumper/CMakeLists.txt
@@ -2,12 +2,9 @@
 
 add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
   argdumper.cpp
-  )
 
-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})
+  LINK_LIBS
+    lldbCore
+    lldbUtility
+  )
 
Index: source/Utility/CMakeLists.txt
===================================================================
--- source/Utility/CMakeLists.txt
+++ source/Utility/CMakeLists.txt
@@ -16,4 +16,12 @@
   StringLexer.cpp
   TaskPool.cpp
   UriParser.cpp
+
+  LINK_LIBS
+    lldbCore
+    lldbHost
+    lldbTarget
+
+  LINK_COMPONENTS
+    Support
   )
Index: source/Target/CMakeLists.txt
===================================================================
--- source/Target/CMakeLists.txt
+++ source/Target/CMakeLists.txt
@@ -58,4 +58,20 @@
   ThreadSpec.cpp
   UnixSignals.cpp
   UnwindAssembly.cpp
+
+  LINK_LIBS
+    lldbBreakpoint
+    lldbCore
+    lldbExpression
+    lldbHost
+    lldbInterpreter
+    lldbSymbol
+    lldbUtility
+    lldbPluginExpressionParserClang
+    lldbPluginCPlusPlusLanguage
+    lldbPluginObjCLanguage
+    lldbPluginProcessUtility
+
+  LINK_COMPONENTS
+    Support
   )
Index: source/Symbol/CMakeLists.txt
===================================================================
--- source/Symbol/CMakeLists.txt
+++ source/Symbol/CMakeLists.txt
@@ -36,4 +36,25 @@
   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
   )
Index: source/Interpreter/CMakeLists.txt
===================================================================
--- source/Interpreter/CMakeLists.txt
+++ source/Interpreter/CMakeLists.txt
@@ -43,4 +43,15 @@
   Options.cpp
   Property.cpp
   ScriptInterpreter.cpp
+
+  LINK_LIBS
+    lldbCommands
+    lldbCore
+    lldbDataFormatters
+    lldbHost
+    lldbTarget
+    lldbUtility
+
+  LINK_COMPONENTS
+    Support
   )
Index: source/Initialization/CMakeLists.txt
===================================================================
--- source/Initialization/CMakeLists.txt
+++ source/Initialization/CMakeLists.txt
@@ -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
   )
Index: source/Host/CMakeLists.txt
===================================================================
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -55,6 +55,10 @@
   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 @@
       macosx/cfcpp/CFCString.cpp
       )
 
+
   elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
     add_host_subdirectory(linux
       linux/AbstractSocket.cpp
@@ -120,6 +125,7 @@
       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 @@
   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)
Index: source/Expression/CMakeLists.txt
===================================================================
--- source/Expression/CMakeLists.txt
+++ source/Expression/CMakeLists.txt
@@ -21,4 +21,18 @@
 
   DEPENDS
   ${tablegen_deps}
+
+  LINK_LIBS
+    lldbCore
+    lldbHost
+    lldbInterpreter
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+    lldbPluginExpressionParserClang
+
+  LINK_COMPONENTS
+    Core
+    ExecutionEngine
+    Support
   )
Index: source/DataFormatters/CMakeLists.txt
===================================================================
--- source/DataFormatters/CMakeLists.txt
+++ source/DataFormatters/CMakeLists.txt
@@ -16,4 +16,14 @@
   TypeValidator.cpp
   ValueObjectPrinter.cpp
   VectorType.cpp
+
+  LINK_LIBS
+    lldbCore
+    lldbInterpreter
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+  
+  LINK_COMPONENTS
+    Support
   )
Index: source/Core/CMakeLists.txt
===================================================================
--- source/Core/CMakeLists.txt
+++ source/Core/CMakeLists.txt
@@ -69,5 +69,24 @@
   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
   )
 
Index: source/Commands/CMakeLists.txt
===================================================================
--- source/Commands/CMakeLists.txt
+++ source/Commands/CMakeLists.txt
@@ -29,4 +29,19 @@
   CommandObjectWatchpoint.cpp
   CommandObjectWatchpointCommand.cpp
   CommandObjectLanguage.cpp
+
+  LINK_LIBS
+    lldbBreakpoint
+    lldbCore
+    lldbDataFormatters
+    lldbExpression
+    lldbHost
+    lldbInterpreter
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+    lldbPluginExpressionParserClang
+
+  LINK_COMPONENTS
+    Support
   )
Index: source/Breakpoint/CMakeLists.txt
===================================================================
--- source/Breakpoint/CMakeLists.txt
+++ source/Breakpoint/CMakeLists.txt
@@ -20,4 +20,16 @@
   Watchpoint.cpp
   WatchpointList.cpp
   WatchpointOptions.cpp
+
+  LINK_LIBS
+    lldbCore
+    lldbExpression
+    lldbInterpreter
+    lldbSymbol
+    lldbTarget
+    lldbPluginCPlusPlusLanguage
+    lldbPluginObjCLanguage
+
+  LINK_COMPONENTS
+    Support
   )
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to