summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/jit.yml18
-rw-r--r--Python/jit.c7
-rw-r--r--Tools/jit/_schema.py4
-rw-r--r--Tools/jit/_targets.py16
4 files changed, 42 insertions, 3 deletions
diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml
index 43d0b2c..809ac45 100644
--- a/.github/workflows/jit.yml
+++ b/.github/workflows/jit.yml
@@ -29,6 +29,7 @@ jobs:
target:
- i686-pc-windows-msvc/msvc
- x86_64-pc-windows-msvc/msvc
+ - aarch64-pc-windows-msvc/msvc
- x86_64-apple-darwin/clang
- aarch64-apple-darwin/clang
- x86_64-unknown-linux-gnu/gcc
@@ -49,6 +50,10 @@ jobs:
architecture: x64
runner: windows-latest
compiler: msvc
+ - target: aarch64-pc-windows-msvc/msvc
+ architecture: ARM64
+ runner: windows-latest
+ compiler: msvc
- target: x86_64-apple-darwin/clang
architecture: x86_64
runner: macos-13
@@ -85,14 +90,21 @@ jobs:
with:
python-version: '3.11'
- - name: Windows
- if: runner.os == 'Windows'
+ - name: Native Windows
+ if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
run: |
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
- - name: macOS
+ # No PGO or tests (yet):
+ - name: Emulated Windows
+ if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
+ run: |
+ choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
+ ./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
+
+ - name: Native macOS
if: runner.os == 'macOS'
run: |
brew install llvm@${{ matrix.llvm }}
diff --git a/Python/jit.c b/Python/jit.c
index 9f9e123..dae2516 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -185,6 +185,8 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64.cpp
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64Common.cpp
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64Common.h
+ // - aarch64-pc-windows-msvc:
+ // - https://github.com/llvm/llvm-project/blob/main/lld/COFF/Chunks.cpp
// - aarch64-unknown-linux-gnu:
// - https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/AArch64.cpp
// - i686-pc-windows-msvc:
@@ -252,6 +254,7 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
assert((int64_t)value < (1LL << 31));
*loc32 = (uint32_t)value;
continue;
+ case HoleKind_IMAGE_REL_ARM64_BRANCH26:
case HoleKind_R_AARCH64_CALL26:
case HoleKind_R_AARCH64_JUMP26:
// 28-bit relative branch.
@@ -293,6 +296,7 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
set_bits(loc32, 5, value, 48, 16);
continue;
case HoleKind_ARM64_RELOC_GOT_LOAD_PAGE21:
+ case HoleKind_IMAGE_REL_ARM64_PAGEBASE_REL21:
case HoleKind_R_AARCH64_ADR_GOT_PAGE:
// 21-bit count of pages between this page and an absolute address's
// page... I know, I know, it's weird. Pairs nicely with
@@ -302,6 +306,7 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
const Hole *next_hole = &stencil->holes[i + 1];
if (i + 1 < stencil->holes_size &&
(next_hole->kind == HoleKind_ARM64_RELOC_GOT_LOAD_PAGEOFF12 ||
+ next_hole->kind == HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12L ||
next_hole->kind == HoleKind_R_AARCH64_LD64_GOT_LO12_NC) &&
next_hole->offset == hole->offset + 4 &&
next_hole->symbol == hole->symbol &&
@@ -354,6 +359,8 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
continue;
case HoleKind_ARM64_RELOC_GOT_LOAD_PAGEOFF12:
case HoleKind_ARM64_RELOC_PAGEOFF12:
+ case HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12A:
+ case HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12L:
case HoleKind_R_AARCH64_LD64_GOT_LO12_NC:
// 12-bit low part of an absolute address. Pairs nicely with
// ARM64_RELOC_GOT_LOAD_PAGE21 (above).
diff --git a/Tools/jit/_schema.py b/Tools/jit/_schema.py
index 14e5fc2..045fd50 100644
--- a/Tools/jit/_schema.py
+++ b/Tools/jit/_schema.py
@@ -8,6 +8,10 @@ HoleKind: typing.TypeAlias = typing.Literal[
"ARM64_RELOC_PAGEOFF12",
"ARM64_RELOC_UNSIGNED",
"IMAGE_REL_AMD64_REL32",
+ "IMAGE_REL_ARM64_BRANCH26",
+ "IMAGE_REL_ARM64_PAGEBASE_REL21",
+ "IMAGE_REL_ARM64_PAGEOFFSET_12A",
+ "IMAGE_REL_ARM64_PAGEOFFSET_12L",
"IMAGE_REL_I386_DIR32",
"IMAGE_REL_I386_REL32",
"R_AARCH64_ABS64",
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index 07959b1..417fdb5 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -238,6 +238,19 @@ class _COFF(
addend = (
int.from_bytes(raw[offset : offset + 4], "little", signed=True) - 4
)
+ case {
+ "Offset": offset,
+ "Symbol": s,
+ "Type": {
+ "Value": "IMAGE_REL_ARM64_BRANCH26"
+ | "IMAGE_REL_ARM64_PAGEBASE_REL21"
+ | "IMAGE_REL_ARM64_PAGEOFFSET_12A"
+ | "IMAGE_REL_ARM64_PAGEOFFSET_12L" as kind
+ },
+ }:
+ offset += base
+ value, symbol = self._unwrap_dllimport(s)
+ addend = 0
case _:
raise NotImplementedError(relocation)
return _stencils.Hole(offset, kind, value, symbol, addend)
@@ -435,6 +448,9 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
if re.fullmatch(r"aarch64-apple-darwin.*", host):
args = ["-mcmodel=large"]
return _MachO(host, alignment=8, args=args, prefix="_")
+ if 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):
args = ["-mcmodel=large"]
return _ELF(host, alignment=8, args=args)