Skip to content

Commit ad3c773

Browse files
authored
Merge pull request #10381 from keith/ks/no-linking-rpath
Don't add rpath to swift with statically linking.
2 parents 0a55ddd + 408c38f commit ad3c773

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,10 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
12671267
Arguments.push_back("-force_load_swift_libs");
12681268
} else {
12691269
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
1270+
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1271+
// of time the standard library won't be copied. SR-1967
1272+
Arguments.push_back("-rpath");
1273+
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
12701274
}
12711275

12721276
if (context.Args.hasArg(options::OPT_profile_generate)) {
@@ -1305,11 +1309,6 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
13051309
Arguments.push_back(context.Args.MakeArgString(LibProfile));
13061310
}
13071311

1308-
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
1309-
// of time the standard library won't be copied.
1310-
Arguments.push_back("-rpath");
1311-
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
1312-
13131312
// FIXME: Properly handle deployment targets.
13141313
assert(Triple.isiOS() || Triple.isWatchOS() || Triple.isMacOSX());
13151314
if (Triple.isiOS()) {

test/Driver/linker.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// RUN: %FileCheck %s < %t.simple.txt
33
// RUN: %FileCheck -check-prefix SIMPLE %s < %t.simple.txt
44

5+
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -static-stdlib %s 2>&1 > %t.simple.txt
6+
// RUN: %FileCheck -check-prefix SIMPLE_STATIC -implicit-check-not -rpath %s < %t.simple.txt
7+
58
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-ios7.1 %s 2>&1 > %t.simple.txt
69
// RUN: %FileCheck -check-prefix IOS_SIMPLE %s < %t.simple.txt
710

@@ -69,6 +72,23 @@
6972
// SIMPLE: -o linker
7073

7174

75+
// SIMPLE_STATIC: swift
76+
// SIMPLE_STATIC: -o [[OBJECTFILE:.*]]
77+
78+
// SIMPLE_STATIC-NEXT: bin/ld{{"? }}
79+
// SIMPLE_STATIC: [[OBJECTFILE]]
80+
// SIMPLE_STATIC: -lobjc
81+
// SIMPLE_STATIC: -lSystem
82+
// SIMPLE_STATIC: -arch x86_64
83+
// SIMPLE_STATIC: -L [[STDLIB_PATH:[^ ]+/lib/swift_static/macosx]]
84+
// SIMPLE_STATIC: -lc++
85+
// SIMPLE_STATIC: -framework Foundation
86+
// SIMPLE_STATIC: -force_load_swift_libs
87+
// SIMPLE_STATIC: -macosx_version_min 10.{{[0-9]+}}.{{[0-9]+}}
88+
// SIMPLE_STATIC: -no_objc_category_merging
89+
// SIMPLE_STATIC: -o linker
90+
91+
7292
// IOS_SIMPLE: swift
7393
// IOS_SIMPLE: -o [[OBJECTFILE:.*]]
7494

0 commit comments

Comments
 (0)