[Lldb-commits] [lldb] r226039 - Fixes compilation/run error with BUILD_SHARED_LIBS=TRUE

Vince Harron vharron at google.com
Wed Jan 14 13:01:15 PST 2015


Author: vharron
Date: Wed Jan 14 15:01:15 2015
New Revision: 226039

URL: http://llvm.org/viewvc/llvm-project?rev=226039&view=rev
Log:
Fixes compilation/run error with BUILD_SHARED_LIBS=TRUE

BUILD_SHARED_LIBS=TRUE currently isn't working for Linux x86_64
This patch fixes the link errors and also some runtime errors

Test Plan:
CC=clang CXX=clang++ cmake -GNinja -DBUILD_SHARED_LIBS=TRUE -DCMAKE_LINKER=ld.gold -DCMAKE_BUILD_TYPE=Debug ../../llvm
ninja
ninja check-lldb


Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/cmake/LLDBDependencies.cmake
    lldb/trunk/source/CMakeLists.txt
    lldb/trunk/tools/lldb-gdbserver/CMakeLists.txt
    lldb/trunk/tools/lldb-mi/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=226039&r1=226038&r2=226039&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Jan 14 15:01:15 2015
@@ -236,7 +236,15 @@ else ()
 endif ()
 
 macro(add_lldb_library name)
-  llvm_process_sources(srcs ${ARGN})
+  # only supported parameters to this macro are the optional 
+  # MODULE;SHARED;STATIC library type and source files
+  cmake_parse_arguments(PARAM
+    "MODULE;SHARED;STATIC"
+    ""
+    ""
+    ${ARGN})
+  llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
+  
   if (MSVC_IDE OR XCODE)
     string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
     list(GET split_path -1 dir)
