Skip to content

Commit a382a44

Browse files
Fix up conditions
1 parent b606b48 commit a382a44

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Tools/jit/_targets.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
CPYTHON = TOOLS.parent
2626
PYTHON_EXECUTOR_CASES_C_H = CPYTHON / "Python" / "executor_cases.c.h"
2727
TOOLS_JIT_TEMPLATE_C = TOOLS_JIT / "template.c"
28+
ASYNCIO_RUNNER=asyncio.Runner()
2829

2930
_S = typing.TypeVar("_S", _schema.COFFSection, _schema.ELFSection, _schema.MachOSection)
3031
_R = typing.TypeVar(
@@ -222,7 +223,7 @@ def build(
222223
and jit_stencils.read_text().startswith(digest)
223224
):
224225
return
225-
stencil_groups = asyncio.run(self._build_stencils())
226+
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
226227
jit_stencils_new = out / "jit_stencils.h.new"
227228
try:
228229
with jit_stencils_new.open("w") as file:
@@ -518,30 +519,30 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
518519
# ghccc currently crashes Clang when combined with musttail on aarch64. :(
519520
target: _COFF | _ELF | _MachO
520521
if re.fullmatch(r"aarch64-apple-darwin.*", host):
521-
condition = "defined(__aarch64__)" and "defined(__APPLE__)"
522+
condition = "defined(__aarch64__) && defined(__APPLE__)"
522523
target = _MachO(host, condition, alignment=8, prefix="_")
523524
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
524525
args = ["-fms-runtime-lib=dll"]
525526
condition = "defined(_M_ARM64)"
526527
target = _COFF(host, condition, alignment=8, args=args)
527528
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
528529
args = ["-fpic"]
529-
condition = "defined(__aarch64__)" and "defined(__linux__)"
530+
condition = "aarch64__) && defined(__linux__)"
530531
target = _ELF(host, condition, alignment=8, args=args)
531532
elif re.fullmatch(r"i686-pc-windows-msvc", host):
532533
args = ["-DPy_NO_ENABLE_SHARED"]
533534
condition = "defined(_M_IX86)"
534535
target = _COFF(host, condition, args=args, ghccc=True, prefix="_")
535536
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
536-
condition = "defined(__x86_64__)" and "defined(__APPLE__)"
537+
condition = "defined(__x86_64__) && defined(__APPLE__)"
537538
target = _MachO(host, condition, ghccc=True, prefix="_")
538539
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
539540
args = ["-fms-runtime-lib=dll"]
540541
condition = "defined(_M_X64)"
541542
target = _COFF(host, condition, args=args, ghccc=True)
542543
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
543544
args = ["-fpic"]
544-
condition = "defined(__x86_64__)" and "defined(__linux__)"
545+
condition = "defined(__x86_64__) && defined(__linux__)"
545546
target = _ELF(host, condition, args=args, ghccc=True)
546547
else:
547548
raise ValueError(host)

Tools/jit/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
with open("jit_stencils.h", "w") as fp:
4545
for idx, target in enumerate(args.target):
46-
fp.write(f"#{'if' if idx == 0 else 'elif'} defined(__{target.condition}__)\n")
46+
fp.write(f"#{'if' if idx == 0 else 'elif'} {target.condition}\n")
4747
fp.write(f'# include "jit_stencils-{target.triple}.h"\n')
4848

4949
fp.write("#else\n")

0 commit comments

Comments
 (0)