From 4bfbfe935f8016ba7164899bef69d312be6be2ac Mon Sep 17 00:00:00 2001 From: Butta Date: Thu, 5 Mar 2020 15:15:31 +0530 Subject: [PATCH] [build][android] set INSTALL_RPATH properly for shared libraries Host libraries will likely all need ORIGIN set, whereas only set it for target libraries that will be packaged with a native toolchain on Android. --- cmake/modules/AddSwift.cmake | 11 +++-------- stdlib/cmake/modules/AddSwiftStdlib.cmake | 7 +++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index bd7f6788970ca..a26126d9cfe2f 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -628,14 +628,9 @@ function(_add_swift_host_library_single target) PROPERTIES INSTALL_RPATH "$ORIGIN:/usr/lib/swift/cygwin") elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID") - # Only set the install RPATH if cross-compiling the host tools, in which - # case both the NDK and Sysroot paths must be set. - if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "" AND - NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "") - set_target_properties("${target}" - PROPERTIES - INSTALL_RPATH "$ORIGIN") - endif() + set_target_properties("${target}" + PROPERTIES + INSTALL_RPATH "$ORIGIN") endif() set_target_properties("${target}" PROPERTIES BUILD_WITH_INSTALL_RPATH YES) diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index 3f9cf357ea2e7..0a27a5be3b437 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -527,10 +527,9 @@ function(_add_swift_target_library_single target name) if(SWIFTLIB_SINGLE_TARGET_LIBRARY) set_target_properties("${target}" PROPERTIES NO_SONAME TRUE) endif() - # Only set the install RPATH if cross-compiling the host tools, in which - # case both the NDK and Sysroot paths must be set. - if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "" AND - NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "") + # Only set the install RPATH if the toolchain and stdlib will be in Termux + # or some other native sysroot on Android. + if(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "") set_target_properties("${target}" PROPERTIES INSTALL_RPATH "$ORIGIN")