From ea46866ac807e6530f97e8d5513b7de6cfd88b36 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Sun, 27 Aug 2023 07:08:26 +0000 Subject: [PATCH 1/2] [lldb][Swift][CMake] Correct RUNPATH in Linux builds * When LLDB_BUILD_FRAMEWORK is not enabled, liblldb is built/installed in 'lib/'. Pass the correct path to 'add_properties_for_swift_modules * '$ORIGIN' instead of '@loader_path' in Linux-like platforms (cherry picked from commit 680e5bae2c5eb29f4c1af61dcf63fe995b1f9492) --- lldb/cmake/modules/AddLLDB.cmake | 15 +++++++++++---- lldb/source/API/CMakeLists.txt | 6 +++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 55179762db7fc..8660bb5d1449b 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -202,10 +202,17 @@ function(add_properties_for_swift_modules target reldir) set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}") if (SWIFT_SWIFT_PARSER) - set_property(TARGET ${target} - APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host") - set_property(TARGET ${target} - APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host") + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set_property(TARGET ${target} + APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host") + set_property(TARGET ${target} + APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host") + elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD") + set_property(TARGET ${target} + APPEND PROPERTY BUILD_RPATH "$ORIGIN/${build_reldir}lib/swift/host") + set_property(TARGET ${target} + APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/host") + endif() endif() endif() endfunction() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index a7cc725c4f6e2..0ae67bd241bcb 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -149,7 +149,11 @@ endif() # BEGIN Swift Mods # Note that add_properties_for_swift_modules appends RPATHs so it's critical # that this is called after lldb_setup_rpaths. -add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../") +if(LLDB_BUILD_FRAMEWORK) + add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../") +else() + add_properties_for_swift_modules(liblldb "../") +endif() # END Swift Mods if(LLDB_ENABLE_PYTHON) From 18215d545185d60648cc0ae2551788695702dc55 Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Wed, 30 Aug 2023 19:14:12 +0530 Subject: [PATCH 2/2] [lldb][cmake] Fix relative path used for lldb executables I had this looking directly in `./swift//` before, but now that an installed lldb executable also links against Swift libraries, this needs to be the more general `../lib/swift//`. (cherry picked from commit 5444a68ce063ec580273010f640578408d7c6cba) --- lldb/cmake/modules/AddLLDB.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 8660bb5d1449b..334de8bf5894d 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -195,7 +195,7 @@ function(add_properties_for_swift_modules target reldir) 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/swift/${platform}") + set(SWIFT_INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/${platform}") endif() set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}")