Skip to content

Commit 7621bbd

Browse files
miss-islingtonhroncokFidget-Spinner
authored
[3.14] gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (GH-142455) (#142485)
gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (GH-142455) (cherry picked from commit bcf90de) Co-authored-by: Miro Hrončok <miro@hroncok.cz> Co-authored-by: Ken Jin <kenjin4096@gmail.com>
1 parent 8cb65ca commit 7621bbd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When calculating the digest of the JIT stencils input, sort the hashed files
2+
by filenames before adding their content to the hasher. This ensures
3+
deterministic hash input and hence deterministic hash, independent on
4+
filesystem order.

Tools/jit/_targets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _compute_digest(self) -> str:
7272
# Exclude cache files from digest computation to ensure reproducible builds.
7373
if dirpath.endswith("__pycache__"):
7474
continue
75-
for filename in filenames:
75+
for filename in sorted(filenames):
7676
hasher.update(pathlib.Path(dirpath, filename).read_bytes())
7777
return hasher.hexdigest()
7878

0 commit comments

Comments
 (0)