Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Add a new ``--enable-prebuilt-jit-stencils`` configure flag that forces the
build to use the existing provided JIT stencil headers even when the digest
at the beginning of the file does not match expectations. The JIT shim
object and unwind info are still rebuilt normally. That allows redistributors
who prebuilt the JIT stencil headers on a system with a different autoconf
version to still use them even when ``pyconfig.h`` is slightly different.
It also allow them to build the JIT shim with different LLVM toolchain.
25 changes: 15 additions & 10 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def build(
*,
comment: str = "",
force: bool = False,
prebuilt: bool = False,
jit_stencils: pathlib.Path,
jit_shim_object: pathlib.Path,
jit_unwind_info: pathlib.Path,
Expand All @@ -355,12 +356,15 @@ def build(
outline = "=" * len(warning)
print("\n".join(["", outline, warning, request, outline, ""]))
digest = f"// {self._compute_digest()}\n"
stencils_current = (
not force
and jit_stencils.exists()
and (prebuilt or jit_stencils.read_text().startswith(digest))
)
# The generated headers include the input digest as their first line.
# If every generated artifact is current, skip the expensive rebuild.
if (
not force
and jit_stencils.exists()
and jit_stencils.read_text().startswith(digest)
stencils_current
and jit_shim_object.exists()
and jit_unwind_info.exists()
and jit_unwind_info.read_text().startswith(digest)
Expand All @@ -377,13 +381,14 @@ def build(
lines=_writer.dump_unwind_info(unwind_info),
)
# Build the uop stencils after the shim metadata has been emitted.
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
self._write_generated_header(
jit_stencils,
digest=digest,
comment=comment,
lines=_writer.dump(stencil_groups, self.known_symbols),
)
if not stencils_current:
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
self._write_generated_header(
jit_stencils,
digest=digest,
comment=comment,
lines=_writer.dump(stencil_groups, self.known_symbols),
)


class _COFF(
Expand Down
6 changes: 6 additions & 0 deletions Tools/jit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def _write_target_dispatcher(
parser.add_argument(
"--llvm-tools-install-dir", help="Installation location of LLVM tools"
)
parser.add_argument(
"--prebuilt",
action="store_true",
help="accept prebuilt stencil headers even if the digest does not match",
)
args = parser.parse_args()
for target in args.target:
target.debug = args.debug
Expand All @@ -85,6 +90,7 @@ def _write_target_dispatcher(
target.build(
comment=comment,
force=args.force,
prebuilt=args.prebuilt,
jit_stencils=args.output_dir / f"jit_stencils-{target.triple}.h",
jit_shim_object=args.output_dir / f"jit_shim-{target.triple}.o",
jit_unwind_info=args.output_dir / f"jit_unwind_info-{target.triple}.h",
Expand Down
26 changes: 26 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,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 stencil headers 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):
Expand Down
Loading