GH-137218: Update make for JIT stencils (#137265)

This commit is contained in:
Savannah Bailey
2025-09-19 10:36:42 +01:00
committed by GitHub
parent 47485c0384
commit 85c1ef6477
4 changed files with 31 additions and 13 deletions

View File

@@ -3127,10 +3127,26 @@ JIT_DEPS = \
$(srcdir)/Python/executor_cases.c.h \
pyconfig.h
jit_stencils.h: $(JIT_DEPS)
ifneq ($(filter aarch64-apple-darwin%,$(HOST_GNU_TYPE)),)
JIT_STENCIL_HEADER := jit_stencils-aarch64-apple-darwin.h
else ifneq ($(filter x86_64-apple-darwin%,$(HOST_GNU_TYPE)),)
JIT_STENCIL_HEADER := jit_stencils-x86_64-apple-darwin.h
else ifeq ($(HOST_GNU_TYPE), aarch64-pc-windows-msvc)
JIT_STENCIL_HEADER := jit_stencils-aarch64-pc-windows-msvc.h
else ifeq ($(HOST_GNU_TYPE), i686-pc-windows-msvc)
JIT_STENCIL_HEADER := jit_stencils-i686-pc-windows-msvc.h
else ifeq ($(HOST_GNU_TYPE), x86_64-pc-windows-msvc)
JIT_STENCIL_HEADER := jit_stencils-x86_64-pc-windows-msvc.h
else ifneq ($(filter aarch64-%-linux-gnu,$(HOST_GNU_TYPE)),)
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),)
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
endif
jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS)
@REGEN_JIT_COMMAND@
Python/jit.o: $(srcdir)/Python/jit.c @JIT_STENCILS_H@
Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER)
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
.PHONY: regen-jit
@@ -3228,7 +3244,7 @@ clean-retain-profile: pycremoval
-rm -rf Python/deepfreeze
-rm -f Python/frozen_modules/*.h
-rm -f Python/frozen_modules/MANIFEST
-rm -f jit_stencils.h
-rm -f jit_stencils*.h
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
-rm -f Include/pydtrace_probes.h
-rm -f profile-gen-stamp

View File

@@ -551,38 +551,45 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
optimizer: type[_optimizers.Optimizer]
target: _COFF32 | _COFF64 | _ELF | _MachO
if re.fullmatch(r"aarch64-apple-darwin.*", host):
host = "aarch64-apple-darwin"
condition = "defined(__aarch64__) && defined(__APPLE__)"
optimizer = _optimizers.OptimizerAArch64
target = _MachO(host, condition, optimizer=optimizer)
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll", "-fplt"]
host = "aarch64-pc-windows-msvc"
condition = "defined(_M_ARM64)"
args = ["-fms-runtime-lib=dll", "-fplt"]
optimizer = _optimizers.OptimizerAArch64
target = _COFF64(host, condition, args=args, optimizer=optimizer)
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
host = "aarch64-unknown-linux-gnu"
condition = "defined(__aarch64__) && defined(__linux__)"
# -mno-outline-atomics: Keep intrinsics from being emitted.
args = ["-fpic", "-mno-outline-atomics"]
condition = "defined(__aarch64__) && defined(__linux__)"
optimizer = _optimizers.OptimizerAArch64
target = _ELF(host, condition, args=args, optimizer=optimizer)
elif re.fullmatch(r"i686-pc-windows-msvc", host):
host = "i686-pc-windows-msvc"
condition = "defined(_M_IX86)"
# -Wno-ignored-attributes: __attribute__((preserve_none)) is not supported here.
args = ["-DPy_NO_ENABLE_SHARED", "-Wno-ignored-attributes"]
optimizer = _optimizers.OptimizerX86
condition = "defined(_M_IX86)"
target = _COFF32(host, condition, args=args, optimizer=optimizer)
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
host = "x86_64-apple-darwin"
condition = "defined(__x86_64__) && defined(__APPLE__)"
optimizer = _optimizers.OptimizerX86
target = _MachO(host, condition, optimizer=optimizer)
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll"]
host = "x86_64-pc-windows-msvc"
condition = "defined(_M_X64)"
args = ["-fms-runtime-lib=dll"]
optimizer = _optimizers.OptimizerX86
target = _COFF64(host, condition, args=args, optimizer=optimizer)
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
host = "x86_64-unknown-linux-gnu"
condition = "defined(__x86_64__) && defined(__linux__)"
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
optimizer = _optimizers.OptimizerX86
target = _ELF(host, condition, args=args, optimizer=optimizer)
else:

3
configure generated vendored
View File

@@ -904,7 +904,6 @@ LDSHARED
SHLIB_SUFFIX
DSYMUTIL_PATH
DSYMUTIL
JIT_STENCILS_H
REGEN_JIT_COMMAND
UNIVERSAL_ARCH_FLAGS
WASM_STDLIB
@@ -10876,7 +10875,6 @@ then :
else case e in #(
e) as_fn_append CFLAGS_NODIST " $jit_flags"
REGEN_JIT_COMMAND="\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host} --output-dir . --pyconfig-dir . --cflags=\"$CFLAGS_JIT\""
JIT_STENCILS_H="jit_stencils.h"
if test "x$Py_DEBUG" = xtrue
then :
as_fn_append REGEN_JIT_COMMAND " --debug"
@@ -10884,7 +10882,6 @@ fi ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tier2_flags $jit_flags" >&5
printf "%s\n" "$tier2_flags $jit_flags" >&6; }

View File

@@ -2787,13 +2787,11 @@ AS_VAR_IF([jit_flags],
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
AS_VAR_SET([REGEN_JIT_COMMAND],
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host} --output-dir . --pyconfig-dir . --cflags=\"$CFLAGS_JIT\""])
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
AS_VAR_IF([Py_DEBUG],
[true],
[AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --debug"])],
[])])
AC_SUBST([REGEN_JIT_COMMAND])
AC_SUBST([JIT_STENCILS_H])
AC_MSG_RESULT([$tier2_flags $jit_flags])
if test "$disable_gil" = "yes" -a "$enable_experimental_jit" != "no"; then