File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -790,14 +790,18 @@ class ModuleInterfaceLoaderImpl {
790790 UsableModulePath = adjacentMod;
791791 return std::make_error_code (std::errc::not_supported);
792792 } else if (isInResourceDir (adjacentMod) &&
793- loadMode == ModuleLoadingMode::PreferSerialized) {
793+ loadMode == ModuleLoadingMode::PreferSerialized &&
794+ rebuildInfo.getOrInsertCandidateModule (adjacentMod).serializationStatus !=
795+ serialization::Status::SDKMismatch) {
794796 // Special-case here: If we're loading a .swiftmodule from the resource
795797 // dir adjacent to the compiler, defer to the serialized loader instead
796798 // of falling back. This is mainly to support development of Swift,
797799 // where one might change the module format version but forget to
798800 // recompile the standard library. If that happens, don't fall back
799801 // and silently recompile the standard library -- instead, error like
800802 // we used to.
803+ // Still accept modules built with a different SDK, allowing the use
804+ // of one toolchain against a different SDK.
801805 LLVM_DEBUG (llvm::dbgs () << " Found out-of-date module in the "
802806 " resource-dir at "
803807 << adjacentMod
Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ ValidationInfo serialization::validateSerializedAST(
544544 requiresOSSAModules, requiresRevisionMatch,
545545 requiredSDK,
546546 extendedInfo, localObfuscator);
547- if (result.status == Status::Malformed )
547+ if (result.status != Status::Valid )
548548 return result;
549549 } else if ((dependencies || searchPaths) &&
550550 result.status == Status::Valid &&
Original file line number Diff line number Diff line change 3434// RUN: -Rmodule-interface-rebuild 2>&1 | %FileCheck %s -check-prefix=CHECK-AvsB-REBUILD
3535// CHECK-AvsB-REBUILD: remark: rebuilding module 'Lib' from interface
3636
37+ /// Modules loaded from the resource dir are not usually rebuilt from
38+ /// the swiftinterface as it would indicate a configuration problem.
39+ /// Lift that behavior for SDK mismatch and still rebuild them.
40+ // RUN: %empty-directory(%t/cache)
41+ // RUN: %target-swift-frontend -emit-module %t/Lib.swift \
42+ // RUN: -swift-version 5 -enable-library-evolution \
43+ // RUN: -target-sdk-name A -parse-stdlib -module-cache-path %t/cache \
44+ // RUN: -o %t/build -emit-module-interface-path %t/build/Lib.swiftinterface
45+ // RUN: env SWIFT_DEBUG_FORCE_SWIFTMODULE_PER_SDK=true \
46+ // RUN: %target-swift-frontend -typecheck %t/Client.swift \
47+ // RUN: -target-sdk-name B -resource-dir %t/build -I %t/build \
48+ // RUN: -parse-stdlib -module-cache-path %t/cache \
49+ // RUN: -Rmodule-interface-rebuild 2>&1 | %FileCheck %s -check-prefix=CHECK-AvsB-REBUILD
50+
3751// BEGIN Lib.swift
3852public func foo( ) { }
3953
You can’t perform that action at this time.
0 commit comments