@@ -839,6 +839,12 @@ class ParseableInterfaceModuleLoaderImpl {
839
839
return scratch.str ();
840
840
}
841
841
842
+ bool isInResourceDir (StringRef path) {
843
+ StringRef resourceDir = ctx.SearchPathOpts .RuntimeLibraryPath ;
844
+ if (resourceDir.empty ()) return false ;
845
+ return path.startswith (resourceDir);
846
+ }
847
+
842
848
// / Finds the most appropriate .swiftmodule, whose dependencies are up to
843
849
// / date, that we can load for the provided .swiftinterface file.
844
850
llvm::ErrorOr<DiscoveredModule> discoverUpToDateModuleForInterface (
@@ -944,6 +950,21 @@ class ParseableInterfaceModuleLoaderImpl {
944
950
<< modulePath
945
951
<< " ; deferring to serialized module loader\n " );
946
952
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);
947
968
} else {
948
969
LLVM_DEBUG (llvm::dbgs () << " Found out-of-date module at "
949
970
<< modulePath << " \n " );
0 commit comments