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

llvm-svn: 316997
This commit is contained in:
Pavel Labath 2017-10-31 13:23:19 +00:00
parent d1089e5cea
commit f753bfeeec
9 changed files with 56 additions and 108 deletions

View File

@ -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()

View File

@ -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})

View File

@ -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

View File

@ -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

View File

@ -1,9 +1,6 @@
include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
argdumper.cpp
LINK_LIBS
lldbUtility
)

View File

@ -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

View File

@ -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 SHARED
# 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

View File

@ -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")

View File

@ -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)