Skip to content

Commit 400559d

Browse files
[CMake] install-distribution support for swift-lldb on Darwin
apple-llvm-split-commit: 8fab08d6a138b1c6b26b2cd319b32d814f348225 apple-llvm-split-dir: lldb/
1 parent c0be5ef commit 400559d

File tree

3 files changed

+46
-23
lines changed

3 files changed

+46
-23
lines changed

lldb/cmake/caches/Apple-lldb-macOS.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ set(LLVM_DISTRIBUTION_COMPONENTS
2727
lldb-argdumper
2828
darwin-debug
2929
debugserver
30+
repl_swift
3031
CACHE STRING "")

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,22 @@ function(lldb_add_post_install_steps_darwin name install_prefix)
220220
endif()
221221

222222
# Generate dSYM in symroot
223-
set(dsym_name ${output_name}.dSYM)
224-
if(is_framework)
225-
set(dsym_name ${output_name}.framework.dSYM)
226-
endif()
227-
if(LLDB_DEBUGINFO_INSTALL_PREFIX)
228-
# This makes the path absolute, so we must respect DESTDIR.
229-
set(dsym_name "\$ENV\{DESTDIR\}${LLDB_DEBUGINFO_INSTALL_PREFIX}/${dsym_name}")
230-
endif()
223+
# TODO: Add an option to skip dSYM creation
224+
if(NOT ${name} STREQUAL "repl_swift")
225+
set(dsym_name ${output_name}.dSYM)
226+
if(is_framework)
227+
set(dsym_name ${output_name}.framework.dSYM)
228+
endif()
229+
if(LLDB_DEBUGINFO_INSTALL_PREFIX)
230+
# This makes the path absolute, so we must respect DESTDIR.
231+
set(dsym_name "\$ENV\{DESTDIR\}${LLDB_DEBUGINFO_INSTALL_PREFIX}/${dsym_name}")
232+
endif()
231233

232-
set(buildtree_name ${buildtree_dir}/${bundle_subdir}${output_name})
233-
install(CODE "message(STATUS \"Externalize debuginfo: ${dsym_name}\")" COMPONENT ${name})
234-
install(CODE "execute_process(COMMAND xcrun dsymutil -o=${dsym_name} ${buildtree_name})"
235-
COMPONENT ${name})
234+
set(buildtree_name ${buildtree_dir}/${bundle_subdir}${output_name})
235+
install(CODE "message(STATUS \"Externalize debuginfo: ${dsym_name}\")" COMPONENT ${name})
236+
install(CODE "execute_process(COMMAND xcrun dsymutil -o=${dsym_name} ${buildtree_name})"
237+
COMPONENT ${name})
238+
endif()
236239

237240
# Strip distribution binary with -ST (removing debug symbol table entries and
238241
# Swift symbols). Avoid CMAKE_INSTALL_DO_STRIP and llvm_externalize_debuginfo()

lldb/tools/repl/swift/CMakeLists.txt

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Set the correct rpath to locate libswiftCore.
2-
if (LLDB_BUILD_FRAMEWORK)
3-
get_target_property(framework_target_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
4-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath \
5-
-Wl,${framework_target_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/Swift/macosx")
6-
elseif( CMAKE_SYSTEM_NAME MATCHES "Linux" )
7-
# Set the correct rpath to locate libswiftCore
2+
if( CMAKE_SYSTEM_NAME MATCHES "Linux" )
83
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ppc64le")
94
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
105
-Wl,-rpath,${CMAKE_BINARY_DIR}/../swift-linux-powerpc64le/lib${LLVM_LIBDIR_SUFFIX}/swift/linux/powerpc64le")
@@ -15,7 +10,13 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Linux" )
1510
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib/swift/linux:${CMAKE_INSTALL_RPATH}")
1611
endif()
1712

18-
add_lldb_tool(repl_swift
13+
# Override locally, so the repl is ad-hoc signed.
14+
set(LLVM_CODESIGNING_IDENTITY "-")
15+
16+
# Requires system-provided Swift libs.
17+
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14.4)
18+
19+
add_lldb_tool(repl_swift ADD_TO_FRAMEWORK
1920
main.c
2021
)
2122
target_link_libraries(repl_swift PRIVATE ${CMAKE_DL_LIBS})
@@ -24,10 +25,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
2425
WIN32_EXECUTABLE TRUE)
2526
endif()
2627

27-
if(LLDB_BUILD_FRAMEWORK)
28-
lldb_add_to_framework(repl_swift)
29-
endif()
30-
3128
# The dummy repl executable is a C program, but we always look for a mangled
3229
# swift symbol (corresponding to main). If we build the repl with debug info,
3330
# the debugger looks at the frame language (looking up the compile unit) and gets
@@ -40,3 +37,25 @@ else()
4037
set_target_properties(repl_swift PROPERTIES
4138
COMPILE_FLAGS "-g0")
4239
endif()
40+
41+
if(APPLE)
42+
# Set the RPATHs to locate libswiftCore. Prefer the just-built one.
43+
set(swift_buildtree ${LLDB_PATH_TO_SWIFT_BUILD}/lib/swift/macosx)
44+
set(system_libs /usr/lib/swift)
45+
46+
if(LLDB_BUILD_FRAMEWORK)
47+
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
48+
set(lldb_buildtree {framework_build_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/Swift/macosx)
49+
set(lldb_installtree Swift/macosx) # repl_swift is installed to framework Resources
50+
endif()
51+
52+
lldb_setup_rpaths(repl_swift
53+
BUILD_RPATH
54+
${swift_buildtree}
55+
${lldb_buildtree}
56+
${system_libs}
57+
INSTALL_RPATH
58+
${lldb_installtree}
59+
${system_libs}
60+
)
61+
endif()

0 commit comments

Comments
 (0)