[Lldb-commits] [lldb] r316997 - Fix LLVM_LINK_LLVM_DYLIB build (pr35053)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 31 06:23:19 PDT 2017


Author: labath
Date: Tue Oct 31 06:23:19 2017
New Revision: 316997

URL: http://llvm.org/viewvc/llvm-project?rev=316997&view=rev
Log:
Fix LLVM_LINK_LLVM_DYLIB build (pr35053)

Summary:
r316368 broke this build when it introduced a reference to a pthread
function to the Utility module. This caused cmake to generate an
incorrect link line (wrong order of libs) because it did not see the
dependency from Utility to the system libraries. Instead these libraries
were being manually added to each final target.

This changes moves the dependency management from the individual targets
to the lldbUtility module, which is consistent with how llvm does it.
The final targets will pick up these libraries as they will be a part of
the link interface of the module.

Technically, some of these dependencies could go into the host module,
as that's where most of the os-specific code is, but I did not try to
investigate which ones.

Reviewers: zturner, sylvestre.ledru

Subscribers: lldb-commits, mgorny

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

Removed:
    lldb/trunk/cmake/LLDBDependencies.cmake
Modified:
    lldb/trunk/scripts/CMakeLists.txt
    lldb/trunk/source/API/CMakeLists.txt
    lldb/trunk/source/Utility/CMakeLists.txt
    lldb/trunk/tools/argdumper/CMakeLists.txt
    lldb/trunk/tools/driver/CMakeLists.txt
    lldb/trunk/tools/intel-features/CMakeLists.txt
    lldb/trunk/tools/lldb-server/CMakeLists.txt
    lldb/trunk/unittests/CMakeLists.txt

Removed: lldb/trunk/cmake/LLDBDependencies.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=316996&view=auto
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake (removed)
@@ -1,52 +0,0 @@
-set(LLDB_SYSTEM_LIBS)
-
-# Windows-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  list(APPEND LLDB_SYSTEM_LIBS
-    ws2_32
-    rpcrt4
-    )
-endif ()
-
-if (NOT LLDB_DISABLE_LIBEDIT)
-  list(APPEND LLDB_SYSTEM_LIBS edit)
-endif()
-if (NOT LLDB_DISABLE_CURSES)
-  list(APPEND LLDB_SYSTEM_LIBS ${CURSES_LIBRARIES})
-  if(LLVM_ENABLE_TERMINFO AND HAVE_TERMINFO)
-    list(APPEND LLDB_SYSTEM_LIBS ${TERMINFO_LIBS})
-  endif()
-endif()
-
-if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
-    list(APPEND LLDB_SYSTEM_LIBS atomic)
-endif()
-
-list(APPEND LLDB_SYSTEM_LIBS ${Backtrace_LIBRARY})
-
-if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
-  list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
-endif()
-
-list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
-
-if (LLVM_BUILD_STATIC)
-  if (NOT LLDB_DISABLE_PYTHON)
-    list(APPEND LLDB_SYSTEM_LIBS python2.7 util)
-  endif()
-  if (NOT LLDB_DISABLE_CURSES)
-    list(APPEND LLDB_SYSTEM_LIBS gpm)
-  endif()
-endif()
-
-if ( NOT LLDB_DISABLE_PYTHON )
-  set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
-  if (CLANG_CL)
-    set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES COMPILE_FLAGS -Wno-unused-function)
-  endif()
-  if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
-      NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
-    set_property(SOURCE ${LLDB_WRAP_PYTHON}
-                 APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
-  endif ()
-endif()

Modified: lldb/trunk/scripts/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/scripts/CMakeLists.txt (original)
+++ lldb/trunk/scripts/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -48,10 +48,10 @@ add_custom_command(
       --swigExecutable=${SWIG_EXECUTABLE}
   VERBATIM
   COMMENT "Python script building LLDB Python wrapper")
-set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
+add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON})
+
 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1)
 
-add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON})
 
 # Install the LLDB python module
 install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})

Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -2,10 +2,6 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows"
   add_definitions( -DEXPORT_LIBLLDB )
 endif()
 
-# Include this so that add_lldb_library() has the list of dependencies
-# for liblldb to link against
-include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
-
 option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
 
 if(LLDB_BUILD_FRAMEWORK AND CMAKE_VERSION VERSION_LESS 3.7)
@@ -112,9 +108,17 @@ if (LLVM_ENABLE_WERROR)
     set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
   endif()
 endif()
+set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
+if (CLANG_CL)
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+    PROPERTY COMPILE_FLAGS " -Wno-unused-function")
+endif()
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
+    NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+    PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
+endif ()
 
