Skip to content

Have the frontend and new swift-driver look in an external -sdk for non-Darwin platform runtime libraries and modules too #79621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
WARNING(warning_no_such_sdk,none,
"no such SDK: '%0'", (StringRef))

WARNING(warning_no_resource_dir_in_sdk, none,
"You passed in an external -sdk without a Swift runtime.\n"
" Either specify a directory containing the runtime libraries with\n"
" the -resource-dir flag, or use -sysroot instead to point at a C/C++\n"
" sysroot alone. Falling back to this path for the Swift runtime modules\n"
" and libraries:\n"
" %0", (StringRef))
ERROR(error_no_frontend_args, none,
"no arguments provided to '-frontend'", ())

Expand Down
4 changes: 2 additions & 2 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,8 @@ void importer::getNormalInvocationArguments(
invocationArgStrs.push_back("-fapinotes-swift-version=" +
languageVersion.asAPINotesVersionString());

// Prefer `-sdk` paths.
if (!searchPathOpts.getSDKPath().empty()) {
// Prefer `-sdk` paths for Darwin.
if (triple.isOSDarwin() && !searchPathOpts.getSDKPath().empty()) {
llvm::SmallString<261> path{searchPathOpts.getSDKPath()};
llvm::sys::path::append(path, "usr", "lib", "swift", "apinotes");

Expand Down
15 changes: 14 additions & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@ static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModule

static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
DiagnosticEngine &Diags,
const llvm::Triple &Triple,
const CASOptions &CASOpts,
const FrontendOptions &FrontendOpts,
StringRef workingDirectory) {
Expand Down Expand Up @@ -2416,6 +2417,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,

if (const Arg *A = Args.getLastArg(OPT_resource_dir))
Opts.RuntimeResourcePath = A->getValue();
else if (!Triple.isOSDarwin() && Args.hasArg(OPT_sdk)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code explicitly follows what the original C++ Driver has long done when looking for the Swift runtime libraries, swiftrt.o, and a few other files found in the Swift resource directory:

if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) {
    StringRef value = A->getValue();
    resourceDirPath.append(value.begin(), value.end());
  } else if (!getTriple().isOSDarwin() && args.hasArg(options::OPT_sdk)) {
    StringRef value = args.getLastArg(options::OPT_sdk)->getValue();
    resourceDirPath.append(value.begin(), value.end());
    llvm::sys::path::append(resourceDirPath, "usr");
    CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared);
  } else {
    auto programPath = getDriver().getSwiftProgramPath();
    CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
        programPath, shared, resourceDirPath);
  }

Note how the SDK is only looked in if a non-Darwin -sdk is explicitly specified: Saleem later tried to expand that to Darwin also in #26361, but he may have never got it to work.

That C++ Driver setup now matches this Frontend setup, because the default in both is now to look relative to the compiler, which is done first in this Frontend here, ie usr/bin/../lib/swift/. If a -resource-dir is set, that is given first priority, then a non-Darwin -sdk is given second priority, ie the C++ Driver and the Frontend now match in where they look.

This is important for two reasons:

  1. The new swift-driver simply queries the Frontend and uses whatever Swift resource directory it uses, so now the new swift-driver finally matches the original C++ Driver's behavior, and piecemeal workarounds like that in [Unix] Go back to only checking the runtime resource path for swiftrt.o swift-driver#1822 can now be eliminated.
  2. The Frontend will now look in the same Swift resource directory for stdlib/corelibs swiftmodules as the swift-driver is looking for runtime libraries and swiftrt.o, eliminating any confusion between the two by centralizing the Swift resource directory lookup here. That already found one bug in the Windows CI, see my other code comment.

However, unlike the C++ Driver, my -sdk code below actually checks if the -sdk path contains a Swift resource directory for the platform triple and does not use the -sdk for this if not, falling back to the aforementioned default next to the compiler in that case. This is because an -sdk is not guaranteed to have a Swift resource directory and may have only a C/C++ sysroot.

We should probably tighten this up to require an explicit -sdk to have a Swift resource directory, with the only exception when an explicit -resource-dir is also specified, but I'm open to debate here. The C++ Driver doesn't even check if the non-Darwin -sdk has a Swift resource directory and simply assumes one is there, we can do a bit better than that.

llvm::SmallString<128> SDKResourcePath(Opts.getSDKPath());
llvm::sys::path::append(
SDKResourcePath, "usr", "lib",
FrontendOpts.UseSharedResourceFolder ? "swift" : "swift_static");
// Check for eg <sdkRoot>/usr/lib/swift/
if (llvm::sys::fs::exists(SDKResourcePath))
Opts.RuntimeResourcePath = SDKResourcePath.str();
else
Diags.diagnose(SourceLoc(), diag::warning_no_resource_dir_in_sdk,
Opts.RuntimeResourcePath);
}

