Skip to content

Commit 5b407ca

Browse files
zhuoweimodocache
authored andcommitted
android: do not add rpaths when linking
the dynamic linker doesn't understand them and spams warnings.
1 parent 627cc07 commit 5b407ca

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ function(_add_swift_library_single target name)
922922
set_target_properties("${target}"
923923
PROPERTIES
924924
INSTALL_NAME_DIR "${install_name_dir}")
925-
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
925+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT "${SWIFTLIB_SINGLE_SDK}" STREQUAL "ANDROID")
926926
set_target_properties("${target}"
927927
PROPERTIES
928928
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/linux")

lib/Driver/ToolChains.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,15 +1162,17 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
11621162

11631163
Arguments.push_back("-lgcc");
11641164
Arguments.push_back("-lc");
1165+
} else {
1166+
// rpaths are not supported on Android.
1167+
1168+
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1169+
// of time the standard library won't be copied.
1170+
Arguments.push_back("-Xlinker");
1171+
Arguments.push_back("-rpath");
1172+
Arguments.push_back("-Xlinker");
1173+
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
11651174
}
11661175

1167-
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1168-
// of time the standard library won't be copied.
1169-
Arguments.push_back("-Xlinker");
1170-
Arguments.push_back("-rpath");
1171-
Arguments.push_back("-Xlinker");
1172-
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
1173-
11741176
// Always add the stdlib
11751177
Arguments.push_back("-lswiftCore");
11761178

0 commit comments

Comments
 (0)