Skip to content

Commit ecdd879

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 70f59f0 + 84d96ad commit ecdd879

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Frontend/ParseableInterfaceModuleLoader.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,12 @@ class ParseableInterfaceModuleLoaderImpl {
839839
return scratch.str();
840840
}
841841

842+
bool isInResourceDir(StringRef path) {
843+
StringRef resourceDir = ctx.SearchPathOpts.RuntimeLibraryPath;
844+
if (resourceDir.empty()) return false;
845+
return path.startswith(resourceDir);
846+
}
847+
842848
/// Finds the most appropriate .swiftmodule, whose dependencies are up to
843849
/// date, that we can load for the provided .swiftinterface file.
844850
llvm::ErrorOr<DiscoveredModule> discoverUpToDateModuleForInterface(
@@ -944,6 +950,21 @@ class ParseableInterfaceModuleLoaderImpl {
944950
<< modulePath
945951
<< "; deferring to serialized module loader\n");
946952
return std::make_error_code(std::errc::not_supported);
953+
} else if (isInResourceDir(modulePath) &&
954+
loadMode == ModuleLoadingMode::PreferSerialized) {
955+
// Special-case here: If we're loading a .swiftmodule from the resource
956+
// dir adjacent to the compiler, defer to the serialized loader instead
957+
// of falling back. This is mainly to support development of Swift,
958+
// where one might change the module format version but forget to
959+
// recompile the standard library. If that happens, don't fall back
960+
// and silently recompile the standard library -- instead, error like
961+
// we used to.
962+
LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module in the "
963+
"resource-dir at "
964+
<< modulePath
965+
<< "; deferring to serialized module loader "
966+
"to diagnose\n");
967+
return std::make_error_code(std::errc::not_supported);
947968
} else {
948969
LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module at "
949970
<< modulePath << "\n");

test/ParseableInterface/inherited-defaults-execution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//
3232
// RUN: %target-build-swift -I%t -L%t -lInherited -o %t/main %target-rpath(%t) %t/main.swift -swift-version 5
3333
// RUN: %target-codesign %t/main %t/%target-library-name(Inherited)
34-
// RUN: %target-run %t/main | %FileCheck --check-prefix=OUTPUT %s
34+
// RUN: %target-run %t/main %t/%target-library-name(Inherited) | %FileCheck --check-prefix=OUTPUT %s
3535
//
3636
// OUTPUT: 45
3737
// OUTPUT-NEXT: 98

0 commit comments

Comments
 (0)