Serialization: restrict swiftmodules to distribution channels

There are scenarios where different compilers are distributed with
compatible serialization format versions and the same tag. Distinguish
swiftmodules in such a case by assigning them to different distribution
channels. A compiler expecting a specific channel will only read
swiftmodules from the same channel. The channels should be defined by
downstream code as it is by definition vendor specific.

For development, a no-channel compiler loads or defining the env var
SWIFT_IGNORE_SWIFTMODULE_REVISION skips this new check.

rdar://123731777
This commit is contained in:
Alexis Laferrière
2024-02-29 17:48:34 -08:00
parent ffc2d9f9a7
commit 1e4fe67f40
10 changed files with 149 additions and 1 deletions

View File

@@ -313,6 +313,16 @@ StringRef getCurrentCompilerSerializationTag() {
#endif
}
StringRef getCurrentCompilerChannel() {
static const char* forceDebugChannel =
::getenv("SWIFT_FORCE_SWIFTMODULE_CHANNEL");
if (forceDebugChannel)
return forceDebugChannel;
// Leave it to downstream compilers to define the different channels.
return StringRef();
}
unsigned getUpcomingCxxInteropCompatVersion() {
return SWIFT_VERSION_MAJOR + 1;
}