From 0f886751a74179f8e2ecfaecbb8d21eeba1c2451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 16 Apr 2026 14:39:41 +0200 Subject: [PATCH] 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 00000000000000..52dbc347a00ad2 --- /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 ea0a9722c3cdf8..0ac7ae774a3f38 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -235,6 +235,7 @@ def build( *, comment: str = "", force: bool = False, + prebuilt: bool = False, jit_stencils: pathlib.Path, ) -> None: """Build jit_stencils.h in the given directory.""" @@ -250,7 +251,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 127d93b317fb09..ec1ce4fc40484b 100644 --- a/Tools/jit/build.py +++ b/Tools/jit/build.py @@ -43,6 +43,11 @@ "--cflags", help="additional flags to pass to the compiler", default="" ) parser.add_argument("--llvm-version", help="LLVM version to use") + 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 @@ -55,6 +60,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 8620eb3fbdd36b..d9d9e7321d686c 100755 --- a/configure +++ b/configure @@ -1114,6 +1114,7 @@ with_strict_overflow enable_safety enable_slower_safety enable_experimental_jit +enable_prebuilt_jit_stencils with_dsymutil with_address_sanitizer with_memory_sanitizer @@ -1858,6 +1859,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) @@ -11004,6 +11008,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 d73b37327fe584..c58590bd4d30b9 100644 --- a/configure.ac +++ b/configure.ac @@ -2836,6 +2836,19 @@ AS_VAR_IF([jit_flags], AC_SUBST([REGEN_JIT_COMMAND]) 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):