Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
# 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 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

Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER)
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<

.PHONY: regen-jit
Expand Down Expand Up @@ -3237,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
-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
Expand Down
17 changes: 12 additions & 5 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-pcn-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:
Expand Down
3 changes: 0 additions & 3 deletions configure

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

2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading