Skip to content

Cherry pick two swift changes from next branch #4051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lldb/cmake/modules/AddLLDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,40 @@ function(add_lldb_library name)
endif()
endfunction(add_lldb_library)

# BEGIN Swift Mods
function(add_properties_for_swift_modules target)
if (BOOTSTRAPPING_MODE)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS|.*HOSTLIBS")
target_link_directories(${target} PRIVATE
"${CMAKE_OSX_SYSROOT}/usr/lib/swift"
"${LLDB_SWIFT_LIBS}/macosx")
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH
"/usr/lib/swift")
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
target_link_directories(${target} PRIVATE "${LLDB_SWIFT_LIBS}/macosx")
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH
"${LLDB_SWIFT_LIBS}/macosx")
else()
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE}'")
endif()

# Workaround for a linker crash related to autolinking: rdar://77839981
set_property(TARGET ${target} APPEND_STRING PROPERTY
LINK_FLAGS " -lobjc ")
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
string(REGEX MATCH "^[^-]*" arch ${TARGET_TRIPLE})
target_link_libraries(${target} PRIVATE swiftCore-linux-${arch})

# TODO: add "${LLDB_SWIFT_LIBS}/linux" to BUILD_RPATH and not INSTALL_RPATH.
# This does not work for some reason.
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH
"${LLDB_SWIFT_LIBS}/linux;$ORIGIN/../lib/swift/linux")
endif()
endif()
endfunction()
# END Swift Mods

function(add_lldb_executable name)
cmake_parse_arguments(ARG
"GENERATE_INSTALL"
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ add_lldb_library(liblldb SHARED ${option_framework}
${option_install_prefix}
)

# BEGIN Swift Mods
add_properties_for_swift_modules(liblldb)
# END Swift Mods

# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
# which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so
# (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so
Expand Down
5 changes: 5 additions & 0 deletions lldb/source/Plugins/ExpressionParser/Swift/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ if(NOT LLDB_BUILT_STANDALONE)
set(tablegen_deps intrinsics_gen)
endif()

if (NOT BOOTSTRAPPING_MODE)
add_library(swiftCompilerModules ALIAS swiftCompilerStub)
endif()

add_lldb_library(lldbPluginExpressionParserSwift PLUGIN
SwiftASTManipulator.cpp
SwiftExpressionParser.cpp
Expand Down Expand Up @@ -37,6 +41,7 @@ add_lldb_library(lldbPluginExpressionParserSwift PLUGIN
swiftSIL
swiftSILOptimizer
swiftSerialization
swiftCompilerModules
clangAST
clangBasic
clangRewrite
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "swift/AST/Module.h"
#include "swift/AST/Type.h"
#include "swift/AST/Types.h"
#include "swift/Basic/InitializeSwiftModules.h"
#include "swift/Demangling/ManglingMacros.h"
#include "llvm/Support/ConvertUTF.h"

Expand Down Expand Up @@ -80,6 +81,8 @@ void SwiftLanguage::Initialize() {
lldb_private::formatters::NSArray_Additionals::GetAdditionalSynthetics()
.emplace(g_NSArrayClass1,
lldb_private::formatters::swift::ArraySyntheticFrontEndCreator);

initializeSwiftModules();
}

void SwiftLanguage::Terminate() {
Expand Down
4 changes: 4 additions & 0 deletions lldb/tools/lldb-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ add_lldb_tool(lldb-test
Support
)

# BEGIN Swift Mods
add_properties_for_swift_modules(lldb-test)
# END Swift Mods

if(Python3_RPATH)
set_property(TARGET lldb-test APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
set_property(TARGET lldb-test APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
Expand Down