[Serialization] Restrict loading swiftmodule files to the builder's SDK

Serialize the canonical name of the SDK used when building a swiftmodule
file and use it to ensure that the swiftmodule file is loaded only with
the same SDK. The SDK name must be passed down from the frontend.

This will report unsupported configurations like:

- Installing roots between incompatible SDKs without deleting the
swiftmodule files.
- Having multiple targets in the same project using different SDKs.
- Loading a swiftmodule created with a newer SDK (and stdlib) with an
older SDK.

All of these lead to hard to investigate deserialization failures and
this change should detect them early, before reaching a deserialization
failure.

rdar://78048939
This commit is contained in:
Alexis Laferrière
2021-06-01 16:57:40 -07:00
parent 7c653e4fec
commit c38d1773d2
16 changed files with 85 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ namespace swift {
bool SkipSymbolGraphInheritedDocs = true;
bool IncludeSPISymbolsInSymbolGraph = false;
llvm::VersionTuple UserModuleVersion;
std::string SDKName;
StringRef GroupInfoPath;
StringRef ImportedHeader;