Skip to content

Commit c442ddd

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)
1 parent 5cb6573 commit c442ddd

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
@@ -224,10 +224,17 @@ function(add_properties_for_swift_modules target reldir)
224224
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}")
225225

226226
if (SWIFT_SWIFT_PARSER)
227-
set_property(TARGET ${target}
228-
APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host")
229-
set_property(TARGET ${target}
230-
APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host")
227+
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
228+
set_property(TARGET ${target}
229+
APPEND PROPERTY BUILD_RPATH "@loader_path/${build_reldir}lib/swift/host")
230+
set_property(TARGET ${target}
231+
APPEND PROPERTY INSTALL_RPATH "@loader_path/${reldir}lib/swift/host")
232+
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD")
233+
set_property(TARGET ${target}
234+
APPEND PROPERTY BUILD_RPATH "$ORIGIN/${build_reldir}lib/swift/host")
235+
set_property(TARGET ${target}
236+
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/host")
237+
endif()
231238
endif()
232239
endif()
233240
endfunction()

lldb/source/API/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ endif()
154154
# BEGIN Swift Mods
155155
# Note that add_properties_for_swift_modules appends RPATHs so it's critical
156156
# that this is called after lldb_setup_rpaths.
157-
add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../")
157+
if(LLDB_BUILD_FRAMEWORK)
158+
add_properties_for_swift_modules(liblldb "../../../../../../usr/" "../../../../")
159+
else()
160+
add_properties_for_swift_modules(liblldb "../")
161+
endif()
158162
# END Swift Mods
159163

160164
if(LLDB_ENABLE_PYTHON)

0 commit comments

Comments
 (0)