[Serialization] Only remark if the last digit mismatches in precise tag check

Weaken the precise tag check at loading swiftmodule to accept binary
modules build by a compiler with a tag where only the last digit is
different. We assume that the other digit in the version should ensure
compiler and stdlib compatibility. If the last digit doesn't match,
still raise a remark.

rdar://105158258
This commit is contained in:
Alexis Laferrière
2023-02-13 12:56:07 -08:00
parent e079db233f
commit a5ccbf3264
5 changed files with 44 additions and 17 deletions

View File

@@ -372,10 +372,18 @@ static ValidationInfo validateControlBlock(
StringRef compilerRevision = forcedDebugRevision ?
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
if (moduleRevision != compilerRevision) {
result.status = Status::RevisionIncompatible;
// The module versions are mismatching, record it and diagnose later.
result.problematicRevision = moduleRevision;
// We can't trust this module format at this point.
return result;
// Reject the module only it still mismatches without the last digit.
StringRef compilerRevisionHead = compilerRevision.rsplit('.').first;
StringRef moduleRevisionHead = moduleRevision.rsplit('.').first;
if (moduleRevisionHead != compilerRevisionHead) {
result.status = Status::RevisionIncompatible;
// We can't trust the module format at this point.
return result;
}
}
}
break;