mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Allow loading modules built on some SDK variants
When restricting loading swiftmodules to the SDK used to build them, an exception should be made for modules built against an SDK that is a subset of the SDK used when loading the module. In such a case, the swiftmodule file is more reliable. rdar://92827584
This commit is contained in:
@@ -156,11 +156,18 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
|
||||
return error(status);
|
||||
}
|
||||
|
||||
// The loaded module was built with a compatible SDK if either:
|
||||
// * it was the same SDK
|
||||
// * or one who's name is a prefix of the clients' SDK name. This expects
|
||||
// that a module built with macOS11 can be used with the macOS11.secret SDK.
|
||||
// This is generally the case as SDKs with suffixes are a superset of the
|
||||
// short SDK name equivalent. While this is accepted, this is still not a
|
||||
// recommended configuration and may lead to unreadable swiftmodules.
|
||||
StringRef moduleSDK = Core->SDKName;
|
||||
StringRef clientSDK = ctx.LangOpts.SDKName;
|
||||
if (ctx.SearchPathOpts.EnableSameSDKCheck &&
|
||||
!moduleSDK.empty() && !clientSDK.empty() &&
|
||||
moduleSDK != clientSDK) {
|
||||
!clientSDK.startswith(moduleSDK)) {
|
||||
status = Status::SDKMismatch;
|
||||
return error(status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user