@@ -57,7 +57,7 @@ class ModuleDependenciesCacheDeserializer {
57
57
// These return true if there was an error.
58
58
bool readSignature ();
59
59
bool enterGraphBlock ();
60
- bool readMetadata ();
60
+ bool readMetadata (StringRef scannerContextHash );
61
61
bool readGraph (ModuleDependenciesCache &cache);
62
62
63
63
std::optional<std::string> getIdentifier (unsigned n);
@@ -143,7 +143,7 @@ bool ModuleDependenciesCacheDeserializer::enterGraphBlock() {
143
143
144
144
// / Read in the serialized file's format version, error/exit if not matching
145
145
// / current version.
146
- bool ModuleDependenciesCacheDeserializer::readMetadata () {
146
+ bool ModuleDependenciesCacheDeserializer::readMetadata (StringRef scannerContextHash ) {
147
147
using namespace graph_block ;
148
148
149
149
auto entry = Cursor.advance ();
@@ -165,12 +165,14 @@ bool ModuleDependenciesCacheDeserializer::readMetadata() {
165
165
return true ;
166
166
167
167
unsigned majorVersion, minorVersion;
168
-
169
168
MetadataLayout::readRecord (Scratch, majorVersion, minorVersion);
170
169
if (majorVersion != MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR ||
171
- minorVersion != MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR) {
170
+ minorVersion != MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR)
171
+ return true ;
172
+
173
+ std::string readScannerContextHash = BlobData.str ();
174
+ if (readScannerContextHash != scannerContextHash)
172
175
return true ;
173
- }
174
176
175
177
return false ;
176
178
}
@@ -815,7 +817,7 @@ bool ModuleDependenciesCacheDeserializer::readInterModuleDependenciesCache(
815
817
if (enterGraphBlock ())
816
818
return true ;
817
819
818
- if (readMetadata ())
820
+ if (readMetadata (cache. scannerContextHash ))
819
821
return true ;
820
822
821
823
if (readGraph (cache))
@@ -1123,7 +1125,7 @@ class ModuleDependenciesCacheSerializer {
1123
1125
void writeSignature ();
1124
1126
void writeBlockInfoBlock ();
1125
1127
1126
- void writeMetadata ();
1128
+ void writeMetadata (StringRef scanningContextHash );
1127
1129
void writeIdentifiers ();
1128
1130
void writeArraysOfIdentifiers ();
1129
1131
@@ -1210,14 +1212,13 @@ void ModuleDependenciesCacheSerializer::writeSignature() {
1210
1212
Out.Emit ((unsigned )c, 8 );
1211
1213
}
1212
1214
1213
- void ModuleDependenciesCacheSerializer::writeMetadata () {
1215
+ void ModuleDependenciesCacheSerializer::writeMetadata (StringRef scanningContextHash ) {
1214
1216
using namespace graph_block ;
1215
-
1216
1217
MetadataLayout::emitRecord (Out, ScratchRecord,
1217
1218
AbbrCodes[MetadataLayout::Code],
1218
1219
MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR,
1219
1220
MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR,
1220
- version::getSwiftFullVersion () );
1221
+ scanningContextHash );
1221
1222
}
1222
1223
1223
1224
void ModuleDependenciesCacheSerializer::writeIdentifiers () {
@@ -1896,7 +1897,7 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
1896
1897
collectStringsAndArrays (cache);
1897
1898
1898
1899
// Write the version information
1899
- writeMetadata ();
1900
+ writeMetadata (cache. scannerContextHash );
1900
1901
1901
1902
// Write the strings
1902
1903
writeIdentifiers ();
0 commit comments