Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows on aarch64 #14911

Merged
merged 3 commits into from
Aug 18, 2024

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Aug 15, 2024

Adds ARM64-specific stack unwinding so that the prelude now compiles for Windows on ARM64.

This is tested in a UTM virtual machine only. To set up:

  • Install the MSVC build tools with ARM64/ARM64EC support (we won't be dealing with ARM64EC at all);
  • Install Crystal 1.13. Note that Windows ARM64 can run x86-64 binaries directly;
  • Check out this branch;
  • Start an MSVC native build tools shell, enter PowerShell, and then build Boehm GC and PCRE2 with the following:
    .\etc\win-ci\build-gc.ps1 -BuildTree deps\gc -Version 8.2.6 -AtomicOpsVersion 7.8.2
    .\etc\win-ci\build-gc.ps1 -BuildTree deps-md\gc -Version 8.2.6 -AtomicOpsVersion 7.8.2 -Dynamic
    .\etc\win-ci\build-pcre2.ps1 -BuildTree deps\pcre2 -Version 10.43
    .\etc\win-ci\build-pcre2.ps1 -BuildTree deps-md\pcre2 -Version 10.43 -Dynamic
  • Override the CRYSTAL_LIBRARY_PATH environment variable so that it points at the libs directory created from the previous step;
  • Use bin\crystal build --target=aarch64-pc-windows-msvc --target -Dwithout_iconv to build something; (we don't need to supply --cross-compile or build a local compiler here)
  • Copy the DLLs inside the dlls directory created above to the current directory manually, since the ones placed by the compiler are the x86-64 ones;
  • You should now have a fully working Windows ARM64 executable built by Crystal.

For convenience, the x86-64 and ARM64 Windows bindings share the same directory using a symbolic link.

The context switch reuses the existing one for AArch64 Linux, since it seems the ABIs are identical; most Fiber and select specs work, except ones that deal with closed Channels for some reason.

@@ -122,6 +122,7 @@ lib LibC
end

IMAGE_FILE_MACHINE_AMD64 = DWORD.new!(0x8664)
IMAGE_FILE_MACHINE_ARM64 = DWORD.new!(0xAA64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This const value is a neat gimmick. 😆

This reverts commit 3f3cdf4.
@straight-shoota straight-shoota merged commit f3fb7b6 into crystal-lang:master Aug 18, 2024
65 checks passed
@HertzDevil HertzDevil deleted the feature/windows-arm64 branch September 8, 2024 15:02
@straight-shoota straight-shoota changed the title Support ARM64 Windows Add support for Windows on aarch64 Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants