Skip to content

Commit 33a246b

Browse files
enumerate stencils
1 parent f15b48a commit 33a246b

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

Makefile.pre.in

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,10 +3136,29 @@ JIT_DEPS = \
31363136
$(srcdir)/Python/executor_cases.c.h \
31373137
pyconfig.h
31383138

3139-
jit_stencils.h: $(JIT_DEPS)
3139+
jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS)
31403140
@REGEN_JIT_COMMAND@
31413141

3142-
Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(wildcard jit_stencils-*.h)
3142+
# Match Darwin hosts with version suffixes
3143+
ifneq ($(filter aarch64-apple-darwin%,$(HOST_GNU_TYPE)),)
3144+
JIT_STENCIL_HEADER = jit_stencils-aarch64-apple-darwin.h
3145+
else ifneq ($(filter x86_64-apple-darwin%,$(HOST_GNU_TYPE)),)
3146+
JIT_STENCIL_HEADER = jit_stencils-x86_64-apple-darwin.h
3147+
else ifeq ($(HOST_GNU_TYPE), aarch64-pc-windows-msvc)
3148+
JIT_STENCIL_HEADER = jit_stencils-aarch64-pc-windows-msvc.h
3149+
else ifneq ($(filter aarch64-unknown-linux-gnu,$(HOST_GNU_TYPE)),)
3150+
JIT_STENCIL_HEADER = jit_stencils-aarch64-unknown-linux-gnu.h
3151+
else ifeq ($(HOST_GNU_TYPE), i686-pc-windows-msvc)
3152+
JIT_STENCIL_HEADER = jit_stencils-i686-pc-windows-msvc.h
3153+
else ifeq ($(HOST_GNU_TYPE), x86_64-pc-windows-msvc)
3154+
JIT_STENCIL_HEADER = jit_stencils-x86_64-pc-windows-msvc.h
3155+
else ifneq ($(filter x86_64-unknown-linux-gnu,$(HOST_GNU_TYPE)),)
3156+
JIT_STENCIL_HEADER = jit_stencils-x86_64-unknown-linux-gnu.h
3157+
else
3158+
$(error "Unsupported host triple: $(HOST_GNU_TYPE). Please update the Makefile to support this host triple.")
3159+
endif
3160+
3161+
Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER)
31433162
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
31443163

31453164
.PHONY: regen-jit

Tools/jit/_targets.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,38 +557,45 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
557557
optimizer: type[_optimizers.Optimizer]
558558
target: _COFF32 | _COFF64 | _ELF | _MachO
559559
if re.fullmatch(r"aarch64-apple-darwin.*", host):
560+
host = "aarch64-apple-darwin"
560561
condition = "defined(__aarch64__) && defined(__APPLE__)"
561562
optimizer = _optimizers.OptimizerAArch64
562563
target = _MachO(host, condition, optimizer=optimizer)
563564
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
564-
args = ["-fms-runtime-lib=dll", "-fplt"]
565+
host = "aarch64-pc-windows-msvc"
565566
condition = "defined(_M_ARM64)"
567+
args = ["-fms-runtime-lib=dll", "-fplt"]
566568
optimizer = _optimizers.OptimizerAArch64
567569
target = _COFF64(host, condition, args=args, optimizer=optimizer)
568570
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
571+
host = "aarch64-unknown-linux-gnu"
572+
condition = "defined(__aarch64__) && defined(__linux__)"
569573
# -mno-outline-atomics: Keep intrinsics from being emitted.
570574
args = ["-fpic", "-mno-outline-atomics"]
571-
condition = "defined(__aarch64__) && defined(__linux__)"
572575
optimizer = _optimizers.OptimizerAArch64
573576
target = _ELF(host, condition, args=args, optimizer=optimizer)
574577
elif re.fullmatch(r"i686-pc-windows-msvc", host):
578+
host = "i686-pc-windows-msvc"
579+
condition = "defined(_M_IX86)"
575580
# -Wno-ignored-attributes: __attribute__((preserve_none)) is not supported here.
576581
args = ["-DPy_NO_ENABLE_SHARED", "-Wno-ignored-attributes"]
577582
optimizer = _optimizers.OptimizerX86
578-
condition = "defined(_M_IX86)"
579583
target = _COFF32(host, condition, args=args, optimizer=optimizer)
580584
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
585+
host = "x86_64-apple-darwin"
581586
condition = "defined(__x86_64__) && defined(__APPLE__)"
582587
optimizer = _optimizers.OptimizerX86
583588
target = _MachO(host, condition, optimizer=optimizer)
584589
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
585-
args = ["-fms-runtime-lib=dll"]
590+
host = "x86_64-pc-windows-msvc"
586591
condition = "defined(_M_X64)"
592+
args = ["-fms-runtime-lib=dll"]
587593
optimizer = _optimizers.OptimizerX86
588594
target = _COFF64(host, condition, args=args, optimizer=optimizer)
589595
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
590-
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
596+
host = "x86_64-unknown-linux-gnu"
591597
condition = "defined(__x86_64__) && defined(__linux__)"
598+
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
592599
optimizer = _optimizers.OptimizerX86
593600
target = _ELF(host, condition, args=args, optimizer=optimizer)
594601
else:

0 commit comments

Comments
 (0)