Skip to content
Open
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()) {
Copy link
Member

Choose a reason for hiding this comment

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

Wait, why are we not preferring -sdk paths?

Copy link
Member Author

Choose a reason for hiding this comment

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

Once the Frontend change is made for non-Darwin, the RuntimeResourcePath in the very next block has been set to <-sdk>/usr/lib/swift, so this explicit getSDKPath() check is not needed when targeting non-Darwin. 😺

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 @@ -2319,6 +2319,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 @@ -2453,6 +2454,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,

if (const Arg *A = Args.getLastArg(OPT_resource_dir))
Opts.RuntimeResourcePath = A->getValue();
Copy link
Member Author

Choose a reason for hiding this comment

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

@etcwilde, just so it's clear what I'm talking about, -resource-dir is used to set RuntimeResourcePath. This flag is pretty much mandatory to cross-compile Swift today, all cross-compilation SDK bundles set it. The goal with the logic below is to make it possible to not pass the -resource-dir flag if -sdk contains those files instead, which is where the new cross-compilation model doc, that you co-authored and approved, says they should be.

If you guys have changed your mind on what that doc says, please let us know what the new plan is.

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();
Copy link
Member

Choose a reason for hiding this comment

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

This line confuses me. The compiler resource dir should be relative to the compiler. Updating it to point into the SDK seems suspicious to me.

  /// Path to search for compiler-relative header files.
  std::string RuntimeResourcePath;

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, the -resource-dir flag is used to pass in the location of the Swift runtime libraries, modules, and some Swift-related headers for cross-compilation to a platform. It is pretty much required for cross-compilation to work, so all SDK bundles pass it in (I know Windows got it to work without that flag, but they do so by adding more than a half-dozen other flags to replace it, which is not workable).

This change brings back what the legacy C++ Driver did, which is look in the -sdk for those files, so you could sometimes not pass in -resource-dir when that was the default Driver.

I know that you would like to split up the -resource-dir/RuntimeResourcePath as it's currently defined, into some compiler-related files and some SDK-related files, but that has never been explicitly specified, let alone implemented.

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 @@ -4142,7 +4155,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
9 changes: 8 additions & 1 deletion test/ClangImporter/sdk-apinotes.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify
// RUN: %empty-directory(%t/sdk)
// 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,16 @@
// 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-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.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,21 @@
// 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-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/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-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule

// CHECK-CACHE-DAG: Normal-{{.+}}.swiftmodule
// CHECK-CACHE-DAG: Flat-{{.+}}.swiftmodule
Expand All @@ -31,8 +38,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 +48,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,21 @@
// 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-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/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-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule

// CHECK-CACHE-DAG: Normal-{{.+}}.swiftmodule
// CHECK-CACHE-DAG: Flat-{{.+}}.swiftmodule
Expand All @@ -31,8 +38,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 +48,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
Loading