gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (GH-142455)
(cherry picked from commit
bcf90de8ba2ea087540a5f632656ef880ee46b5c)
Co-authored-by: Miro HronĨok <miro@hroncok.cz>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
--- /dev/null
+When calculating the digest of the JIT stencils input, sort the hashed files
+by filenames before adding their content to the hasher. This ensures
+deterministic hash input and hence deterministic hash, independent on
+filesystem order.
# Exclude cache files from digest computation to ensure reproducible builds.
if dirpath.endswith("__pycache__"):
continue
- for filename in filenames:
+ for filename in sorted(filenames):
hasher.update(pathlib.Path(dirpath, filename).read_bytes())
return hasher.hexdigest()