From c442ddda7c8438393a30a898ae375749ff5f1993 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Sun, 27 Aug 2023 07:08:26 +0000 Subject: [PATCH] [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 16cd2dbfa9df4..ff9d0251479c9 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -224,10 +224,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 24ef9ad348eb2..4b1dfe93ee7e0 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -154,7 +154,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)