summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/cmake/caches/Apple-lldb-macOS.cmake3
-rw-r--r--lldb/cmake/modules/AddLLDB.cmake138
-rw-r--r--lldb/cmake/modules/LLDBConfig.cmake9
-rw-r--r--lldb/cmake/modules/LLDBFramework.cmake2
-rw-r--r--lldb/source/API/CMakeLists.txt8
-rw-r--r--lldb/tools/argdumper/CMakeLists.txt8
-rw-r--r--lldb/tools/darwin-debug/CMakeLists.txt8
-rw-r--r--lldb/tools/debugserver/source/CMakeLists.txt16
8 files changed, 118 insertions, 74 deletions
diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake
index 944fc906c51..e1a34ad326a 100644
--- a/lldb/cmake/caches/Apple-lldb-macOS.cmake
+++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake
@@ -13,6 +13,9 @@ set(CMAKE_INSTALL_PREFIX /Applications/Xcode.app/Contents/Developer/usr CACHE ST
# CMAKE_INSTALL_PREFIX. In any case, DESTDIR will be an extra prefix.
set(LLDB_FRAMEWORK_INSTALL_DIR /Applications/Xcode.app/Contents/SharedFrameworks CACHE STRING "")
+# DESTDIR will be an extra prefix
+set(LLDB_DEBUGINFO_INSTALL_PREFIX /debuginfo CACHE STRING "")
+
# Release builds may change these:
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index e8241e7ee2f..d53dab654a1 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -3,7 +3,7 @@ function(add_lldb_library name)
# MODULE;SHARED;STATIC library type and source files
cmake_parse_arguments(PARAM
"MODULE;SHARED;STATIC;OBJECT;PLUGIN"
- "ENTITLEMENTS"
+ "INSTALL_PREFIX;ENTITLEMENTS"
"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
${ARGN})
llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
@@ -58,38 +58,26 @@ function(add_lldb_library name)
${pass_ENTITLEMENTS}
${pass_NO_INSTALL_RPATH}
)
+ endif()
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
- if (PARAM_SHARED)
- if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
- if(LLDB_FRAMEWORK_INSTALL_DIR)
- set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
- else()
- set(install_dir ".")
- endif()
- else()
- set(install_dir lib${LLVM_LIBDIR_SUFFIX})
- endif()
- install(TARGETS ${name}
- COMPONENT ${name}
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${install_dir}
- ARCHIVE DESTINATION ${install_dir})
- else()
- install(TARGETS ${name}
- COMPONENT ${name}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
- endif()
- if (NOT CMAKE_CONFIGURATION_TYPES)
- add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
- endif()
+ if(PARAM_SHARED)
+ set(install_dest lib${LLVM_LIBDIR_SUFFIX})
+ if(PARAM_INSTALL_PREFIX)
+ set(install_dest ${PARAM_INSTALL_PREFIX})
+ endif()
+ # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS
+ install(TARGETS ${name} COMPONENT ${name}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION ${install_dest}
+ ARCHIVE DESTINATION ${install_dest}
+ FRAMEWORK DESTINATION ${install_dest})
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
endif()
endif()
-
# Hack: only some LLDB libraries depend on the clang autogenerated headers,
# but it is simple enough to make all of LLDB depend on some of those
# headers without negatively impacting much of anything.
@@ -110,7 +98,7 @@ endfunction(add_lldb_library)
function(add_lldb_executable name)
cmake_parse_arguments(ARG
"GENERATE_INSTALL"
- "ENTITLEMENTS"
+ "INSTALL_PREFIX;ENTITLEMENTS"
"LINK_LIBS;LINK_COMPONENTS"
${ARGN}
)
@@ -134,16 +122,22 @@ function(add_lldb_executable name)
set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
if(ARG_GENERATE_INSTALL)
- install(TARGETS ${name}
- COMPONENT ${name}
- RUNTIME DESTINATION bin)
+ set(install_dest bin)
+ if(ARG_INSTALL_PREFIX)
+ set(install_dest ${ARG_INSTALL_PREFIX})
+ endif()
+ install(TARGETS ${name} COMPONENT ${name}
+ RUNTIME DESTINATION ${install_dest})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
+ if(APPLE AND ARG_INSTALL_PREFIX)
+ lldb_add_post_install_steps_darwin(${name} ${ARG_INSTALL_PREFIX})
+ endif()
endif()
-endfunction(add_lldb_executable)
+endfunction()
macro(add_lldb_tool_subdirectory name)
@@ -151,7 +145,19 @@ macro(add_lldb_tool_subdirectory name)
endmacro()
function(add_lldb_tool name)
- add_lldb_executable(${name} GENERATE_INSTALL ${ARGN})
+ cmake_parse_arguments(ARG "ADD_TO_FRAMEWORK" "" "" ${ARGN})
+ if(LLDB_BUILD_FRAMEWORK AND ARG_ADD_TO_FRAMEWORK)
+ set(subdir LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources)
+ add_lldb_executable(${name}
+ GENERATE_INSTALL
+ INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR}/${subdir}
+ ${ARG_UNPARSED_ARGUMENTS}
+ )
+ lldb_add_to_buildtree_lldb_framework(${name} ${subdir})
+ return()
+ endif()
+
+ add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS})
endfunction()
# Support appending linker flags to an existing target.
@@ -170,12 +176,7 @@ function(lldb_append_link_flags target_name new_link_flags)
set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
endfunction()
-# Unified handling for executable LLDB.framework resources. Given the name of an
-# executable target, this function adds a post-build step to copy it to the
-# framework bundle in the build-tree.
-function(lldb_add_to_framework name)
- set(subdir "LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources")
-
+function(lldb_add_to_buildtree_lldb_framework name subdir)
# Destination for the copy in the build-tree. While the framework target may
# not exist yet, it will exist when the generator expression gets expanded.
set(copy_dest "$<TARGET_FILE_DIR:liblldb>/../../../${subdir}")
@@ -187,6 +188,61 @@ function(lldb_add_to_framework name)
)
endfunction()
+function(lldb_add_post_install_steps_darwin name install_prefix)
+ if(NOT APPLE)
+ message(WARNING "Darwin-specific functionality; not currently available on non-Apple platforms.")
+ return()
+ endif()
+
+ get_target_property(output_name ${name} OUTPUT_NAME)
+ if(NOT output_name)
+ set(output_name ${name})
+ endif()
+
+ get_target_property(is_framework ${name} FRAMEWORK)
+ if(is_framework)
+ get_target_property(buildtree_dir ${name} LIBRARY_OUTPUT_DIRECTORY)
+ if(buildtree_dir)
+ set(bundle_subdir ${output_name}.framework/Versions/${LLDB_FRAMEWORK_VERSION}/)
+ else()
+ message(SEND_ERROR "Framework target ${name} missing property for output directory. Cannot generate post-install steps.")
+ return()
+ endif()
+ else()
+ get_target_property(target_type ${name} TYPE)
+ if(target_type STREQUAL "EXECUTABLE")
+ set(buildtree_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
+ else()
+ # Only ever install shared libraries.
+ set(output_name "lib${output_name}.dylib")
+ set(buildtree_dir ${LLVM_LIBRARY_OUTPUT_INTDIR})
+ endif()
+ endif()
+
+ # Generate dSYM in symroot
+ set(dsym_name ${output_name}.dSYM)
+ if(is_framework)
+ set(dsym_name ${output_name}.framework.dSYM)
+ endif()
+ if(LLDB_DEBUGINFO_INSTALL_PREFIX)
+ # This makes the path absolute, so we must respect DESTDIR.
+ set(dsym_name "\$ENV\{DESTDIR\}${LLDB_DEBUGINFO_INSTALL_PREFIX}/${dsym_name}")
+ endif()
+
+ set(buildtree_name ${buildtree_dir}/${bundle_subdir}${output_name})
+ install(CODE "message(STATUS \"Externalize debuginfo: ${dsym_name}\")" COMPONENT ${name})
+ install(CODE "execute_process(COMMAND xcrun dsymutil -o=${dsym_name} ${buildtree_name})"
+ COMPONENT ${name})
+
+ # Strip distribution binary with -ST (removing debug symbol table entries and
+ # Swift symbols). Avoid CMAKE_INSTALL_DO_STRIP and llvm_externalize_debuginfo()
+ # as they can't be configured sufficiently.
+ set(installtree_name "\$ENV\{DESTDIR\}${install_prefix}/${bundle_subdir}${output_name}")
+ install(CODE "message(STATUS \"Stripping: ${installtree_name}\")" COMPONENT ${name})
+ install(CODE "execute_process(COMMAND xcrun strip -ST ${installtree_name})"
+ COMPONENT ${name})
+endfunction()
+
# CMake's set_target_properties() doesn't allow to pass lists for RPATH
# properties directly (error: "called with incorrect number of arguments").
# Instead of defining two list variables each time, use this helper function.
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index e65b4bd9773..ef9356591c3 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -65,12 +65,9 @@ if(LLDB_BUILD_FRAMEWORK)
set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework")
- # Set designated directory for all dSYMs. Essentially, this emits the
- # framework's dSYM outside of the framework directory.
- if(LLVM_EXTERNALIZE_DEBUGINFO)
- set(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING
- "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)")
- endif()
+ # Essentially, emit the framework's dSYM outside of the framework directory.
+ set(LLDB_DEBUGINFO_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING
+ "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)")
endif()
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake
index 56e0880b423..f5f3cd4d60a 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -33,6 +33,8 @@ set_output_directory(liblldb
LIBRARY_DIR ${framework_target_dir}
)
+lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
+
# Affects the layout of the framework bundle (default is macOS layout).
if(IOS)
set_target_properties(liblldb PROPERTIES
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 8d2b7f06bef..d93b8b5e381 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -9,8 +9,8 @@ if(NOT LLDB_DISABLE_PYTHON)
set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
endif()
-if(LLDB_BUILD_FRAMEWORK AND LLVM_EXTERNALIZE_DEBUGINFO)
- set(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION framework.dSYM)
+if(LLDB_BUILD_FRAMEWORK)
+ set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR})
endif()
add_lldb_library(liblldb SHARED
@@ -99,7 +99,9 @@ add_lldb_library(liblldb SHARED
${LLDB_ALL_PLUGINS}
LINK_COMPONENTS
Support
- )
+
+ ${option_install_prefix}
+)
if (MSVC)
set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
diff --git a/lldb/tools/argdumper/CMakeLists.txt b/lldb/tools/argdumper/CMakeLists.txt
index af9374b7ea8..d0767483781 100644
--- a/lldb/tools/argdumper/CMakeLists.txt
+++ b/lldb/tools/argdumper/CMakeLists.txt
@@ -1,10 +1,6 @@
-add_lldb_tool(lldb-argdumper
+add_lldb_tool(lldb-argdumper ADD_TO_FRAMEWORK
argdumper.cpp
LINK_LIBS
lldbUtility
- )
-
-if(LLDB_BUILD_FRAMEWORK)
- lldb_add_to_framework(lldb-argdumper)
-endif()
+)
diff --git a/lldb/tools/darwin-debug/CMakeLists.txt b/lldb/tools/darwin-debug/CMakeLists.txt
index 6b9eac31fe5..b902788f05a 100644
--- a/lldb/tools/darwin-debug/CMakeLists.txt
+++ b/lldb/tools/darwin-debug/CMakeLists.txt
@@ -1,7 +1,3 @@
-add_lldb_tool(darwin-debug
+add_lldb_tool(darwin-debug ADD_TO_FRAMEWORK
darwin-debug.cpp
- )
-
-if(LLDB_BUILD_FRAMEWORK)
- lldb_add_to_framework(darwin-debug)
-endif()
+)
diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt
index 863afaaecfb..cf305c9d268 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -272,22 +272,14 @@ if(build_and_sign_debugserver)
COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
endif()
set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
- add_lldb_tool(debugserver
+ add_lldb_tool(debugserver ADD_TO_FRAMEWORK
debugserver.cpp
-
- LINK_LIBS
- lldbDebugserverCommon
-
- ENTITLEMENTS
- ${entitlements}
- )
+ LINK_LIBS lldbDebugserverCommon
+ ENTITLEMENTS ${entitlements}
+ )
set_target_properties(debugserver PROPERTIES FOLDER "lldb libraries/debugserver")
- if(LLDB_BUILD_FRAMEWORK)
- lldb_add_to_framework(debugserver)
- endif()
-
if(IOS)
set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
WITH_LOCKDOWN
OpenPOWER on IntegriCloud