From: Miro HronĨok Date: Tue, 9 Dec 2025 17:33:09 +0000 (+0100) Subject: gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit... X-Git-Tag: v3.15.0a3~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcf90de8ba2ea087540a5f632656ef880ee46b5c;p=thirdparty%2FPython%2Fcpython.git gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (#142455) Co-authored-by: Ken Jin --- diff --git a/Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst b/Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst new file mode 100644 index 000000000000..4de16866f288 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst @@ -0,0 +1,4 @@ +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. diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index adb8a8d8ecb8..f92f3eac13bd 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -76,7 +76,7 @@ class _Target(typing.Generic[_S, _R]): # 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()