Skip to content

Commit 4579e37

Browse files
committed
[Serialization] Intro distinct compiler revision string for serialization
1 parent 3d8e60d commit 4579e37

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

include/swift/Basic/Version.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ StringRef getSwiftRevision();
167167
/// and \c getCurrentCompilerTag returns the version tuple in string format.
168168
bool isCurrentCompilerTagged();
169169

170-
/// Retrieves the distribtion tag of the running compiler, if any.
170+
/// Retrieves the distribution tag of the running compiler, if any.
171171
StringRef getCurrentCompilerTag();
172172

173+
/// Retrieves the distribution tag of the running compiler for serialization,
174+
/// if any. This can hold more information than \c getCurrentCompilerTag
175+
/// depending on the vendor.
176+
StringRef getCurrentCompilerSerializationTag();
177+
173178
} // end namespace version
174179
} // end namespace swift
175180

lib/Basic/Version.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,5 +297,13 @@ StringRef getCurrentCompilerTag() {
297297
#endif
298298
}
299299

300+
StringRef getCurrentCompilerSerializationTag() {
301+
#ifdef SWIFT_COMPILER_VERSION
302+
return SWIFT_COMPILER_VERSION;
303+
#else
304+
return StringRef();
305+
#endif
306+
}
307+
300308
} // end namespace version
301309
} // end namespace swift

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static ValidationInfo validateControlBlock(
370370
if (forcedDebugRevision ||
371371
(requiresRevisionMatch && version::isCurrentCompilerTagged())) {
372372
StringRef compilerRevision = forcedDebugRevision ?
373-
forcedDebugRevision : version::getCurrentCompilerTag();
373+
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
374374
if (moduleRevision != compilerRevision) {
375375
result.status = Status::RevisionIncompatible;
376376

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ void Serializer::writeHeader(const SerializationOptions &options) {
10111011
static const char* forcedDebugRevision =
10121012
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_REVISION");
10131013
auto revision = forcedDebugRevision ?
1014-
forcedDebugRevision : version::getCurrentCompilerTag();
1014+
forcedDebugRevision : version::getCurrentCompilerSerializationTag();
10151015
Revision.emit(ScratchRecord, revision);
10161016

10171017
IsOSSA.emit(ScratchRecord, options.IsOSSA);

0 commit comments

Comments
 (0)