Skip to content

Add Windows ARM64 support - #138

Merged
Jarred-Sumner merged 12 commits into
mainfrom
claude/windows-arm64-support
Jan 16, 2026
Merged

Jarred-Sumner merged 12 commits into
mainfrom
claude/windows-arm64-support

Conversation

@sosukesuzuki

Copy link
Copy Markdown
Member

Summary

This PR adds Windows ARM64 (WoA) support to JavaScriptCore.

Source Code Changes

CPU Detection

  • Add _M_ARM64 MSVC macro to ARM64 CPU detection in PlatformCPU.h and BPlatform.h

Calling Conventions

  • Limit SYSV_ABI attribute to x86_64 only on Windows (ARM64 uses a different ABI)
    • PlatformCallingConventions.h
    • CodePtr.h
    • FunctionPtr.h
    • FunctionTraits.h (2 locations)
    • AbstractMacroAssembler.h

ARM64 Assembler

  • Expand LinkRecord::CopyTypes to uint64_t content[5] for Windows (different struct packing)
  • Add FlushInstructionCache() API call to cacheFlush() for Windows

Frame Pointer Handling

  • Add Windows ARM64 DECLARE_CALL_FRAME macro with x29 clobber in CallFrame.h
  • Disable USE_BUILTIN_FRAME_ADDRESS for Windows ARM64 in PlatformUse.h

Register Mappings

  • Add Windows ARM64 register mappings to MachineContext.h:
    • stackPointerImpl: regs.Sp
    • framePointerImpl: regs.Fp
    • instructionPointerImpl: regs.Pc
    • argumentPointer<1>: regs.X1
    • wasmInstancePointer: regs.X19
    • llintInstructionPointer: regs.X4

