Skip to content

Commit ffed8d9

Browse files
authored
GH-116134: JIT aarch64-pc-windows-msvc (GH-116130)
1 parent 981f27d commit ffed8d9

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

Diff for: .github/workflows/jit.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
target:
3030
- i686-pc-windows-msvc/msvc
3131
- x86_64-pc-windows-msvc/msvc
32+
- aarch64-pc-windows-msvc/msvc
3233
- x86_64-apple-darwin/clang
3334
- aarch64-apple-darwin/clang
3435
- x86_64-unknown-linux-gnu/gcc
@@ -49,6 +50,10 @@ jobs:
4950
architecture: x64
5051
runner: windows-latest
5152
compiler: msvc
53+
- target: aarch64-pc-windows-msvc/msvc
54+
architecture: ARM64
55+
runner: windows-latest
56+
compiler: msvc
5257
- target: x86_64-apple-darwin/clang
5358
architecture: x86_64
5459
runner: macos-13
@@ -85,14 +90,21 @@ jobs:
8590
with:
8691
python-version: '3.11'
8792

88-
- name: Windows
89-
if: runner.os == 'Windows'
93+
- name: Native Windows
94+
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
9095
run: |
9196
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
9297
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
9398
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
9499
95-
- name: macOS
100+
# No PGO or tests (yet):
101+
- name: Emulated Windows
102+
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
103+
run: |
104+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
105+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
106+
107+
- name: Native macOS
96108
if: runner.os == 'macOS'
97109
run: |
98110
brew install llvm@${{ matrix.llvm }}

Diff for: Python/jit.c

+7
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
185185
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64.cpp
186186
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64Common.cpp
187187
// - https://github.com/llvm/llvm-project/blob/main/lld/MachO/Arch/ARM64Common.h
188+
// - aarch64-pc-windows-msvc:
189+
// - https://github.com/llvm/llvm-project/blob/main/lld/COFF/Chunks.cpp
188190
// - aarch64-unknown-linux-gnu:
189191
// - https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/AArch64.cpp
190192
// - i686-pc-windows-msvc:
@@ -252,6 +254,7 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
252254
assert((int64_t)value < (1LL << 31));
253255
*loc32 = (uint32_t)value;
254256
continue;
257+
case HoleKind_IMAGE_REL_ARM64_BRANCH26:
255258
case HoleKind_R_AARCH64_CALL26:
256259
case HoleKind_R_AARCH64_JUMP26:
257260
// 28-bit relative branch.
@@ -293,6 +296,7 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
293296
set_bits(loc32, 5, value, 48, 16);
294297
continue;
295298
case HoleKind_ARM64_RELOC_GOT_LOAD_PAGE21:
299+
case HoleKind_IMAGE_REL_ARM64_PAGEBASE_REL21:
296300
case HoleKind_R_AARCH64_ADR_GOT_PAGE:
297301
// 21-bit count of pages between this page and an absolute address's
298302
// 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)
302306
const Hole *next_hole = &stencil->holes[i + 1];
303307
if (i + 1 < stencil->holes_size &&
304308
(next_hole->kind == HoleKind_ARM64_RELOC_GOT_LOAD_PAGEOFF12 ||
309+
next_hole->kind == HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12L ||
305310
next_hole->kind == HoleKind_R_AARCH64_LD64_GOT_LO12_NC) &&
306311
next_hole->offset == hole->offset + 4 &&
307312
next_hole->symbol == hole->symbol &&
@@ -354,6 +359,8 @@ patch(unsigned char *base, const Stencil *stencil, uint64_t *patches)
354359
continue;
355360
case HoleKind_ARM64_RELOC_GOT_LOAD_PAGEOFF12:
356361
case HoleKind_ARM64_RELOC_PAGEOFF12:
362+
case HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12A:
363+
case HoleKind_IMAGE_REL_ARM64_PAGEOFFSET_12L:
357364
case HoleKind_R_AARCH64_LD64_GOT_LO12_NC:
358365
// 12-bit low part of an absolute address. Pairs nicely with
359366
// ARM64_RELOC_GOT_LOAD_PAGE21 (above).

Diff for: Tools/jit/_schema.py

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"ARM64_RELOC_PAGEOFF12",
99
"ARM64_RELOC_UNSIGNED",
1010
"IMAGE_REL_AMD64_REL32",
11+
"IMAGE_REL_ARM64_BRANCH26",
12+
"IMAGE_REL_ARM64_PAGEBASE_REL21",
13+
"IMAGE_REL_ARM64_PAGEOFFSET_12A",
14+
"IMAGE_REL_ARM64_PAGEOFFSET_12L",
1115
"IMAGE_REL_I386_DIR32",
1216
"IMAGE_REL_I386_REL32",
1317
"R_AARCH64_ABS64",

Diff for: Tools/jit/_targets.py

+16
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ def _handle_relocation(
238238
addend = (
239239
int.from_bytes(raw[offset : offset + 4], "little", signed=True) - 4
240240
)
241+
case {
242+
"Offset": offset,
243+
"Symbol": s,
244+
"Type": {
245+
"Value": "IMAGE_REL_ARM64_BRANCH26"
246+
| "IMAGE_REL_ARM64_PAGEBASE_REL21"
247+
| "IMAGE_REL_ARM64_PAGEOFFSET_12A"
248+
| "IMAGE_REL_ARM64_PAGEOFFSET_12L" as kind
249+
},
250+
}:
251+
offset += base
252+
value, symbol = self._unwrap_dllimport(s)
253+
addend = 0
241254
case _:
242255
raise NotImplementedError(relocation)
243256
return _stencils.Hole(offset, kind, value, symbol, addend)
@@ -435,6 +448,9 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
435448
if re.fullmatch(r"aarch64-apple-darwin.*", host):
436449
args = ["-mcmodel=large"]
437450
return _MachO(host, alignment=8, args=args, prefix="_")
451+
if re.fullmatch(r"aarch64-pc-windows-msvc", host):
452+
args = ["-fms-runtime-lib=dll"]
453+
return _COFF(host, alignment=8, args=args)
438454
if re.fullmatch(r"aarch64-.*-linux-gnu", host):
439455
args = ["-mcmodel=large"]
440456
return _ELF(host, alignment=8, args=args)

0 commit comments

Comments
 (0)