@@ -244,13 +252,17 @@ macro(add_lldb_library name)
       ../../include/lldb${dir}/*.h)
     set(srcs ${srcs} ${headers})
   endif()
-  if (MODULE)
+  if (PARAM_MODULE)
     set(libkind MODULE)
-  elseif (SHARED_LIBRARY)
+  elseif (PARAM_SHARED)
     set(libkind SHARED)
-  else()
+  elseif (PARAM_STATIC)
     set(libkind STATIC)
+  else ()
+    # library type unspecified - controlled by BUILD_SHARED_LIBS
+    unset(libkind)
   endif()
+
   #PIC not needed on Win
   if (NOT MSVC)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=226039&r1=226038&r2=226039&view=diff
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Wed Jan 14 15:01:15 2015
@@ -18,14 +18,12 @@ set( LLDB_USED_LIBS
   lldbPluginDynamicLoaderPosixDYLD
   lldbPluginDynamicLoaderHexagonDYLD
 
-  lldbPluginObjectFileMachO
   lldbPluginObjectFileELF
   lldbPluginObjectFileJIT
   lldbPluginSymbolVendorELF
   lldbPluginObjectContainerBSDArchive
   lldbPluginObjectContainerMachOArchive
   lldbPluginProcessGDBRemote
-  lldbPluginProcessMachCore
   lldbPluginProcessUtility
   lldbPluginPlatformGDB
   lldbPluginPlatformFreeBSD
@@ -33,7 +31,6 @@ set( LLDB_USED_LIBS
   lldbPluginPlatformLinux
   lldbPluginPlatformPOSIX
   lldbPluginPlatformWindows
-  lldbPluginObjectFileMachO
   lldbPluginObjectContainerMachOArchive
   lldbPluginObjectContainerBSDArchive
   lldbPluginPlatformMacOSX
@@ -106,6 +103,8 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Darwin"
   set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
   list(APPEND LLDB_USED_LIBS
     lldbPluginDynamicLoaderDarwinKernel
+    lldbPluginObjectFileMachO
+    lldbPluginProcessMachCore
     lldbPluginProcessMacOSXKernel
     lldbPluginSymbolVendorMacOSX
     lldbPluginSystemRuntimeMacOSX
@@ -165,6 +164,7 @@ set( LLVM_LINK_COMPONENTS
   mcdisassembler
   executionengine
   option
+  support
   )
 
 if ( NOT LLDB_DISABLE_PYTHON )

Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=226039&r1=226038&r2=226039&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Wed Jan 14 15:01:15 2015
@@ -30,6 +30,7 @@ endif ()
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
   add_subdirectory(API)
 endif ()
+
 add_subdirectory(Breakpoint)
 add_subdirectory(Commands)
 add_subdirectory(Core)
@@ -44,8 +45,6 @@ add_subdirectory(Utility)
 
 include(../cmake/LLDBDependencies.cmake)
 
-set(SHARED_LIBRARY 1)
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
 add_definitions( -DEXPORT_LIBLLDB )
 endif()
@@ -56,7 +55,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows"
 # On Non-Windows, the corresponding file list is maintained in
 # source\API\CMakeLists.txt.  When editing this list, do not forget to make a
 # corresponding change in that file as well (when appropriate).
-add_lldb_library(liblldb
+add_lldb_library(liblldb SHARED
   lldb.cpp
   lldb-log.cpp
   API/SBAddress.cpp

Modified: lldb/trunk/tools/lldb-gdbserver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-gdbserver/CMakeLists.txt?rev=226039&r1=226038&r2=226039&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-gdbserver/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-gdbserver/CMakeLists.txt Wed Jan 14 15:01:15 2015
@@ -17,26 +17,33 @@ include_directories(../../source)
 
 include(../../cmake/LLDBDependencies.cmake)
 
-# have to include lldb and lldb-log files since those are not libraries and llgs depends on them
-add_lldb_executable(lldb-gdbserver
-  lldb-gdbserver.cpp
-  ../../source/lldb-log.cpp
-  ../../source/lldb.cpp
-  )
-
-# The Darwin linker doesn't understand --start-group/--end-group.
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
-  target_link_libraries(lldb-gdbserver
-                        -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
+if ( BUILD_SHARED_LIBS )
+  add_lldb_executable(lldb-gdbserver
+    lldb-gdbserver.cpp
+    )
+
+  target_link_libraries(lldb-gdbserver liblldb)
 else()
-  target_link_libraries(lldb-gdbserver ${LLDB_USED_LIBS})
-endif()
-target_link_libraries(lldb-gdbserver ${CLANG_USED_LIBS})
-llvm_config(lldb-gdbserver ${LLVM_LINK_COMPONENTS})
+  # have to include lldb and lldb-log files since those are not libraries and llgs depends on them
+  add_lldb_executable(lldb-gdbserver
+    lldb-gdbserver.cpp
+    ../../source/lldb-log.cpp
+    ../../source/lldb.cpp
+    )
+
+  # The Darwin linker doesn't understand --start-group/--end-group.
+  if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+    target_link_libraries(lldb-gdbserver
+                          -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
+  else()
+    target_link_libraries(lldb-gdbserver ${LLDB_USED_LIBS})
+  endif()
+  target_link_libraries(lldb-gdbserver ${CLANG_USED_LIBS})
+  llvm_config(lldb-gdbserver ${LLVM_LINK_COMPONENTS})
 
-target_link_libraries(lldb-gdbserver ${LLDB_SYSTEM_LIBS})
+  target_link_libraries(lldb-gdbserver ${LLDB_SYSTEM_LIBS})
+endif()
 
 set_target_properties(lldb-gdbserver PROPERTIES VERSION ${LLDB_VERSION})
-
 install(TARGETS lldb-gdbserver
   RUNTIME DESTINATION bin)

Modified: lldb/trunk/tools/lldb-mi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/CMakeLists.txt?rev=226039&r1=226038&r2=226039&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt Wed Jan 14 15:01:15 2015
@@ -164,7 +164,7 @@ add_lldb_executable(lldb-mi
   )
 endif ()
 
-target_link_libraries(lldb-mi liblldb)
+target_link_libraries(lldb-mi liblldb pthread)
 # TODO: why isn't this done by add_lldb_executable?
 #target_link_libraries(lldb-mi ${LLDB_USED_LIBS})
 #llvm_config(lldb-mi ${LLVM_LINK_COMPONENTS})





More information about the lldb-commits mailing list