Skip to content

Commit 85c1ef6

Browse files
GH-137218: Update make for JIT stencils (#137265)
1 parent 47485c0 commit 85c1ef6

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

Makefile.pre.in

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,11 +3126,27 @@ JIT_DEPS = \
31263126
$(srcdir)/Tools/jit/*.py \
31273127
$(srcdir)/Python/executor_cases.c.h \
31283128
pyconfig.h
3129-
3130-
jit_stencils.h: $(JIT_DEPS)
3129+
3130+
ifneq ($(filter aarch64-apple-darwin%,$(HOST_GNU_TYPE)),)
3131+
JIT_STENCIL_HEADER := jit_stencils-aarch64-apple-darwin.h
3132+
else ifneq ($(filter x86_64-apple-darwin%,$(HOST_GNU_TYPE)),)
3133+
JIT_STENCIL_HEADER := jit_stencils-x86_64-apple-darwin.h
3134+
else ifeq ($(HOST_GNU_TYPE), aarch64-pc-windows-msvc)
3135+
JIT_STENCIL_HEADER := jit_stencils-aarch64-pc-windows-msvc.h
3136+
else ifeq ($(HOST_GNU_TYPE), i686-pc-windows-msvc)
3137+
JIT_STENCIL_HEADER := jit_stencils-i686-pc-windows-msvc.h
3138+
else ifeq ($(HOST_GNU_TYPE), x86_64-pc-windows-msvc)
3139+
JIT_STENCIL_HEADER := jit_stencils-x86_64-pc-windows-msvc.h
3140+
else ifneq ($(filter aarch64-%-linux-gnu,$(HOST_GNU_TYPE)),)
3141+
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
3142+
else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),)
3143+
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
3144+
endif
3145+
3146+
jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS)
31313147
@REGEN_JIT_COMMAND@
31323148

3133-
Python/jit.o: $(srcdir)/Python/jit.c @JIT_STENCILS_H@
3149+
Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER)
31343150
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
31353151

31363152
.PHONY: regen-jit
@@ -3228,7 +3244,7 @@ clean-retain-profile: pycremoval
32283244
-rm -rf Python/deepfreeze
32293245
-rm -f Python/frozen_modules/*.h
32303246
-rm -f Python/frozen_modules/MANIFEST
3231-
-rm -f jit_stencils.h
3247+
-rm -f jit_stencils*.h
32323248
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
32333249
-rm -f Include/pydtrace_probes.h
32343250
-rm -f profile-gen-stamp

Tools/jit/_targets.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,38 +551,45 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
551551
optimizer: type[_optimizers.Optimizer]
552552
target: _COFF32 | _COFF64 | _ELF | _MachO
553553
if re.fullmatch(r"aarch64-apple-darwin.*", host):
554+
host = "aarch64-apple-darwin"
554555
condition = "defined(__aarch64__) && defined(__APPLE__)"
555556
optimizer = _optimizers.OptimizerAArch64
556557
target = _MachO(host, condition, optimizer=optimizer)
557558
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
558-
args = ["-fms-runtime-lib=dll", "-fplt"]
559+
host = "aarch64-pc-windows-msvc"
559560
condition = "defined(_M_ARM64)"
561+
args = ["-fms-runtime-lib=dll", "-fplt"]
560562
optimizer = _optimizers.OptimizerAArch64
561563
target = _COFF64(host, condition, args=args, optimizer=optimizer)
562564
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
565+
host = "aarch64-unknown-linux-gnu"
566+
condition = "defined(__aarch64__) && defined(__linux__)"
563567
# -mno-outline-atomics: Keep intrinsics from being emitted.
564568
args = ["-fpic", "-mno-outline-atomics"]
565-
condition = "defined(__aarch64__) && defined(__linux__)"
566569
optimizer = _optimizers.OptimizerAArch64
567570
target = _ELF(host, condition, args=args, optimizer=optimizer)
568571
elif re.fullmatch(r"i686-pc-windows-msvc", host):
572+
host = "i686-pc-windows-msvc"
573+
condition = "defined(_M_IX86)"
569574
# -Wno-ignored-attributes: __attribute__((preserve_none)) is not supported here.
570575
args = ["-DPy_NO_ENABLE_SHARED", "-Wno-ignored-attributes"]
571576
optimizer = _optimizers.OptimizerX86
572-
condition = "defined(_M_IX86)"
573577
target = _COFF32(host, condition, args=args, optimizer=optimizer)
574578
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
579+
host = "x86_64-apple-darwin"
575580
condition = "defined(__x86_64__) && defined(__APPLE__)"
576581
optimizer = _optimizers.OptimizerX86
577582
target = _MachO(host, condition, optimizer=optimizer)
578583
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
579-
args = ["-fms-runtime-lib=dll"]
584+
host = "x86_64-pc-windows-msvc"
580585
condition = "defined(_M_X64)"
586+
args = ["-fms-runtime-lib=dll"]
581587
optimizer = _optimizers.OptimizerX86
582588
target = _COFF64(host, condition, args=args, optimizer=optimizer)
583589
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
584-
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
590+
host = "x86_64-unknown-linux-gnu"
585591
condition = "defined(__x86_64__) && defined(__linux__)"
592+
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
586593
optimizer = _optimizers.OptimizerX86
587594
target = _ELF(host, condition, args=args, optimizer=optimizer)
588595
else:

configure

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,13 +2787,11 @@ AS_VAR_IF([jit_flags],
27872787
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
27882788
AS_VAR_SET([REGEN_JIT_COMMAND],
27892789
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host} --output-dir . --pyconfig-dir . --cflags=\"$CFLAGS_JIT\""])
2790-
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
27912790
AS_VAR_IF([Py_DEBUG],
27922791
[true],
27932792
[AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --debug"])],
27942793
[])])
27952794
AC_SUBST([REGEN_JIT_COMMAND])
2796-
AC_SUBST([JIT_STENCILS_H])
27972795
AC_MSG_RESULT([$tier2_flags $jit_flags])
27982796

27992797
if test "$disable_gil" = "yes" -a "$enable_experimental_jit" != "no"; then

0 commit comments

Comments
 (0)