From 655bea4226b401a11164f99c6344e38d8742b8e4 Mon Sep 17 00:00:00 2001 From: Alexandre Rames Date: Fri, 3 Sep 2021 11:12:27 -0700 Subject: [modules] Use `HashBuilder` and `MD5` for the module hash. Per the comments, `hash_code` values "are not stable to save or persist", so are unsuitable for the module hash, which must persist across compilations for the implicit module hashes to match. Note that in practice, today, `hash_code` are stable. But this is an implementation detail, with a clear `FIXME` indicating we should switch to a per-execution seed. The stability of `MD5` also allows modules cross-compilation use-cases. The `size_t` underlying storage for `hash_code` varying across platforms could cause mismatching hashes when cross-compiling from a 64bit target to a 32bit target. Note that native endianness is still used for the hash computation. So hashes will differ between platforms of different endianness. Reviewed By: jansvoboda11 Differential Revision: https://reviews.llvm.org/D102943 --- clang/lib/Serialization/ModuleFileExtension.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'clang/lib/Serialization/ModuleFileExtension.cpp') diff --git a/clang/lib/Serialization/ModuleFileExtension.cpp b/clang/lib/Serialization/ModuleFileExtension.cpp index 6b7fd1d..95fff41 100644 --- a/clang/lib/Serialization/ModuleFileExtension.cpp +++ b/clang/lib/Serialization/ModuleFileExtension.cpp @@ -11,12 +11,10 @@ using namespace clang; char ModuleFileExtension::ID = 0; -ModuleFileExtension::~ModuleFileExtension() { } +ModuleFileExtension::~ModuleFileExtension() {} -llvm::hash_code ModuleFileExtension::hashExtension(llvm::hash_code Code) const { - return Code; -} +void ModuleFileExtension::hashExtension(ExtensionHashBuilder &HBuilder) const {} -ModuleFileExtensionWriter::~ModuleFileExtensionWriter() { } +ModuleFileExtensionWriter::~ModuleFileExtensionWriter() {} -ModuleFileExtensionReader::~ModuleFileExtensionReader() { } +ModuleFileExtensionReader::~ModuleFileExtensionReader() {} -- cgit v1.1