Skip to content

Commit bcf90de

Browse files
gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (#142455)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
1 parent 1adb17b commit bcf90de

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
@@ -76,7 +76,7 @@ def _compute_digest(self) -> str:
7676
# Exclude cache files from digest computation to ensure reproducible builds.
7777
if dirpath.endswith("__pycache__"):
7878
continue
79-
for filename in filenames:
79+
for filename in sorted(filenames):
8080
hasher.update(pathlib.Path(dirpath, filename).read_bytes())
8181
return hasher.hexdigest()
8282

0 commit comments

Comments
 (0)