[Serialization] Intro distinct compiler revision string for serialization

This commit is contained in:
Alexis Laferrière
2023-02-13 12:51:48 -08:00
parent 3d8e60d83e
commit 4579e37e61
4 changed files with 16 additions and 3 deletions

View File

@@ -167,9 +167,14 @@ StringRef getSwiftRevision();
/// and \c getCurrentCompilerTag returns the version tuple in string format.
bool isCurrentCompilerTagged();
/// Retrieves the distribtion tag of the running compiler, if any.
/// Retrieves the distribution tag of the running compiler, if any.
StringRef getCurrentCompilerTag();
/// Retrieves the distribution tag of the running compiler for serialization,
/// if any. This can hold more information than \c getCurrentCompilerTag
/// depending on the vendor.
StringRef getCurrentCompilerSerializationTag();
} // end namespace version
} // end namespace swift

View File

@@ -297,5 +297,13 @@ StringRef getCurrentCompilerTag() {
#endif
}
StringRef getCurrentCompilerSerializationTag() {
#ifdef SWIFT_COMPILER_VERSION
return SWIFT_COMPILER_VERSION;
#else
return StringRef();
#endif
}
} // end namespace version
} // end namespace swift

View File

@@ -370,7 +370,7 @@ static ValidationInfo validateControlBlock(
if (forcedDebugRevision ||
(requiresRevisionMatch && version::isCurrentCompilerTagged())) {
StringRef compilerRevision = forcedDebugRevision ?
forcedDebugRevision : version::getCurrentCompilerTag();
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
if (moduleRevision != compilerRevision) {
result.status = Status::RevisionIncompatible;

View File

@@ -1011,7 +1011,7 @@ void Serializer::writeHeader(const SerializationOptions &options) {
static const char* forcedDebugRevision =
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_REVISION");
auto revision = forcedDebugRevision ?
forcedDebugRevision : version::getCurrentCompilerTag();
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
Revision.emit(ScratchRecord, revision);
IsOSSA.emit(ScratchRecord, options.IsOSSA);