"""Target-specific code generation, parsing, and processing."""
+
import asyncio
import dataclasses
import hashlib
args: typing.Sequence[str] = ()
ghccc: bool = False
prefix: str = ""
+ stable: bool = False
debug: bool = False
- force: bool = False
verbose: bool = False
def _compute_digest(self, out: pathlib.Path) -> str:
tasks.append(group.create_task(coro, name=opname))
return {task.get_name(): task.result() for task in tasks}
- def build(self, out: pathlib.Path, *, comment: str = "") -> None:
+ def build(
+ self, out: pathlib.Path, *, comment: str = "", force: bool = False
+ ) -> None:
"""Build jit_stencils.h in the given directory."""
+ if not self.stable:
+ warning = f"JIT support for {self.triple} is still experimental!"
+ request = "Please report any issues you encounter.".center(len(warning))
+ outline = "=" * len(warning)
+ print("\n".join(["", outline, warning, request, outline, ""]))
digest = f"// {self._compute_digest(out)}\n"
jit_stencils = out / "jit_stencils.h"
if (
- not self.force
+ not force
and jit_stencils.exists()
and jit_stencils.read_text().startswith(digest)
):
} | {
"Offset": offset,
"Symbol": {"Name": s},
- "Type": {
- "Name": "X86_64_RELOC_BRANCH" | "X86_64_RELOC_SIGNED" as kind
- },
+ "Type": {"Name": "X86_64_RELOC_BRANCH" | "X86_64_RELOC_SIGNED" as kind},
}:
offset += base
s = s.removeprefix(self.prefix)
def get_target(host: str) -> _COFF | _ELF | _MachO:
"""Build a _Target for the given host "triple" and options."""
# ghccc currently crashes Clang when combined with musttail on aarch64. :(
+ target: _COFF | _ELF | _MachO
if re.fullmatch(r"aarch64-apple-darwin.*", host):
- return _MachO(host, alignment=8, prefix="_")
- if re.fullmatch(r"aarch64-pc-windows-msvc", host):
+ target = _MachO(host, alignment=8, prefix="_")
+ elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll"]
- return _COFF(host, alignment=8, args=args)
- if re.fullmatch(r"aarch64-.*-linux-gnu", host):
+ target = _COFF(host, alignment=8, args=args)
+ elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
args = ["-fpic"]
- return _ELF(host, alignment=8, args=args)
- if re.fullmatch(r"i686-pc-windows-msvc", host):
+ target = _ELF(host, alignment=8, args=args)
+ elif re.fullmatch(r"i686-pc-windows-msvc", host):
args = ["-DPy_NO_ENABLE_SHARED"]
- return _COFF(host, args=args, ghccc=True, prefix="_")
- if re.fullmatch(r"x86_64-apple-darwin.*", host):
- return _MachO(host, ghccc=True, prefix="_")
- if re.fullmatch(r"x86_64-pc-windows-msvc", host):
+ target = _COFF(host, args=args, ghccc=True, prefix="_")
+ elif re.fullmatch(r"x86_64-apple-darwin.*", host):
+ target = _MachO(host, ghccc=True, prefix="_")
+ elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
args = ["-fms-runtime-lib=dll"]
- return _COFF(host, args=args, ghccc=True)
- if re.fullmatch(r"x86_64-.*-linux-gnu", host):
+ target = _COFF(host, args=args, ghccc=True)
+ elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
args = ["-fpic"]
- return _ELF(host, args=args, ghccc=True)
- raise ValueError(host)
+ target = _ELF(host, args=args, ghccc=True)
+ else:
+ raise ValueError(host)
+ return target