Skip to content

Commit b67c6c5

Browse files
committed
Only enable -sdk changes for non-Darwin and use the right -sysroot flag on Windows
Also, disable Serialization/runtime-import-from-sdk again and try out a fix for the ModuleInterface/swift_build_sdk_interfaces/check-only-mode errors.
1 parent 7a3ace1 commit b67c6c5

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
271271
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
272272
}
273273

274-
if (!SearchPathOpts.SkipSDKImportPaths && !SearchPathOpts.getSDKPath().empty()) {
274+
if (!SearchPathOpts.SkipSDKImportPaths && Triple.isOSDarwin() && !SearchPathOpts.getSDKPath().empty()) {
275275
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
276276
? "swift" : "swift_static";
277277

@@ -284,18 +284,6 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
284284

285285
LibPath = SearchPathOpts.getSDKPath();
286286
llvm::sys::path::append(LibPath, "usr", "lib", swiftDir);
287-
if (!Triple.isOSDarwin()) {
288-
// Use the non-architecture suffixed form with directory-layout
289-
// swiftmodules.
290-
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
291-
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
292-
293-
// Compatibility with older releases - use the architecture suffixed form
294-
// for pre-directory-layout multi-architecture layout. Note that some
295-
// platforms (e.g. Windows) will use this even with directory layout in
296-
// older releases.
297-
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
298-
}
299287
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
300288
}
301289
SearchPathOpts.setRuntimeLibraryImportPaths(RuntimeLibraryImportPaths);
@@ -2411,7 +2399,7 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
24112399

24122400
if (const Arg *A = Args.getLastArg(OPT_resource_dir))
24132401
Opts.RuntimeResourcePath = A->getValue();
2414-
else if (Args.hasArg(OPT_sdk)) {
2402+
else if (!Triple.isOSDarwin() && Args.hasArg(OPT_sdk)) {
24152403
llvm::SmallString<128> SDKResourcePath(Opts.getSDKPath());
24162404
llvm::sys::path::append(
24172405
SDKResourcePath, "usr", "lib",

test/ModuleInterface/swift_build_sdk_interfaces/check-only-mode.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/sdk/usr/lib)
3+
// RUN: cp -r %test-resource-dir %t/sdk/usr/lib
4+
// RUN: rm -rf %t/sdk/usr/lib/swift/host
25
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
36
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
47

58
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name Normal
69
// RUN: echo 'public func flat() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/usr/lib/swift/Flat.swiftinterface -emit-module -o /dev/null -module-name Flat
710
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name FMWK
811

9-
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift
10-
// RUN: ln -s %platform-module-dir %t/sdk/usr/lib/swift
1112
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -v -o %t/prebuilt -check-only
1213
// RUN: ls %t/prebuilt | %FileCheck %s
1314
// CHECK-DAG: Normal.swiftmodule

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66

77
// %t/good-sdk contains a loadable standard library.
88
// RUN: %empty-directory(%t/good-sdk)
9-
// RUN: %empty-directory(%t/good-sdk/usr/lib/swift/%target-sdk-name)
9+
// RUN: %empty-directory(%t/good-sdk/usr/lib/swift)
1010
// RUN: cp -r %platform-module-dir/Swift.swiftmodule %t/good-sdk/usr/lib/swift/Swift.swiftmodule
11-
// RUN: cp -r %platform-module-dir/Swift.swiftmodule %t/good-sdk/usr/lib/swift/%target-sdk-name/Swift.swiftmodule
1211

1312
// %t/bad-sdk contains an invalid standard library that cannot be loaded.
1413
// RUN: %empty-directory(%t/bad-sdk)
1514
// RUN: %empty-directory(%t/bad-sdk/usr/lib/swift/Swift.swiftmodule)
16-
// RUN: %empty-directory(%t/bad-sdk/usr/lib/swift/%target-sdk-name/Swift.swiftmodule)
1715
// RUN: touch %t/bad-sdk/usr/lib/swift/Swift.swiftmodule/garbage-garbage-garbage.swiftmodule
18-
// RUN: touch %t/bad-sdk/usr/lib/swift/%target-sdk-name/Swift.swiftmodule/garbage-garbage-garbage.swiftmodule
1916

2017
// %t/empty-toolchain does not contain a standard library.
2118
// RUN: %empty-directory(%t/empty-toolchain)
@@ -48,6 +45,11 @@
4845
// We also check that ClangImporter noticed SwiftShims in the toolchain and
4946
// didn't add a -isystem flag to look in the SDK.
5047

48+
// FIXME: We can't properly test this on a non-Darwin platform because we'll get
49+
// the same error message for "unloadable standard library" and "no standard
50+
// library" (https://github.com/apple/swift/issues/52499).
51+
// REQUIRES: objc_interop
52+
5153
// RUN: %empty-directory(%t/mcp)
5254
// 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 -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import 2>&1 | %FileCheck --check-prefix CHECK-EMPTY %s
5355
// CHECK-EMPTY-NOT: '-isystem' '{{.*}}/bad-sdk/usr/lib/swift/shims'

0 commit comments

Comments
 (0)