Skip to content

Commit 1b61ae7

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

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
@@ -1135,15 +1135,17 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
11351135

11361136
Arguments.push_back("-lgcc");
11371137
Arguments.push_back("-lc");
1138+
} else {
1139+
// rpaths are not supported on Android.
1140+
1141+
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1142+
// of time the standard library won't be copied.
1143+
Arguments.push_back("-Xlinker");
1144+
Arguments.push_back("-rpath");
1145+
Arguments.push_back("-Xlinker");
1146+
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
11381147
}
11391148

1140-
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1141-
// of time the standard library won't be copied.
1142-
Arguments.push_back("-Xlinker");
1143-
Arguments.push_back("-rpath");
1144-
Arguments.push_back("-Xlinker");
1145-
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
1146-
11471149
// Always add the stdlib
11481150
Arguments.push_back("-lswiftCore");
11491151

0 commit comments

Comments
 (0)