Fixup using prebuilt JIT on ELN

See f45779a0aa for context.

After autoconf 2.73 landed in Fedora ELN,
the pre-built JIT stencils were rejected because of checksum mismatch.

This new patch adds an ability to circumvent that check.

It has been offered upstream in
https://github.com/python/cpython/issues/148646
https://github.com/python/cpython/pull/148647

While this has yet to be finalized upstream and might take a while, we need to fix the ELN build right away.

(When we build the stencils on rawhide for the next release,
the problem will shift from ELN with new autoconf to old Fedoras with old autoconf.)

Cherry-picked from python3.15 commit 4a1f3dae4f24af60227469c76acf9452f02c90dd
This commit is contained in:
Miro Hrončok 2026-04-17 09:29:26 +02:00
commit 9025dc9760
2 changed files with 151 additions and 1 deletions

View file

@ -0,0 +1,146 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 16 Apr 2026 14:39:41 +0200
Subject: 00486: gh-148646: Add --enable-prebuilt-jit-stencils configure flag
---
...-04-16-14-39-33.gh-issue-148646.iIIgWF.rst | 6 +++++
Tools/jit/_targets.py | 3 ++-
Tools/jit/build.py | 6 +++++
configure | 26 +++++++++++++++++++
configure.ac | 13 ++++++++++
5 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 Misc/NEWS.d/next/Build/2026-04-16-14-39-33.gh-issue-148646.iIIgWF.rst
diff --git a/Misc/NEWS.d/next/Build/2026-04-16-14-39-33.gh-issue-148646.iIIgWF.rst b/Misc/NEWS.d/next/Build/2026-04-16-14-39-33.gh-issue-148646.iIIgWF.rst
new file mode 100644
index 0000000000..52dbc347a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-04-16-14-39-33.gh-issue-148646.iIIgWF.rst
@@ -0,0 +1,6 @@
+Add a new ``--enable-prebuilt-jit-stencils`` configure flag that forces the
+build to use the existing provided JIT stencils even when the digest at the
+beginning of the file does not match expectations. That allows
+redistributors who prebuilt the JIT stencils on a system with a different
+autoconf version to still use them even when ``pyconfig.h`` is slightly
+different.
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index f1085cc9bf..3d8af735e2 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -205,6 +205,7 @@ def build(
*,
comment: str = "",
force: bool = False,
+ prebuilt: bool = False,
jit_stencils: pathlib.Path,
) -> None:
"""Build jit_stencils.h in the given directory."""
@@ -218,7 +219,7 @@ def build(
if (
not force
and jit_stencils.exists()
- and jit_stencils.read_text().startswith(digest)
+ and (prebuilt or jit_stencils.read_text().startswith(digest))
):
return
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
diff --git a/Tools/jit/build.py b/Tools/jit/build.py
index a073300592..5580985974 100644
--- a/Tools/jit/build.py
+++ b/Tools/jit/build.py
@@ -42,6 +42,11 @@
parser.add_argument(
"--cflags", help="additional flags to pass to the compiler", default=""
)
+ parser.add_argument(
+ "--prebuilt",
+ action="store_true",
+ help="accept prebuilt stencils even if the digest does not match",
+ )
args = parser.parse_args()
for target in args.target:
target.debug = args.debug
@@ -52,6 +57,7 @@
target.build(
comment=comment,
force=args.force,
+ prebuilt=args.prebuilt,
jit_stencils=args.output_dir / f"jit_stencils-{target.triple}.h",
)
jit_stencils_h = args.output_dir / "jit_stencils.h"
diff --git a/configure b/configure
index 8cfdda5a29..e3f51f1f86 100755
--- a/configure
+++ b/configure
@@ -1104,6 +1104,7 @@ with_strict_overflow
enable_safety
enable_slower_safety
enable_experimental_jit
+enable_prebuilt_jit_stencils
with_dsymutil
with_address_sanitizer
with_memory_sanitizer
@@ -1841,6 +1842,9 @@ Optional Features:
--enable-experimental-jit[=no|yes|yes-off|interpreter]
build the experimental just-in-time compiler
(default is no)
+ --enable-prebuilt-jit-stencils
+ accept prebuilt JIT stencils even if the digest does
+ not match (default is no)
--enable-loadable-sqlite-extensions
support loadable extensions in the sqlite3 module,
see Doc/library/sqlite3.rst (default is no)
@@ -10932,6 +10936,28 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tier2_flags $jit_flags" >&5
printf "%s\n" "$tier2_flags $jit_flags" >&6; }
+# Check for --enable-prebuilt-jit-stencils:
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --enable-prebuilt-jit-stencils" >&5
+printf %s "checking for --enable-prebuilt-jit-stencils... " >&6; }
+# Check whether --enable-prebuilt-jit-stencils was given.
+if test ${enable_prebuilt_jit_stencils+y}
+then :
+ enableval=$enable_prebuilt_jit_stencils;
+else case e in #(
+ e) enable_prebuilt_jit_stencils=no ;;
+esac
+fi
+
+if test "x$enable_prebuilt_jit_stencils" = xno
+then :
+
+else case e in #(
+ e) as_fn_append REGEN_JIT_COMMAND " --prebuilt" ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_prebuilt_jit_stencils" >&5
+printf "%s\n" "$enable_prebuilt_jit_stencils" >&6; }
+
if test "$disable_gil" = "yes" -a "$enable_experimental_jit" != "no"; then
# GH-133171: This configuration builds the JIT but never actually uses it,
# which is surprising (and strictly worse than not building it at all):
diff --git a/configure.ac b/configure.ac
index 1acb91fd27..462152c656 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2800,6 +2800,19 @@ AC_SUBST([REGEN_JIT_COMMAND])
AC_SUBST([JIT_STENCILS_H])
AC_MSG_RESULT([$tier2_flags $jit_flags])
+# Check for --enable-prebuilt-jit-stencils:
+AC_MSG_CHECKING([for --enable-prebuilt-jit-stencils])
+AC_ARG_ENABLE([prebuilt-jit-stencils],
+ [AS_HELP_STRING([--enable-prebuilt-jit-stencils],
+ [accept prebuilt JIT stencils even if the digest does not match (default is no)])],
+ [],
+ [enable_prebuilt_jit_stencils=no])
+AS_VAR_IF([enable_prebuilt_jit_stencils],
+ [no],
+ [],
+ [AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --prebuilt"])])
+AC_MSG_RESULT([$enable_prebuilt_jit_stencils])
+
if test "$disable_gil" = "yes" -a "$enable_experimental_jit" != "no"; then
# GH-133171: This configuration builds the JIT but never actually uses it,
# which is surprising (and strictly worse than not building it at all):

View file

@ -87,7 +87,7 @@ License: Python-2.0.1
%bcond jit_build_stencils %[%{with jit} && 0%{?fedora} >= 41]
%if %{with jit}
# When built with JIT, it still needs to be enabled on runtime via PYTHON_JIT=1
%global jit_flag --enable-experimental-jit=yes-off
%global jit_flag --enable-experimental-jit=yes-off %{!?with_jit_build_stencils:--enable-prebuilt-jit-stencils}
%endif
# Main interpreter loop optimization
@ -471,6 +471,10 @@ Patch481: 00481-cve-2026-5713.patch
# Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor
Patch482: 00482-cve-2026-6100.patch
# 00486 # 5ae0b81b3135319f8d75a886fb7a11fa40ac11f4
# gh-148646: Add --enable-prebuilt-jit-stencils configure flag
Patch486: 00486-gh-148646-add---enable-prebuilt-jit-stencils-configure-flag.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,