[all-commits] [llvm/llvm-project] 655bea: [modules] Use `HashBuilder` and `MD5` for the modu...

Alexandre Rames via All-commits all-commits at lists.llvm.org
Fri Sep 3 11:13:50 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 655bea4226b401a11164f99c6344e38d8742b8e4
      https://github.com/llvm/llvm-project/commit/655bea4226b401a11164f99c6344e38d8742b8e4
  Author: Alexandre Rames <arames at apple.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M clang/include/clang/Basic/ObjCRuntime.h
    M clang/include/clang/Basic/Sanitizers.h
    M clang/include/clang/Lex/HeaderSearchOptions.h
    M clang/include/clang/Serialization/ModuleFileExtension.h
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/lib/Frontend/TestModuleFileExtension.cpp
    M clang/lib/Frontend/TestModuleFileExtension.h
    M clang/lib/Serialization/ModuleFileExtension.cpp
    M clang/unittests/Frontend/CompilerInvocationTest.cpp
    M llvm/include/llvm/Support/VersionTuple.h

  Log Message:
  -----------
  [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




More information about the All-commits mailing list