Skip to content

Commit 4458a18

Browse files
authored
Merge pull request swiftlang#31055 from xymus/note-misc-version
[Serialization] Note the misc version field of modules on deserialization failures
2 parents f62620f + 2fbc063 commit 4458a18

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ ERROR(serialization_fatal,Fatal,
751751
"fatal error encountered while reading from module '%0'; "
752752
"please file a bug report with your project and the crash log",
753753
(StringRef))
754+
NOTE(serialization_misc_version,none,
755+
"module '%0' full misc version is '%1'",
756+
(StringRef, StringRef))
754757
NOTE(serialization_compatibility_version_mismatch,none,
755758
"compiling as Swift %0, with '%1' built as Swift %2 "
756759
"(this is supported but may expose additional compiler issues)",

include/swift/Serialization/Validation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct ValidationInfo {
7777
StringRef name = {};
7878
StringRef targetTriple = {};
7979
StringRef shortVersion = {};
80+
StringRef miscVersion = {};
8081
version::Version compatibilityVersion = {};
8182
size_t bytes = 0;
8283
Status status = Status::Malformed;

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ static void skipRecord(llvm::BitstreamCursor &cursor, unsigned recordKind) {
167167
void ModuleFile::fatal(llvm::Error error) {
168168
if (FileContext) {
169169
getContext().Diags.diagnose(SourceLoc(), diag::serialization_fatal, Name);
170+
getContext().Diags.diagnose(SourceLoc(), diag::serialization_misc_version,
171+
Name, MiscVersion);
170172

171173
if (!CompatibilityVersion.empty()) {
172174
if (getContext().LangOpts.EffectiveLanguageVersion

lib/Serialization/ModuleFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
274274
break;
275275
}
276276

277+
result.miscVersion = blobData;
277278
versionSeen = true;
278279
break;
279280
}
@@ -1673,6 +1674,7 @@ ModuleFile::ModuleFile(
16731674
TargetTriple = info.targetTriple;
16741675
CompatibilityVersion = info.compatibilityVersion;
16751676
IsSIB = extInfo->isSIB();
1677+
MiscVersion = info.miscVersion;
16761678

16771679
hasValidControlBlock = true;
16781680
break;

lib/Serialization/ModuleFile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class ModuleFile
100100
/// modules, which are assumed to contain canonical SIL for an entire module.
101101
bool IsSIB = false;
102102

103+
// Full blob from the misc. version field of the metadata block. This should
104+
// include the version string of the compiler that built the module.
105+
StringRef MiscVersion;
106+
103107
public:
104108
/// Represents another module that has been imported as a dependency.
105109
class Dependency {

test/Serialization/Recovery/crash-recovery.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public class Sub: Base {
1313
}
1414

1515
// CHECK-CRASH: error: fatal error encountered while reading from module 'Lib'; please file a bug report with your project and the crash log
16-
// CHECK-CRASH-4-NOT: note
16+
// CHECK-CRASH: note: module 'Lib' full misc version is
17+
// CHECK-CRASH-4-NOT: note: compiling as
1718
// CHECK-CRASH-4_2: note: compiling as Swift 4.2, with 'Lib' built as Swift 4.1.50
1819
// CHECK-CRASH-LABEL: *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
1920
// CHECK-CRASH: could not find 'disappearingMethod()' in parent class

0 commit comments

Comments
 (0)