Opts.SkipAllImplicitImportPaths |= Args.hasArg(OPT_nostdimport);
Opts.SkipSDKImportPaths |= Args.hasArg(OPT_nostdlibimport);
Expand Down Expand Up @@ -4075,7 +4088,7 @@ bool CompilerInvocation::parseArgs(

ParseSymbolGraphArgs(SymbolGraphOpts, ParsedArgs, Diags, LangOpts);

if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags,
if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags, LangOpts.Target,
CASOpts, FrontendOpts, workingDirectory)) {
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion test/ClangImporter/sdk-apinotes.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify
// RUN: %empty-directory(%t/sdk/usr/lib/swift/apinotes)
// RUN: %empty-directory(%t/sdk/usr/lib/swift/%target-sdk-name)
// RUN: cp -r %clang-importer-sdk-path/usr/include %t/sdk/usr
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift
// RUN: cp %S/Inputs/cfuncs.apinotes %t/sdk/usr/lib/swift/apinotes
// RUN: cp -r %platform-module-dir/Swift.swiftmodule %t/sdk/usr/lib/swift/%target-sdk-name/
// RUN: %target-swift-frontend(mock-sdk: -sdk %t/sdk) -typecheck %s -verify -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import

import cfuncs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
// RUN: %empty-directory(%t/sdk/usr/lib/swift/%target-sdk-name)
// RUN: cp -r %platform-module-dir/{_Concurrency,_StringProcessing,Swift,SwiftOnoneSupport}.swiftmodule %t/sdk/usr/lib/swift/%target-sdk-name/
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift

// 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
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name Normal
// 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
// 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

Expand All @@ -12,14 +15,14 @@
// CHECK-DAG: Flat.swiftmodule
// CHECK-DAG: FMWK.swiftmodule

// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/{Normal,Flat,FMWK}-*.swiftmodule

// Touch a file in the SDK (to make it look like it changed) and try again.
// In -check-only mode, this should force a rebuild.
// RUN: rm -rf %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule

import Normal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
// RUN: %empty-directory(%t/sdk/usr/lib/swift/%target-sdk-name)
// RUN: cp -r %platform-module-dir/{_Concurrency,_StringProcessing,Swift,SwiftOnoneSupport}.swiftmodule %t/sdk/usr/lib/swift/%target-sdk-name/
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift

// 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
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name Normal
// 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
// 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

Expand All @@ -12,17 +15,17 @@
// CHECK-DAG: Flat.swiftmodule
// CHECK-DAG: FMWK.swiftmodule

// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/{FMWK,Flat,Normal}-*.swiftmodule

// Touch a file in the SDK (to make it look like it changed) and try again.
// This should still be able to use the prebuilt modules because they track
// content hashes, not just size+mtime.
// RUN: rm -rf %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/{FMWK,Flat,Normal}-*.swiftmodule

// CHECK-CACHE-DAG: Normal-{{.+}}.swiftmodule
// CHECK-CACHE-DAG: Flat-{{.+}}.swiftmodule
Expand All @@ -31,8 +34,8 @@
// Actually change a file in the SDK, to check that we're tracking dependencies
// at all.
// RUN: rm -rf %t/MCP
// RUN: echo "public func another()" >> %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: echo "public func another()" >> %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: env SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH=%t/prebuilt %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
Expand All @@ -41,7 +44,7 @@
// Without the prebuilt cache everything should still work; it'll just take time
// because we have to build the interfaces.
// RUN: rm -rf %t/MCP
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
// RUN: %empty-directory(%t/sdk/usr/lib/swift/%target-sdk-name)
// RUN: cp -r %platform-module-dir/{_Concurrency,_StringProcessing,Swift,SwiftOnoneSupport}.swiftmodule %t/sdk/usr/lib/swift/%target-sdk-name/
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift

// 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
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name Normal
// 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
// 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

Expand All @@ -12,17 +15,17 @@
// CHECK-DAG: Flat.swiftmodule
// CHECK-DAG: FMWK.swiftmodule

// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/{FMWK,Flat,Normal}-*.swiftmodule

// Touch a file in the SDK (to make it look like it changed) and try again.
// This should still be able to use the prebuilt modules because they track
// content hashes, not just size+mtime.
// RUN: rm -rf %t/MCP
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/{FMWK,Flat,Normal}-*.swiftmodule

// CHECK-CACHE-DAG: Normal-{{.+}}.swiftmodule
// CHECK-CACHE-DAG: Flat-{{.+}}.swiftmodule
Expand All @@ -31,8 +34,8 @@
// Actually change a file in the SDK, to check that we're tracking dependencies
// at all.
// RUN: rm -rf %t/MCP
// RUN: echo "public func another()" >> %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: echo "public func another()" >> %t/sdk/System/iOSSupport/usr/lib/swift/Normal.swiftmodule/%target-swiftinterface-name
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
Expand All @@ -41,7 +44,7 @@
// Without the prebuilt cache everything should still work; it'll just take time
// because we have to build the interfaces.
// RUN: rm -rf %t/MCP
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -I %t/sdk/System/iOSSupport/usr/lib/swift/ -module-cache-path %t/MCP
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/system-dependencies-sdk %t/sdk
// RUN: %empty-directory(%t/sdk/usr/lib/swift/%target-sdk-name)
// RUN: cp -r %platform-module-dir/{_Concurrency,_StringProcessing,Swift,SwiftOnoneSupport}.swiftmodule %t/sdk/usr/lib/swift/%target-sdk-name/
// RUN: cp -r %test-resource-dir/shims %t/sdk/usr/lib/swift
// RUN: echo 'import Platform; public func usesCStruct(_: SomeCStruct?) {}' | %target-swift-frontend - -emit-module-interface-path %t/sdk/usr/lib/swift/Swifty.swiftmodule/%target-swiftinterface-name -emit-module -o /dev/null -module-name Swifty -sdk %t/sdk

// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -v -o %t/prebuilt
// RUN: ls %t/prebuilt | %FileCheck %s
// CHECK: Swifty.swiftmodule

// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Swifty-*.swiftmodule

// Touch a file in the SDK (to make it look like it changed) and try again.
// This should still be able to use the prebuilt modules because they track
Expand Down
Loading