Skip to content

feat: add Windows ARM64 and FreeBSD amd64 support#32

Merged
kolkov merged 5 commits intomainfrom
feature/windows-arm64
Mar 29, 2026
Merged

feat: add Windows ARM64 and FreeBSD amd64 support#32
kolkov merged 5 commits intomainfrom
feature/windows-arm64

Conversation

@kolkov
Copy link
Copy Markdown
Contributor

@kolkov kolkov commented Mar 29, 2026

Summary

  • Windows ARM64 (Snapdragon X) support -- extended existing AAPCS64 ARM64 implementation to Windows via build tag changes. Zero new assembly -- Windows ARM64 ABI is identical to Unix ARM64 for non-variadic functions. Tested on Samsung Galaxy Book 4 Edge (Snapdragon X Elite) by @SideFx
  • FreeBSD amd64 support -- added libc.so.7 dynamic loading (dl_freebsd.go, dl_freebsd_nocgo.go). Extended 15+ build tags to include freebsd
  • CI cross-compilation -- new job validates all 7 platforms compile: linux/darwin/windows x amd64+arm64 + freebsd/amd64

Key findings from research

  • syscall.SyscallN is broken for float args on ARM64 Windows (Go runtime TODO in asmstdcall) -- used runtime.cgocall instead
  • runtime.cgocall works on Windows without fakecgo (cgocall.go:135 explicitly exempts Windows)
  • FreeBSD dlopen lives in libc.so.7 (not libdl.so.2), requires -gcflags for fakecgo

Platform support: 6 -> 7 targets

Platform Arch Status
Windows ARM64 NEW -- tested on Snapdragon X Elite
FreeBSD AMD64 NEW -- cross-compile verified

Resolves #31

Test plan

  • All tests pass on Windows AMD64 (host)
  • All tests pass on Snapdragon X Elite (Windows ARM64) -- confirmed by @SideFx
  • Cross-compilation succeeds for all 7 platforms
  • CI green (lint, formatting, tests on 3 platforms, benchmarks, quality gate)
  • go fmt ./... clean
  • No private files committed (.claude/, docs/dev/, tmp/)

kolkov added 5 commits March 29, 2026 10:55
Extend AAPCS64 ARM64 implementation to Windows by adding 'windows'
to build constraints. Windows ARM64 uses identical calling convention
to Unix ARM64 (confirmed by Microsoft docs, purego, and libffi).

No new assembly needed — runtime.cgocall works on Windows without
fakecgo (Go runtime explicitly exempts Windows from iscgo check).

Changes:
- Rename call_unix.go -> call_arm64.go (now serves 3 OS)
- Rename syscall_unix_arm64.go/s -> syscall_arm64.go/s
- Extend dl_windows.go and callback_windows.go to all GOARCH

Resolves #31
Adds a cross-compile job that builds for all supported targets:
linux/amd64, linux/arm64, darwin/amd64, darwin/arm64,
windows/amd64, windows/arm64, freebsd/amd64.

This catches build tag errors for platforms without native CI runners
(Windows ARM64 has no GitHub Actions runner available).
…ure)

freebsd/amd64 fails cross-compilation due to:
- fakecgo/freebsd.go: cgo_export_dynamic not allowed with CGO_ENABLED=0
- amd64 Execute method missing for freebsd (build tag excludes it)

This is a pre-existing issue unrelated to Windows ARM64 changes.
Tracked in #32.
FreeBSD uses System V AMD64 ABI (identical to Linux) but differs in:
- dlopen/dlsym live in libc.so.7 (not libdl.so.2)
- RTLD_DEFAULT matches macOS value, not Linux
- fakecgo requires -gcflags="...=-std" for cgo_export_dynamic

Changes:
- Add internal/dl/dl_freebsd.go (RTLD constants)
- Add internal/dl/dl_freebsd_nocgo.go (libc.so.7 imports)
- Extend build tags in 15 files to include freebsd
- CI cross-compile includes freebsd/amd64 with gcflags workaround
- README: platform table updated (7 targets), roadmap v0.5.0 entry
- ARCHITECTURE.md: platform matrix with Windows ARM64 and FreeBSD
- CHANGELOG: v0.5.0 entry with all changes
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov kolkov merged commit ca3231c into main Mar 29, 2026
19 checks passed
@kolkov kolkov deleted the feature/windows-arm64 branch March 29, 2026 11:43
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.

Windows arm64 not supported (yet)

1 participant