Assembler Directives

  • Exclude .previous directive for Windows in MacroAssemblerARM64.cpp (COFF doesn't support it)
  • Add Windows ARM64 currentStackPointer implementation in StackPointer.cpp

JIT/Offlineasm

  • Disable inline ASM-based unaryDoubleOpWrapper for Windows ARM64 in ThunkGenerators.cpp
  • Add Windows ARM64 COFF-style addressing to globaladdr in arm64.rb

Build System

  • Add architecture detection for clang_rt.builtins library in OptionsMSVC.cmake (aarch64 vs x86_64)

CI Changes

  • Add Windows ARM64 matrix entries using windows-11-arm runner
  • Add ARM64-specific LLVM installation step (manual download since Scoop may not have ARM64 LLVM)
  • Update Build WebKit step with -Platform parameter
  • Add Windows ARM64 artifact download/upload in release job

Testing

This PR needs to be tested on Windows ARM64 hardware via CI.

@robobun

robobun commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

/build-preview

@github-actions

Copy link
Copy Markdown

🔄 Preview build started

Release tag: autobuild-preview-pr-138-8d20fd8e
Workflow: View progress

This commit adds Windows ARM64 (WoA) support to JavaScriptCore.

Source code changes:
- Add _M_ARM64 MSVC macro to CPU detection (PlatformCPU.h, BPlatform.h)
- Limit SYSV_ABI to x86_64 only on Windows (6 files)
- Expand LinkRecord::CopyTypes for Windows and add FlushInstructionCache to cacheFlush (ARM64Assembler.h)
- Add Windows ARM64 DECLARE_CALL_FRAME macro with x29 clobber (CallFrame.h)
- Disable USE_BUILTIN_FRAME_ADDRESS for Windows ARM64 (PlatformUse.h)
- Add Windows ARM64 register mappings to MachineContext.h (Sp, Fp, Pc, X1, X19, X4)
- Exclude .previous directive for Windows (MacroAssemblerARM64.cpp)
- Add Windows ARM64 currentStackPointer implementation (StackPointer.cpp)
- Disable inline ASM unaryDoubleOpWrapper for Windows ARM64 (ThunkGenerators.cpp)
- Add Windows ARM64 COFF-style addressing to globaladdr (arm64.rb)
- Add architecture detection for clang_rt.builtins (OptionsMSVC.cmake)

CI changes:
- Add Windows ARM64 matrix entries (windows-11-arm runner)
- Add ARM64-specific LLVM installation step
- Update Build WebKit step with Platform parameter
- Add Windows ARM64 artifact download/upload in release job
@robobun
robobun force-pushed the claude/windows-arm64-support branch from 8d20fd8 to a48085e Compare January 16, 2026 09:49
@robobun

robobun commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

/build-preview

@github-actions

Copy link
Copy Markdown

⚠️ Preview build was cancelled

This may have been caused by a newer build being triggered for the same PR.

@github-actions

Copy link
Copy Markdown

🔄 Preview build started

Release tag: autobuild-preview-pr-138-a48085e2
Workflow: View progress

@github-actions

Copy link
Copy Markdown

⚠️ Preview build was cancelled

This may have been caused by a newer build being triggered for the same PR.

@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

Use the official LLVM releases URL instead of aspect-build/llvm-project
which doesn't have Windows ARM64 (woa64) builds.

The correct URL format is:
https://github.com/llvm/llvm-project/releases/download/llvmorg-<version>/LLVM-<version>-woa64.exe

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

The ICU project files specify Windows SDK 10.0.16299.0 which isn't
available on the Windows ARM64 GitHub Actions runner. Add
/p:WindowsTargetPlatformVersion=10.0 to MSBuild calls to let it pick
the latest available SDK version.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

The VS Developer Shell adds VS's bundled x64 LLVM tools to PATH before
our explicitly installed ARM64 LLVM. This caused cmake to use the x64
clang-cl which generates x64 code, but the ARM64 libraries were being
linked, causing architecture mismatch errors.

For ARM64 builds, explicitly specify the full path to the ARM64 LLVM
toolchain we installed (C:/LLVM/bin/clang-cl.exe and lld-link.exe).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

LLVM 19 has a bug in the AArch64 backend that causes SEH unwind info
errors when compiling JSC on Windows ARM64:
  "fatal error: error in backend: Failed to evaluate function length in SEH unwind info"

LLVM 21.1.8 has better Windows ARM64 support and likely fixes this issue.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

Use /clang: prefix instead of -Xclang when passing Clang-specific
flags to clang-cl. The /clang: prefix is the proper clang-cl syntax
for passing flags directly to the Clang frontend.
@github-actions

Copy link
Copy Markdown

⚠️ Preview build was cancelled

This may have been caused by a newer build being triggered for the same PR.

@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

Add -mllvm -align-loops=1 flag for Windows ARM64 builds to work around
the LLVM bug llvm/llvm-project#47432 which causes 'Failed to evaluate
function length in SEH unwind info' errors when inline assembly contains
alignment directives.

This is a known issue that affects all current LLVM versions on Windows
ARM64. The workaround disables loop alignment which prevents the compiler
from generating the problematic alignment directives in inline assembly.
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

The -mllvm -align-loops option was removed in LLVM 21. Use the
official Clang frontend -falign-loops=1 flag instead.
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

Claude Bot added 2 commits January 16, 2026 14:46
LLVM has a bug (llvm/llvm-project#47432) on Windows ARM64 that causes a
fatal error 'Failed to evaluate function length in SEH unwind info' when
inline assembly contains alignment directives like .balign.

The probe trampoline in MacroAssemblerARM64.cpp uses .balign 16 for
function alignment, which triggers this bug. Since the probe functionality
is primarily used for debugging/profiling and is not critical for normal
operation, we disable it on Windows ARM64 by wrapping the inline assembly
and probe() function in a conditional compilation guard.

A stub implementation is provided that triggers RELEASE_ASSERT if probe
is ever called on Windows ARM64, ensuring any code paths that rely on it
will be caught during development.
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

LLVM has a bug (llvm/llvm-project#47432) on Windows ARM64 that causes a
fatal error 'Failed to evaluate function length in SEH unwind info' when
inline assembly contains alignment directives like .balign/.balignl.

The LowLevelInterpreter uses alignment directives for performance
optimization (better instruction cache usage), but they are not required
for correctness. On Windows ARM64, we disable these directives to work
around the LLVM bug.
@github-actions

Copy link
Copy Markdown

❌ Preview build failed

Check the workflow run for details.

LLVM has a bug (llvm/llvm-project#47432) that causes a fatal error
"Failed to evaluate function length in SEH unwind info" when inline
assembly contains alignment directives like .p2align on Windows ARM64.

The gcSafeZeroMemory function has ARM64-specific inline assembly with
.p2align 4, which triggers this bug. Fall back to the generic scalar
implementation on Windows ARM64.
@github-actions

Copy link
Copy Markdown

✅ Preview build completed

Release: autobuild-preview-pr-138-a5af1deb

@Jarred-Sumner
Jarred-Sumner marked this pull request as ready for review January 16, 2026 19:41
@Jarred-Sumner
Jarred-Sumner merged commit c4efd9c into main Jan 16, 2026
30 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/windows-arm64-support branch January 16, 2026 19:42
@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Adds Windows ARM64 support across the WebKit build infrastructure, including platform-specific CI workflows, assembly handling, calling convention adjustments, and toolchain configuration while maintaining x86_64 compatibility.

Changes

Cohort / File(s) Summary
CI/CD Workflow Configuration
.github/workflows/build-reusable.yml, windows-release.ps1
Introduces ARM64 build matrix entries and platform-specific LLVM/Ninja installation steps; updates MSBuild invocations with explicit Windows SDK version and ARM64-aware toolchain paths; adds ARM64 artifacts to release handling.
WTF Platform Abstractions
Source/WTF/wtf/PlatformCPU.h, Source/WTF/wtf/PlatformCallingConventions.h, Source/WTF/wtf/PlatformUse.h
Expands ARM64 CPU detection to recognize MSVC's _M_ARM64 macro; restricts SYSV_ABI calling convention to Windows x86_64 only; excludes Windows ARM64 from BUILTIN_FRAME_ADDRESS support.
Code Pointer and Function Traits
Source/WTF/wtf/CodePtr.h, Source/WTF/wtf/FunctionPtr.h, Source/WTF/wtf/FunctionTraits.h
Narrows SYSV_ABI function pointer constructor overloads to Windows x86_64 only, removing them from Windows ARM64 builds.
Stack Pointer and Memory Allocator
Source/WTF/wtf/StackPointer.cpp, Source/bmalloc/bmalloc/BPlatform.h
Adds ARM64 Windows inline-assembly implementation for stack pointer retrieval; extends ARM64 CPU detection macro for MSVC builds.
ARM64 Assembler and JIT Core
Source/JavaScriptCore/assembler/ARM64Assembler.h, Source/JavaScriptCore/assembler/AbstractMacroAssembler.h, Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp
Extends CopyTypes struct for Windows ARM64; adjusts size assertion logic; adds cache flush support for Windows; disables probe trampoline generation on Windows ARM64 with stub implementation; restricts x86_64-specific constructor to that architecture.
Instruction Generation and Lowering
Source/JavaScriptCore/jit/ThunkGenerators.cpp, Source/JavaScriptCore/llint/LowLevelInterpreter.cpp, Source/JavaScriptCore/offlineasm/arm64.rb
Excludes Windows ARM64 from ARM64 inline assembly wrapper path; disables alignment directives on Windows ARM64; adds COFF-style addressing for ARM64 globaladdr lowering.
Call Frame and Machine Context
Source/JavaScriptCore/interpreter/CallFrame.h, Source/JavaScriptCore/runtime/MachineContext.h
Adds ARM64-specific DECLARE_CALL_FRAME implementation using _AddressOfReturnAddress() on Windows; extends ARM64 register mappings for stack, frame, instruction, and argument pointers.
Memory Operations
Source/JavaScriptCore/heap/GCMemoryOperations.h
Prevents ARM64 inline assembly with alignment directives on Windows due to LLVM bug; falls back to scalar code path.
CMake Configuration
Source/cmake/OptionsMSVC.cmake
Introduces architecture-aware Clang builtins library lookup; selects appropriate architecture variant based on CMAKE_SYSTEM_PROCESSOR.

Possibly related PRs


Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants