Skip to content

Commit 12217a4

Browse files
committed
[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 680e5ba) (cherry picked from commit ea46866)
1 parent 71b6f8f commit 12217a4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,17 @@ function(add_properties_for_swift_modules target reldir)
202202
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}")
203203

204204
if (SWIFT_SWIFT_PARSER)
205-
set_property(TARGET ${target}
206-
APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host")
207-
set_property(TARGET ${target}
208-
APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host")
205+
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
206+
set_property(TARGET ${target}
207+
APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host")
208+
set_property(TARGET ${target}
209+
APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host")
210+
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD")
211+
set_property(TARGET ${target}
212+
APPEND PROPERTY BUILD_RPATH "$ORIGIN/${build_reldir}lib/swift/host")
213+
set_property(TARGET ${target}
214+
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/host")
215+
endif()
209216
endif()
210217
endif()
211218
endfunction()

lldb/source/API/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ endif()
149149
# BEGIN Swift Mods
150150
# Note that add_properties_for_swift_modules appends RPATHs so it's critical
151151
# that this is called after lldb_setup_rpaths.
152-
add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../")
152+
if(LLDB_BUILD_FRAMEWORK)
153+
add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../")
154+
else()
155+
add_properties_for_swift_modules(liblldb "../")
156+
endif()
153157
# END Swift Mods
154158

155159
if(LLDB_ENABLE_PYTHON)

0 commit comments

Comments
 (0)