-# This should not be part of LLDBDependencies.cmake, because we don't
-# want every single library taking a dependency on the script interpreters.
 target_link_libraries(liblldb PRIVATE
   lldbPluginScriptInterpreterNone
   lldbPluginScriptInterpreterPython
@@ -156,7 +160,6 @@ endif()
 if (LLDB_WRAP_PYTHON)
   add_dependencies(liblldb swig_wrapper)
 endif()
-target_link_libraries(liblldb PRIVATE ${LLDB_SYSTEM_LIBS})
 
 if(LLDB_BUILD_FRAMEWORK)
   file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h

Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -1,3 +1,44 @@
+set(LLDB_SYSTEM_LIBS)
+
+# Windows-only libraries
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+  list(APPEND LLDB_SYSTEM_LIBS
+    ws2_32
+    rpcrt4
+    )
+endif ()
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  list(APPEND LLDB_SYSTEM_LIBS edit)
+endif()
+if (NOT LLDB_DISABLE_CURSES)
+  list(APPEND LLDB_SYSTEM_LIBS ${CURSES_LIBRARIES})
+  if(LLVM_ENABLE_TERMINFO AND HAVE_TERMINFO)
+    list(APPEND LLDB_SYSTEM_LIBS ${TERMINFO_LIBS})
+  endif()
+endif()
+
+if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
+    list(APPEND LLDB_SYSTEM_LIBS atomic)
+endif()
+
+list(APPEND LLDB_SYSTEM_LIBS ${Backtrace_LIBRARY})
+
+if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
+  list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
+endif()
+
+list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
+
+if (LLVM_BUILD_STATIC)
+  if (NOT LLDB_DISABLE_PYTHON)
+    list(APPEND LLDB_SYSTEM_LIBS python2.7 util)
+  endif()
+  if (NOT LLDB_DISABLE_CURSES)
+    list(APPEND LLDB_SYSTEM_LIBS gpm)
+  endif()
+endif()
+
 add_lldb_library(lldbUtility
   Baton.cpp
   Connection.cpp
@@ -38,7 +79,8 @@ add_lldb_library(lldbUtility
   VMRange.cpp
 
   LINK_LIBS
-  # lldbUtility cannot have any dependencies
+    ${LLDB_SYSTEM_LIBS}
+    # lldbUtility does not depend on other LLDB libraries
 
   LINK_COMPONENTS
     BinaryFormat

Modified: lldb/trunk/tools/argdumper/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/argdumper/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/tools/argdumper/CMakeLists.txt (original)
+++ lldb/trunk/tools/argdumper/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -1,9 +1,6 @@
-include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
-
 add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
   argdumper.cpp
 
   LINK_LIBS
     lldbUtility
   )
-

Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -1,5 +1,3 @@
-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

Modified: lldb/trunk/tools/intel-features/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/intel-features/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/tools/intel-features/CMakeLists.txt (original)
+++ lldb/trunk/tools/intel-features/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -1,5 +1,3 @@
-include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
-
 # Flags to control each individual feature
 option(LLDB_BUILD_INTEL_MPX "Enable Building of Intel(R) Memory Protection Extensions" ON)
 option(LLDB_BUILD_INTEL_PT "Enable Building of Intel(R) Processor Trace Tool" OFF)
@@ -63,7 +61,6 @@ add_lldb_library(lldbIntelFeatures SHARE
 # Add link dependencies for python wrapper
 if (NOT LLDB_DISABLE_PYTHON AND LLDB_BUILD_INTEL_PT)
   add_dependencies(lldbIntelFeatures intel-features-swig_wrapper)
-  target_link_libraries(lldbIntelFeatures PRIVATE ${LLDB_SYSTEM_LIBS})
 endif()
 
 install(TARGETS lldbIntelFeatures

Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -24,41 +24,6 @@ endif ()
 
 include_directories(../../source)
 
-set(LLDB_SYSTEM_LIBS)
-if (NOT LLDB_DISABLE_LIBEDIT)
-  list(APPEND LLDB_SYSTEM_LIBS edit)
-endif()
-if (NOT LLDB_DISABLE_CURSES)
-  list(APPEND LLDB_SYSTEM_LIBS ${CURSES_LIBRARIES})
-  if(LLVM_ENABLE_TERMINFO AND HAVE_TERMINFO)
-    list(APPEND LLDB_SYSTEM_LIBS ${TERMINFO_LIBS})
-  endif()
-endif()
-
-if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
-    list(APPEND LLDB_SYSTEM_LIBS atomic)
-endif()
-
-# On FreeBSD/NetBSD backtrace() is provided by libexecinfo, not libc.
-if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-  list(APPEND LLDB_SYSTEM_LIBS execinfo)
-endif()
-
-if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
-  list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
-endif()
-
-list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
-
-if (LLVM_BUILD_STATIC)
-  if (NOT LLDB_DISABLE_PYTHON)
-    list(APPEND LLDB_SYSTEM_LIBS python2.7 util)
-  endif()
-  if (NOT LLDB_DISABLE_CURSES)
-    list(APPEND LLDB_SYSTEM_LIBS gpm)
-  endif()
-endif()
-
 set(LLDB_PLUGINS)
 
 if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")

Modified: lldb/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/CMakeLists.txt?rev=316997&r1=316996&r2=316997&view=diff
==============================================================================
--- lldb/trunk/unittests/CMakeLists.txt (original)
+++ lldb/trunk/unittests/CMakeLists.txt Tue Oct 31 06:23:19 2017
@@ -11,8 +11,6 @@ else ()
   list(APPEND LLVM_COMPILE_FLAGS -include ${LLDB_GTEST_COMMON_INCLUDE})
 endif ()
 
-include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
-
 if (LLDB_BUILT_STANDALONE)
   # Build the gtest library needed for unittests, if we have LLVM sources
   # handy.
@@ -46,7 +44,7 @@ function(add_lldb_unittest test_name)
     POST_BUILD
     COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  target_link_libraries(${test_name} ${ARG_LINK_LIBS} ${LLDB_SYSTEM_LIBS})
+  target_link_libraries(${test_name} ${ARG_LINK_LIBS})
 endfunction()
 
 function(add_unittest_inputs test_name inputs)




More information about the lldb-commits mailing list