From 38eff7be0a5c9c320cc0467436fc12be3c0efac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 9 Dec 2025 13:30:03 +0100 Subject: [PATCH 1/3] gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit The order of filenames provided by os.walk is filesystem-dependent. Different filesystems return the files in a different order, hence invalidating the digest. Keeping everything sorted makes the digest deterministic. Fixes https://github.com/python/cpython/issues/142454 --- .../next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst | 4 ++++ Tools/jit/_targets.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst 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 00000000000000..5590e10a6010c3 --- /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 stecnils input, sort the hashed files +by filenames before adding their content to the hasher. This ansures +deterministic hash input and hence deterministic hash, independent on +filesystem order. diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index adb8a8d8ecb8a1..f92f3eac13bde5 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -76,7 +76,7 @@ def _compute_digest(self) -> str: # 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() From 6115fef9eeb361f23d0ada2790d4b23eff0c46db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 9 Dec 2025 14:55:57 +0100 Subject: [PATCH 2/3] Fix typo in Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst Co-authored-by: Ken Jin --- .../next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 5590e10a6010c3..ab95b403b2a40a 100644 --- 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 @@ -1,4 +1,4 @@ -When calculating the digest of the JIT stecnils input, sort the hashed files +When calculating the digest of the JIT stencils input, sort the hashed files by filenames before adding their content to the hasher. This ansures deterministic hash input and hence deterministic hash, independent on filesystem order. From 6273211ff0b1415e184c15951225badb7d68a514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 9 Dec 2025 15:45:11 +0100 Subject: [PATCH 3/3] Fix a typo in Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst --- .../next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ab95b403b2a40a..4de16866f28851 100644 --- 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 @@ -1,4 +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 ansures +by filenames before adding their content to the hasher. This ensures deterministic hash input and hence deterministic hash, independent on filesystem order.