[Serialization] Allow either hash-based or mtime-based deps

Add a bit to the module to determine whether the dependency’s stored bit pattern is a hash or an mtime.

Prebuilt modules store a hash of their dependencies because we can’t be sure their dependencies will have the same modtime as when they were built.
This commit is contained in:
Harlan Haskins
2019-02-13 17:24:24 -08:00
parent 0d951bf3db
commit 7d71579950
5 changed files with 160 additions and 31 deletions

View File

@@ -252,10 +252,19 @@ static bool validateInputBlock(
StringRef blobData;
unsigned kind = cursor.readRecord(entry.ID, scratch, &blobData);
switch (kind) {
case input_block::FILE_DEPENDENCY:
dependencies.push_back(SerializationOptions::FileDependency{
scratch[0], scratch[1], blobData});
case input_block::FILE_DEPENDENCY: {
bool isHashBased = scratch[2] != 0;
if (isHashBased) {
dependencies.push_back(
SerializationOptions::FileDependency::hashBased(
blobData, scratch[0], scratch[1]));
} else {
dependencies.push_back(
SerializationOptions::FileDependency::modTimeBased(
blobData, scratch[0], scratch[1]));
}
break;
}
default:
// Unknown metadata record, possibly for use by a future version of the
// module format.