We change ASTFileSignature from a random 32-bit number to the actual SHA hash of the pcm content.
1> Definition of ASTFileSignature is moved to Basic/Module.h so Module and ASTSourceDescriptor can use it. Before this patch both are using uint64_t as the type of the signature.
2> Add DIAGNOSTIC_OPTIONS_BLOCK and make sure it is the last block of the pcm file. This block contains DIAGNOSTIC_OPTIONS and SIGNATURE.
We are using this patch to solve a PCH+Modules issue: PCH are handled by the build system and modules are handled by the compiler, when the compiler overwrites a pcm file with the same content except the diagnostic differences, we can still treat the PCH as valid and continue using it. This requires us not hashing the diagnostic differences. Moving the diagnostic differences to the end of the pcm makes the task easy:
In a few records, we save bit positions in the pcm file, if the size of the diagnostic options is different, the bit positions can be off. We only need to hash the content till the start of the DIAGNOSTIC_OPTIONS_BLOCK.
3> When we hash the pcm content, there is no point in saving the file size and modification time for the imported module file. The patch will use 0 for both. And the validation will not check the size differences or the modification time differences.
4> In GlobalModuleIndexBuilder, when the signature is non-zero, we check the signature instead of file size/modification time for imported modules.
5> Debug info has a 64-bit slot for dwo id, this patch uses the lower 64 bits of the SHA hash.
I want to gather some feedback on the general direction of this. Given that this is a big patch, I am open to separate it into smaller patches.
Cheers,
Manman
This comment is out of date. Maybe just point to the UnhashedControlBlockRecordTypes for the definitive list of records within this block?