Skip to content

Commit 0110c1c

Browse files
committed
---
yaml --- r: 347199 b: refs/heads/master c: 32dbf26 h: refs/heads/master i: 347197: 90310c8 347195: 73d2e86 347191: 4c20aa7 347183: cc4a4a8 347167: ccb3050 347135: a433ebe
1 parent ec79395 commit 0110c1c

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 23a708b7752841ed841b70d062dfd6e00d488436
2+
refs/heads/master: 32dbf26869aa3c0420abbd46800dc99a80d6d6b8
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/ClangImporter/ClangImporter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
424424
});
425425
}
426426

427+
// If there are no shims in the resource dir, add a search path in the SDK.
428+
SmallString<128> shimsPath(searchPathOpts.RuntimeResourcePath);
429+
llvm::sys::path::append(shimsPath, "shims");
430+
if (!llvm::sys::fs::exists(shimsPath)) {
431+
shimsPath = searchPathOpts.SDKPath;
432+
llvm::sys::path::append(shimsPath, "usr", "lib", "swift", "shims");
433+
invocationArgStrs.insert(invocationArgStrs.end(), {
434+
"-isystem", shimsPath.str()
435+
});
436+
}
437+
427438
// Construct the invocation arguments for the current target.
428439
// Add target-independent options first.
429440
invocationArgStrs.insert(invocationArgStrs.end(), {

trunk/test/Serialization/runtime-import-from-sdk.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,26 @@
55
// resource directory will contain a swiftmodule for the standard library.
66

77
// %t/good-sdk contains a loadable standard library.
8+
// RUN: %empty-directory(%t/good-sdk)
89
// RUN: %empty-directory(%t/good-sdk/usr/lib/swift)
910
// RUN: cp -r %platform-module-dir/Swift.swiftmodule %t/good-sdk/usr/lib/swift/Swift.swiftmodule
1011

1112
// %t/bad-sdk contains an invalid standard library that cannot be loaded.
13+
// RUN: %empty-directory(%t/bad-sdk)
1214
// RUN: %empty-directory(%t/bad-sdk/usr/lib/swift/Swift.swiftmodule)
1315
// RUN: touch %t/bad-sdk/usr/lib/swift/Swift.swiftmodule/garbage-garbage-garbage.swiftmodule
1416

1517
// %t/empty-toolchain does not contain a standard library.
18+
// RUN: %empty-directory(%t/empty-toolchain)
1619
// RUN: %empty-directory(%t/empty-toolchain/usr/lib/swift)
1720

1821
// FIXME: Until we have private imports, we need SwiftShims in the toolchain.
1922
// RUN: cp -r %test-resource-dir/shims %t/empty-toolchain/usr/lib/swift/shims
2023

24+
// %t/really-empty-toolchain does not contain a standard library or SwiftShims.
25+
// RUN: %empty-directory(%t/really-empty-toolchain)
26+
// RUN: %empty-directory(%t/really-empty-toolchain/usr/lib/swift)
27+
2128
// If the compiler's resource directory does not contain a runtime swiftmodule,
2229
// we should fall back to the SDK.
2330

@@ -34,14 +41,26 @@
3441
// If neither the resource directory nor the SDK contains a runtime swiftmodule,
3542
// loading should fail. This just proves that we aren't getting runtime imports
3643
// some other way.
44+
//
45+
// We also check that ClangImporter noticed SwiftShims in the toolchain and
46+
// didn't add a -isystem flag to look in the SDK.
3747

3848
// FIXME: We can't properly test this on a non-Darwin platform because we'll get
3949
// the same error message for "unloadable standard library" and "no standard
4050
// library". (SR-10097)
4151
// REQUIRES: objc_interop
4252

4353
// RUN: %empty-directory(%t/mcp)
44-
// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-sdk) -resource-dir %t/empty-toolchain/usr/lib/swift -module-cache-path %t/mcp -typecheck %s 2>&1 | %FileCheck %s
45-
// CHECK: error: could not find module 'Swift' for target '{{.*}}'; found: garbage-garbage-garbage
54+
// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-sdk) -resource-dir %t/empty-toolchain/usr/lib/swift -module-cache-path %t/mcp -typecheck %s -dump-clang-diagnostics 2>&1 | %FileCheck --check-prefix CHECK-EMPTY %s
55+
// CHECK-EMPTY-NOT: '-isystem' '{{.*}}/bad-sdk/usr/lib/swift/shims'
56+
// CHECK-EMPTY: error: could not find module 'Swift' for target '{{.*}}'; found: garbage-garbage-garbage
57+
58+
// Check that, when the toolchain *doesn't* have SwiftShims in it, ClagImporter
59+
// *does* add a -I flag to look in the SDK.
60+
61+
// RUN: %empty-directory(%t/mcp)
62+
// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-sdk) -resource-dir %t/really-empty-toolchain/usr/lib/swift -module-cache-path %t/mcp -typecheck %s -dump-clang-diagnostics 2>&1 | %FileCheck --check-prefix CHECK-REALLY-EMPTY %s
63+
// CHECK-REALLY-EMPTY: '-isystem' '{{.*}}/bad-sdk/usr/lib/swift/shims'
64+
// CHECK-REALLY-EMPTY: error: could not find module 'Swift' for target '{{.*}}'; found: garbage-garbage-garbage
4665

4766
let x: Int = 1

0 commit comments

Comments
 (0)