From b359056d229fef550d00ae1fe48aad768b03b69b Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 30 Jul 2025 21:01:49 -0700 Subject: [PATCH 01/14] Fix make file to check for wildcard stencils --- Makefile.pre.in | 4 ++-- configure | 3 --- configure.ac | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index b7b16ef4cb9d19..8c75f8bf3aedfd 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3135,7 +3135,7 @@ JIT_DEPS = \ jit_stencils.h: $(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 $(wildcard jit_stencils-*.h) $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< .PHONY: regen-jit @@ -3233,7 +3233,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 jit_stencils-*.h -find build -type f -a ! -name '*.gc??' -exec rm -f {} ';' -rm -f Include/pydtrace_probes.h -rm -f profile-gen-stamp diff --git a/configure b/configure index 0e7aefed5ee62d..8c802b4da4d24f 100755 --- a/configure +++ b/configure @@ -906,7 +906,6 @@ LDSHARED SHLIB_SUFFIX DSYMUTIL_PATH DSYMUTIL -JIT_STENCILS_H REGEN_JIT_COMMAND UNIVERSAL_ARCH_FLAGS WASM_STDLIB @@ -10869,7 +10868,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" @@ -10877,7 +10875,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; } diff --git a/configure.ac b/configure.ac index 1e590e1d0fd727..190174073ecea1 100644 --- a/configure.ac +++ b/configure.ac @@ -2780,13 +2780,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 From 178cebdd4e6b28184a8cf578d095629a6ac9435b Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Thu, 31 Jul 2025 20:34:31 -0700 Subject: [PATCH 02/14] Use * --- Makefile.pre.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 8c75f8bf3aedfd..2e24fc83c6cbef 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3135,7 +3135,7 @@ JIT_DEPS = \ jit_stencils.h: $(JIT_DEPS) @REGEN_JIT_COMMAND@ -Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(wildcard jit_stencils-*.h) +Python/jit.o: $(srcdir)/Python/jit.c jit_stencils*.h $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< .PHONY: regen-jit @@ -3233,7 +3233,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 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 From 332e59654396ce508abee1309c0ad9dd4d8c9c65 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Thu, 31 Jul 2025 20:43:09 -0700 Subject: [PATCH 03/14] Revert to wildcard keyword --- Makefile.pre.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 2e24fc83c6cbef..09f65a27a8d615 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3135,7 +3135,7 @@ JIT_DEPS = \ jit_stencils.h: $(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 $(wildcard jit_stencils-*.h) $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< .PHONY: regen-jit @@ -3233,7 +3233,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 $(wildcard jit_stencils-*.h) -find build -type f -a ! -name '*.gc??' -exec rm -f {} ';' -rm -f Include/pydtrace_probes.h -rm -f profile-gen-stamp From 33a246b74face086469430927d5145a70ca0979f Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:04:07 -0700 Subject: [PATCH 04/14] enumerate stencils --- Makefile.pre.in | 23 +++++++++++++++++++++-- Tools/jit/_targets.py | 17 ++++++++++++----- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index babc91bdeb23ca..a4d01fb7213b45 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3136,10 +3136,29 @@ JIT_DEPS = \ $(srcdir)/Python/executor_cases.c.h \ pyconfig.h -jit_stencils.h: $(JIT_DEPS) +jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS) @REGEN_JIT_COMMAND@ -Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(wildcard jit_stencils-*.h) +# Match Darwin hosts with version suffixes +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 ifneq ($(filter aarch64-unknown-linux-gnu,$(HOST_GNU_TYPE)),) +JIT_STENCIL_HEADER = jit_stencils-aarch64-unknown-linux-gnu.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 x86_64-unknown-linux-gnu,$(HOST_GNU_TYPE)),) +JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h +else +$(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.") +endif + +Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER) $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< .PHONY: regen-jit diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index 3883671e92aa39..1f41b44ef11bf2 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -557,38 +557,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: From 6b467c11213e0b239093f773b002377edfbf5935 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:07:35 -0700 Subject: [PATCH 05/14] Update comment --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a4d01fb7213b45..a1b18fde97e54f 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3155,7 +3155,7 @@ JIT_STENCIL_HEADER = jit_stencils-x86_64-pc-windows-msvc.h else ifneq ($(filter x86_64-unknown-linux-gnu,$(HOST_GNU_TYPE)),) JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h else -$(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.") +$(error "Unsupported host triple: $(HOST_GNU_TYPE).") endif Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER) From 413bcfc215e5e3543718beb3d4fbe7361b611b78 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:08:08 -0700 Subject: [PATCH 06/14] Fix rm --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a1b18fde97e54f..2ff1dd13b59a92 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3256,7 +3256,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 $(wildcard 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 From c6f039064ccbb6ba18429ed87b93667abe1a0e4f Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:10:08 -0700 Subject: [PATCH 07/14] Fix linux --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 2ff1dd13b59a92..7ce2369cf4d096 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3152,7 +3152,7 @@ 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 x86_64-unknown-linux-gnu,$(HOST_GNU_TYPE)),) +else ifeq ($(HOST_GNU_TYPE), x86_64-unknown-linux-gnu) JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h else $(error "Unsupported host triple: $(HOST_GNU_TYPE).") From ecf492fbed3a3a0c980d65373ae39764acdf1132 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:13:14 -0700 Subject: [PATCH 08/14] Update to use pc, since that is what it is it :) --- .github/workflows/jit.yml | 2 +- Makefile.pre.in | 4 ++-- Tools/jit/_targets.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml index 51a069d857f2a3..e860a936247cff 100644 --- a/.github/workflows/jit.yml +++ b/.github/workflows/jit.yml @@ -85,7 +85,7 @@ jobs: - target: aarch64-apple-darwin/clang architecture: aarch64 runner: macos-14 - - target: x86_64-unknown-linux-gnu/gcc + - target: x86_64-pc-linux-gnu/gcc architecture: x86_64 runner: ubuntu-24.04 - target: aarch64-unknown-linux-gnu/gcc diff --git a/Makefile.pre.in b/Makefile.pre.in index 7ce2369cf4d096..d95a8cf9d45015 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3152,8 +3152,8 @@ 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 ifeq ($(HOST_GNU_TYPE), x86_64-unknown-linux-gnu) -JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h +else ifeq ($(HOST_GNU_TYPE), x86_64-pc-linux-gnu) +JIT_STENCIL_HEADER = jit_stencils-x86_64-pc-linux-gnu.h else $(error "Unsupported host triple: $(HOST_GNU_TYPE).") endif diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index 1f41b44ef11bf2..7d0b679bd59987 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -593,7 +593,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO: optimizer = _optimizers.OptimizerX86 target = _COFF64(host, condition, args=args, optimizer=optimizer) elif re.fullmatch(r"x86_64-.*-linux-gnu", host): - host = "x86_64-unknown-linux-gnu" + host = "x86_64-pcn-linux-gnu" condition = "defined(__x86_64__) && defined(__linux__)" args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"] optimizer = _optimizers.OptimizerX86 From 48e3dc141873229486c8018cb0271e815aa43788 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:14:17 -0700 Subject: [PATCH 09/14] fix typo --- Tools/jit/_targets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index 7d0b679bd59987..a8bb494ac1af5d 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -593,7 +593,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO: optimizer = _optimizers.OptimizerX86 target = _COFF64(host, condition, args=args, optimizer=optimizer) elif re.fullmatch(r"x86_64-.*-linux-gnu", host): - host = "x86_64-pcn-linux-gnu" + host = "x86_64-pc-linux-gnu" condition = "defined(__x86_64__) && defined(__linux__)" args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"] optimizer = _optimizers.OptimizerX86 From f32f8a4221bf8152b675f6cbf0cf0b41298206a2 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:20:06 -0700 Subject: [PATCH 10/14] Fix if statements --- Makefile.pre.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index d95a8cf9d45015..8b4234ef9b96e5 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3146,16 +3146,16 @@ 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 ifneq ($(filter aarch64-unknown-linux-gnu,$(HOST_GNU_TYPE)),) -JIT_STENCIL_HEADER = jit_stencils-aarch64-unknown-linux-gnu.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 ifeq ($(HOST_GNU_TYPE), x86_64-pc-linux-gnu) +else ifneq ($(filter aarch64-%-linux-gnu,$(HOST_GNU_TYPE)),) +JIT_STENCIL_HEADER = jit_stencils-aarch64-unknown-linux-gnu.h +else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),) JIT_STENCIL_HEADER = jit_stencils-x86_64-pc-linux-gnu.h else -$(error "Unsupported host triple: $(HOST_GNU_TYPE).") +$(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.") endif Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER) From 0ceca3667d124a129922cdbd020f93a90a19de8c Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sat, 2 Aug 2025 12:21:30 -0700 Subject: [PATCH 11/14] Revert unknown --- .github/workflows/jit.yml | 2 +- Makefile.pre.in | 2 +- Tools/jit/_targets.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml index e860a936247cff..51a069d857f2a3 100644 --- a/.github/workflows/jit.yml +++ b/.github/workflows/jit.yml @@ -85,7 +85,7 @@ jobs: - target: aarch64-apple-darwin/clang architecture: aarch64 runner: macos-14 - - target: x86_64-pc-linux-gnu/gcc + - target: x86_64-unknown-linux-gnu/gcc architecture: x86_64 runner: ubuntu-24.04 - target: aarch64-unknown-linux-gnu/gcc diff --git a/Makefile.pre.in b/Makefile.pre.in index 8b4234ef9b96e5..fea05b69b84b4a 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3153,7 +3153,7 @@ 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-aarch64-unknown-linux-gnu.h else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),) -JIT_STENCIL_HEADER = jit_stencils-x86_64-pc-linux-gnu.h +JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h else $(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.") endif diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index a8bb494ac1af5d..1f41b44ef11bf2 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -593,7 +593,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO: optimizer = _optimizers.OptimizerX86 target = _COFF64(host, condition, args=args, optimizer=optimizer) elif re.fullmatch(r"x86_64-.*-linux-gnu", host): - host = "x86_64-pc-linux-gnu" + host = "x86_64-unknown-linux-gnu" condition = "defined(__x86_64__) && defined(__linux__)" args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"] optimizer = _optimizers.OptimizerX86 From 93306d2b8862c2ae2c14ad24a0c26e94cb267c29 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sun, 3 Aug 2025 15:12:13 -0700 Subject: [PATCH 12/14] Fix match for linux platforms --- Makefile.pre.in | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index fea05b69b84b4a..a4d9e40173df74 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3129,35 +3129,30 @@ config.status: $(srcdir)/configure Python/asm_trampoline.o: $(srcdir)/Python/asm_trampoline.S $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< - -JIT_DEPS = \ - $(srcdir)/Tools/jit/*.c \ - $(srcdir)/Tools/jit/*.py \ - $(srcdir)/Python/executor_cases.c.h \ - pyconfig.h +# Determine correct JIT stencil header based on host triple +ifeq (,$(JIT_STENCIL_HEADER)) + 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 + else + $(error "Unsupported host triple: $(HOST_GNU_TYPE).") + endif +endif jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS) @REGEN_JIT_COMMAND@ -# Match Darwin hosts with version suffixes -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-aarch64-unknown-linux-gnu.h -else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),) -JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h -else -$(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.") -endif - Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER) $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< From 84b3ccaa5c5ffcdf159a71b6b0732a21ad482f92 Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sun, 3 Aug 2025 15:17:04 -0700 Subject: [PATCH 13/14] Add deps --- Makefile.pre.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.pre.in b/Makefile.pre.in index a4d9e40173df74..cfd4ccedefa14e 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3129,6 +3129,12 @@ config.status: $(srcdir)/configure Python/asm_trampoline.o: $(srcdir)/Python/asm_trampoline.S $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< +JIT_DEPS = \ + $(srcdir)/Tools/jit/*.c \ + $(srcdir)/Tools/jit/*.py \ + $(srcdir)/Python/executor_cases.c.h \ + pyconfig.h + # Determine correct JIT stencil header based on host triple ifeq (,$(JIT_STENCIL_HEADER)) ifneq ($(filter aarch64-apple-darwin%,$(HOST_GNU_TYPE)),) From d6a5582076cf28eef27188246e38ce32cbd7217f Mon Sep 17 00:00:00 2001 From: Savannah Bailey Date: Sun, 3 Aug 2025 15:26:05 -0700 Subject: [PATCH 14/14] Gracefully fail --- Makefile.pre.in | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 02ab4dde068147..c32444e7b80e31 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3112,25 +3112,20 @@ JIT_DEPS = \ $(srcdir)/Python/executor_cases.c.h \ pyconfig.h -# Determine correct JIT stencil header based on host triple -ifeq (,$(JIT_STENCIL_HEADER)) - 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 - else - $(error "Unsupported host triple: $(HOST_GNU_TYPE).") - endif +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)