From 4b7545a97355e5dbd234274a9a971d4adbcc2395 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 1 Sep 2023 10:03:51 -0700 Subject: [PATCH 1/3] LLVMSupport: partially backport 6613f4aff85b24a13d4f5f7e9cd24bf3f44037a3 This partially backports the API changes from 6613f4aff85b24a13d4f5f7e9cd24bf3f44037a3 to accommodate the plugin loading support for Swift Macros. --- llvm/include/llvm/Support/DynamicLibrary.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/include/llvm/Support/DynamicLibrary.h b/llvm/include/llvm/Support/DynamicLibrary.h index 0771606a75f56..6e4022f8dac26 100644 --- a/llvm/include/llvm/Support/DynamicLibrary.h +++ b/llvm/include/llvm/Support/DynamicLibrary.h @@ -45,6 +45,9 @@ class DynamicLibrary { /// Returns true if the object refers to a valid library. bool isValid() const { return Data != &Invalid; } + /// Return the OS specific handle value. + void *getOSSpecificHandle() const { return Data; } + /// Searches through the library for the symbol \p symbolName. If it is /// found, the address of that symbol is returned. If not, NULL is returned. /// Note that NULL will also be returned if the library failed to load. From 45f6a5316dfc34be0f053fe62fb22b0d858b9f99 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 1 Sep 2023 10:07:06 -0700 Subject: [PATCH 2/3] build: adjust the build to wire up the library search path This is needed to support Swift macros on Windows. --- lldb/cmake/modules/AddLLDB.cmake | 11 ++++++++--- llvm/lib/Support/CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 334de8bf5894d..fcd07cc1ec4ed 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -190,17 +190,22 @@ function(add_properties_for_swift_modules target reldir) # Workaround for a linker crash related to autolinking: rdar://77839981 set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " -lobjc ") + + set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}") + set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}") elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD") string(REGEX MATCH "^[^-]*" arch ${LLVM_TARGET_TRIPLE}) target_link_libraries(${target} PRIVATE swiftCore-linux-${arch}) string(TOLOWER ${CMAKE_SYSTEM_NAME} platform) set(SWIFT_BUILD_RPATH "${LLDB_SWIFT_LIBS}/${platform}") set(SWIFT_INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/${platform}") + set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}") + set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}") + elseif(CMAKE_SYSTEM_NAME MATCHES Windows) + target_link_directories(${target} PRIVATE + ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/Windows/x86_64) endif() - set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}") - set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}") - if (SWIFT_SWIFT_PARSER) if (CMAKE_SYSTEM_NAME MATCHES "Darwin") set_property(TARGET ${target} diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index d23938c8a7de9..cf4f6b04b7156 100644 --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -81,7 +81,7 @@ endif( MSVC OR MINGW ) # Delay load shell32.dll if possible to speed up process startup. set (delayload_flags) if (MSVC) - set (delayload_flags delayimp -delayload:shell32.dll -delayload:ole32.dll) + set (delayload_flags $<$>:delayimp -delayload:shell32.dll -delayload:ole32.dll>) endif() # Link Z3 if the user wants to build it. From d013aae1eba33246dc9a5dc4f61273442b7dfa54 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 7 Sep 2023 09:33:02 -0700 Subject: [PATCH 3/3] build: support multiple architectures on Windows Swift on Windows only supports 64-bit hosts. Add support for x64 and ARM64 toolchains to be built. --- lldb/cmake/modules/AddLLDB.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index fcd07cc1ec4ed..c46ecb355f8d5 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -202,8 +202,13 @@ function(add_properties_for_swift_modules target reldir) set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}") set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}") elseif(CMAKE_SYSTEM_NAME MATCHES Windows) - target_link_directories(${target} PRIVATE - ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/Windows/x86_64) + if(CMAKE_SYSTEM_PROCESSOR MATCHES AMD64|amd64|x86_64) + target_link_directories(${target} PRIVATE + ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/windows/x86_64) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ARM64|arm64|aarch64) + target_link_directories(${target} PRIVATE + ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/windows/aarch64) + endif() endif() if (SWIFT_SWIFT_PARSER)