From 59722849382468322ca5a1214221852172a20a34 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 29 Mar 2026 10:55:42 +0300 Subject: [PATCH 1/5] feat: add Windows ARM64 support via build tag extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- ffi/callback_windows.go | 2 +- ffi/dl_windows.go | 2 +- internal/arch/arm64/{call_unix.go => call_arm64.go} | 7 ++++--- .../syscall/{syscall_unix_arm64.go => syscall_arm64.go} | 6 +++--- internal/syscall/{syscall_unix_arm64.s => syscall_arm64.s} | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) rename internal/arch/arm64/{call_unix.go => call_arm64.go} (96%) rename internal/syscall/{syscall_unix_arm64.go => syscall_arm64.go} (94%) rename internal/syscall/{syscall_unix_arm64.s => syscall_arm64.s} (98%) diff --git a/ffi/callback_windows.go b/ffi/callback_windows.go index 0c6b29f..c8ce0b1 100644 --- a/ffi/callback_windows.go +++ b/ffi/callback_windows.go @@ -1,4 +1,4 @@ -//go:build windows && amd64 +//go:build windows // Package ffi provides Foreign Function Interface capabilities. // This file contains Windows-specific callback implementation using syscall.NewCallback. diff --git a/ffi/dl_windows.go b/ffi/dl_windows.go index 4e47c86..a4528b8 100644 --- a/ffi/dl_windows.go +++ b/ffi/dl_windows.go @@ -1,4 +1,4 @@ -//go:build windows && amd64 +//go:build windows package ffi diff --git a/internal/arch/arm64/call_unix.go b/internal/arch/arm64/call_arm64.go similarity index 96% rename from internal/arch/arm64/call_unix.go rename to internal/arch/arm64/call_arm64.go index c7b6dfa..20f1436 100644 --- a/internal/arch/arm64/call_unix.go +++ b/internal/arch/arm64/call_arm64.go @@ -1,7 +1,8 @@ -//go:build arm64 && (linux || darwin) +//go:build arm64 && (linux || darwin || windows) -// Unix implementation using AAPCS64 ABI (Linux, macOS on ARM64) -// This implementation follows the ARM64 Procedure Call Standard. +// AAPCS64 ABI implementation (Linux, macOS, Windows on ARM64) +// Windows ARM64 uses the same calling convention as Unix ARM64 for non-variadic functions. +// See: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions package arm64 diff --git a/internal/syscall/syscall_unix_arm64.go b/internal/syscall/syscall_arm64.go similarity index 94% rename from internal/syscall/syscall_unix_arm64.go rename to internal/syscall/syscall_arm64.go index c3841f6..fe3c636 100644 --- a/internal/syscall/syscall_unix_arm64.go +++ b/internal/syscall/syscall_arm64.go @@ -1,7 +1,7 @@ -//go:build (linux || darwin) && arm64 +//go:build (linux || darwin || windows) && arm64 -// AAPCS64 ABI syscall implementation (Linux, macOS on ARM64) -// ARM64 Procedure Call Standard - identical on all Unix-like systems. +// AAPCS64 ABI syscall implementation (Linux, macOS, Windows on ARM64) +// ARM64 Procedure Call Standard - identical across all platforms. package syscall import ( diff --git a/internal/syscall/syscall_unix_arm64.s b/internal/syscall/syscall_arm64.s similarity index 98% rename from internal/syscall/syscall_unix_arm64.s rename to internal/syscall/syscall_arm64.s index 1993e29..a12a700 100644 --- a/internal/syscall/syscall_unix_arm64.s +++ b/internal/syscall/syscall_arm64.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && arm64 +//go:build (linux || darwin || windows) && arm64 #include "textflag.h" #include "abi_arm64.h" From c620e1c957bfa082e7a02068ab8d6b6f67568b92 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 29 Mar 2026 11:04:48 +0300 Subject: [PATCH 2/5] ci: add cross-compilation check for all 7 platforms 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). --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a92d4fd..91682eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,52 @@ jobs: fi echo "All files are properly formatted ✓" + # Cross-compilation - Verify all 7 supported platforms compile + cross-compile: + name: Cross-Compile + runs-on: ubuntu-latest + needs: [lint, formatting] + env: + CGO_ENABLED: 0 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.25' + cache: true + + - name: Cross-compile all platforms + run: | + targets=( + "linux/amd64" + "linux/arm64" + "darwin/amd64" + "darwin/arm64" + "windows/amd64" + "windows/arm64" + "freebsd/amd64" + ) + FAILED=0 + for target in "${targets[@]}"; do + os="${target%%/*}" + arch="${target##*/}" + echo "Building ${os}/${arch}..." + if GOOS=$os GOARCH=$arch go build ./... 2>&1; then + echo " ✅ ${os}/${arch}" + else + echo " ❌ ${os}/${arch} FAILED" + FAILED=1 + fi + done + if [ $FAILED -eq 1 ]; then + echo "❌ Cross-compilation check FAILED" + exit 1 + fi + echo "✅ All 7 platforms compile successfully" + # Unit tests - Platform-specific (Linux + Windows + macOS AMD64) test: name: Test - ${{ matrix.os }} @@ -277,7 +323,7 @@ jobs: # Final status - All checks passed ci-success: name: CI Success - needs: [lint, formatting, test, benchmarks, quality-gate] + needs: [lint, formatting, cross-compile, test, benchmarks, quality-gate] runs-on: ubuntu-latest if: success() steps: @@ -286,6 +332,7 @@ jobs: echo "✅ All CI checks passed!" echo "✅ Lint: PASSED" echo "✅ Formatting: PASSED" + echo "✅ Cross-Compile: PASSED (7 platforms)" echo "✅ Tests: PASSED" echo " - Linux AMD64 (ubuntu-latest)" echo " - Windows AMD64 (windows-latest)" @@ -293,5 +340,5 @@ jobs: echo "✅ Benchmarks: PASSED" echo "✅ Quality Gate: PASSED" echo "" - echo "Note: macOS Intel uses same ABI as Linux AMD64" + echo "Note: Windows ARM64 cross-compile verified, runtime tested by community" echo "🚀 Ready for merge!" From dcc60b33cf4246dfd4abeb4a33ff1c39c85b2fac Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 29 Mar 2026 11:29:35 +0300 Subject: [PATCH 3/5] ci: exclude freebsd/amd64 from cross-compile (pre-existing build failure) 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. --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91682eb..d7ca9fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,7 +109,8 @@ jobs: "darwin/arm64" "windows/amd64" "windows/arm64" - "freebsd/amd64" + # freebsd/amd64 excluded: fakecgo cgo_export_dynamic + missing Execute + # See: https://github.com/go-webgpu/goffi/issues/32 ) FAILED=0 for target in "${targets[@]}"; do @@ -127,7 +128,7 @@ jobs: echo "❌ Cross-compilation check FAILED" exit 1 fi - echo "✅ All 7 platforms compile successfully" + echo "✅ All 6 platforms compile successfully" # Unit tests - Platform-specific (Linux + Windows + macOS AMD64) test: @@ -332,7 +333,7 @@ jobs: echo "✅ All CI checks passed!" echo "✅ Lint: PASSED" echo "✅ Formatting: PASSED" - echo "✅ Cross-Compile: PASSED (7 platforms)" + echo "✅ Cross-Compile: PASSED (6 platforms)" echo "✅ Tests: PASSED" echo " - Linux AMD64 (ubuntu-latest)" echo " - Windows AMD64 (windows-latest)" From 0afd22ba799c915daa0b6b2f1b9e59fd10cf7ee1 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 29 Mar 2026 11:58:09 +0300 Subject: [PATCH 4/5] feat: add FreeBSD amd64 support 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 --- .github/workflows/ci.yml | 18 ++++++++++++---- ffi/callback.go | 2 +- ffi/callback_arm64.go | 2 +- ffi/callback_test.go | 2 +- ffi/cgo_unsupported.go | 2 +- ffi/dl_unix.go | 4 ++-- ffi/fakecgo_unix.go | 2 +- internal/arch/amd64/call_unix.go | 2 +- internal/dl/dl_freebsd.go | 30 ++++++++++++++++++++++++++ internal/dl/dl_freebsd_nocgo.go | 15 +++++++++++++ internal/dl/dl_stubs_arm64.s | 2 +- internal/dl/dl_stubs_unix.s | 2 +- internal/dl/dl_unix.go | 2 +- internal/dl/dl_wrappers_arm64.s | 2 +- internal/dl/dl_wrappers_unix.s | 2 +- internal/syscall/syscall_unix_amd64.go | 2 +- internal/syscall/syscall_unix_amd64.s | 2 +- 17 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 internal/dl/dl_freebsd.go create mode 100644 internal/dl/dl_freebsd_nocgo.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7ca9fa..bf46060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,8 +109,6 @@ jobs: "darwin/arm64" "windows/amd64" "windows/arm64" - # freebsd/amd64 excluded: fakecgo cgo_export_dynamic + missing Execute - # See: https://github.com/go-webgpu/goffi/issues/32 ) FAILED=0 for target in "${targets[@]}"; do @@ -124,11 +122,23 @@ jobs: FAILED=1 fi done + + # FreeBSD requires -gcflags="-std" for fakecgo's //go:cgo_export_dynamic + echo "Building freebsd/amd64 (with -gcflags for fakecgo)..." + if GOOS=freebsd GOARCH=amd64 go build \ + -gcflags="github.com/go-webgpu/goffi/internal/fakecgo=-std" \ + ./... 2>&1; then + echo " ✅ freebsd/amd64" + else + echo " ❌ freebsd/amd64 FAILED" + FAILED=1 + fi + if [ $FAILED -eq 1 ]; then echo "❌ Cross-compilation check FAILED" exit 1 fi - echo "✅ All 6 platforms compile successfully" + echo "✅ All 7 platforms compile successfully" # Unit tests - Platform-specific (Linux + Windows + macOS AMD64) test: @@ -333,7 +343,7 @@ jobs: echo "✅ All CI checks passed!" echo "✅ Lint: PASSED" echo "✅ Formatting: PASSED" - echo "✅ Cross-Compile: PASSED (6 platforms)" + echo "✅ Cross-Compile: PASSED (7 platforms)" echo "✅ Tests: PASSED" echo " - Linux AMD64 (ubuntu-latest)" echo " - Windows AMD64 (windows-latest)" diff --git a/ffi/callback.go b/ffi/callback.go index 29aa1e7..a5d3814 100644 --- a/ffi/callback.go +++ b/ffi/callback.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && amd64 +//go:build (linux || darwin || freebsd) && amd64 // Package ffi provides callback support for Foreign Function Interface (Unix version). // This file implements Go function registration as C callbacks using diff --git a/ffi/callback_arm64.go b/ffi/callback_arm64.go index c6e84cc..c14e17e 100644 --- a/ffi/callback_arm64.go +++ b/ffi/callback_arm64.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && arm64 +//go:build (linux || darwin || freebsd) && arm64 // Package ffi provides callback support for Foreign Function Interface (ARM64 Unix version). // This file implements Go function registration as C callbacks using diff --git a/ffi/callback_test.go b/ffi/callback_test.go index 26ae557..454b3d1 100644 --- a/ffi/callback_test.go +++ b/ffi/callback_test.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && (amd64 || arm64) +//go:build (linux || darwin || freebsd) && (amd64 || arm64) package ffi diff --git a/ffi/cgo_unsupported.go b/ffi/cgo_unsupported.go index 35195ab..2588d89 100644 --- a/ffi/cgo_unsupported.go +++ b/ffi/cgo_unsupported.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && cgo +//go:build (linux || darwin || freebsd) && cgo // Package ffi cannot be built with CGO_ENABLED=1. // diff --git a/ffi/dl_unix.go b/ffi/dl_unix.go index cdbf36a..5f5e95e 100644 --- a/ffi/dl_unix.go +++ b/ffi/dl_unix.go @@ -1,6 +1,6 @@ -//go:build linux && (amd64 || arm64) && !cgo +//go:build (linux || freebsd) && (amd64 || arm64) && !cgo -// Linux library loading - OUR OWN implementation (NO dependencies!) +// Unix library loading via dlopen - OUR OWN implementation (NO dependencies!) // // Status: ✅ FULLY WORKING // ✅ syscall6 (internal/syscall) - Core C function calls (~30ns overhead) diff --git a/ffi/fakecgo_unix.go b/ffi/fakecgo_unix.go index 0b3b176..34c7e51 100644 --- a/ffi/fakecgo_unix.go +++ b/ffi/fakecgo_unix.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && !cgo && !nofakecgo +//go:build (linux || darwin || freebsd) && !cgo && !nofakecgo package ffi diff --git a/internal/arch/amd64/call_unix.go b/internal/arch/amd64/call_unix.go index e085eab..7131a04 100644 --- a/internal/arch/amd64/call_unix.go +++ b/internal/arch/amd64/call_unix.go @@ -1,4 +1,4 @@ -//go:build amd64 && (linux || darwin) +//go:build amd64 && (linux || darwin || freebsd) // Unix implementation using System V AMD64 ABI (Linux, macOS, FreeBSD, etc.) // This implementation closely follows purego's proven approach but is OUR OWN code. diff --git a/internal/dl/dl_freebsd.go b/internal/dl/dl_freebsd.go new file mode 100644 index 0000000..adbd763 --- /dev/null +++ b/internal/dl/dl_freebsd.go @@ -0,0 +1,30 @@ +//go:build freebsd + +// FreeBSD-specific constants for dynamic library loading. +// +// FreeBSD uses the same POSIX dlopen/dlsym API as Linux and macOS. +// RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_LAZY match Linux values. +// RTLD_DEFAULT matches macOS value (not Linux). +// +// Reference: https://github.com/freebsd/freebsd-src/blob/main/include/dlfcn.h + +package dl + +// RTLD constants from for dynamic library loading on FreeBSD. +const ( + // RTLD_LAZY performs relocations at an implementation-dependent time. + RTLD_LAZY = 0x00001 + + // RTLD_NOW resolves all symbols when loading the library (recommended). + RTLD_NOW = 0x00002 + + // RTLD_GLOBAL makes all symbols available for relocation processing of other modules. + RTLD_GLOBAL = 0x00100 + + // RTLD_LOCAL makes symbols not available for relocation processing by other modules. + RTLD_LOCAL = 0x00000 +) + +// RTLD_DEFAULT is a pseudo-handle for dlsym to search for any loaded symbol. +// Same value as macOS, different from Linux (0x00000). +const RTLD_DEFAULT = 1<<64 - 2 // -2 as uintptr diff --git a/internal/dl/dl_freebsd_nocgo.go b/internal/dl/dl_freebsd_nocgo.go new file mode 100644 index 0000000..b6aee4c --- /dev/null +++ b/internal/dl/dl_freebsd_nocgo.go @@ -0,0 +1,15 @@ +//go:build freebsd && !cgo + +package dl + +// Link to libc.so.7 functions using cgo_import_dynamic. +// On FreeBSD, dlopen/dlsym/dlclose are part of libc directly +// (unlike Linux where they're in a separate libdl.so.2). + +//go:cgo_import_dynamic goffi_dlopen dlopen "libc.so.7" +//go:cgo_import_dynamic goffi_dlsym dlsym "libc.so.7" +//go:cgo_import_dynamic goffi_dlerror dlerror "libc.so.7" +//go:cgo_import_dynamic goffi_dlclose dlclose "libc.so.7" + +// Force dependency on libc.so.7 +//go:cgo_import_dynamic _ _ "libc.so.7" diff --git a/internal/dl/dl_stubs_arm64.s b/internal/dl/dl_stubs_arm64.s index 866d884..a03c836 100644 --- a/internal/dl/dl_stubs_arm64.s +++ b/internal/dl/dl_stubs_arm64.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && arm64 && !cgo +//go:build (linux || darwin || freebsd) && arm64 && !cgo #include "textflag.h" diff --git a/internal/dl/dl_stubs_unix.s b/internal/dl/dl_stubs_unix.s index 466ae80..dd674e6 100644 --- a/internal/dl/dl_stubs_unix.s +++ b/internal/dl/dl_stubs_unix.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && amd64 && !cgo +//go:build (linux || darwin || freebsd) && amd64 && !cgo #include "textflag.h" diff --git a/internal/dl/dl_unix.go b/internal/dl/dl_unix.go index 78cc635..907ed0d 100644 --- a/internal/dl/dl_unix.go +++ b/internal/dl/dl_unix.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && !cgo +//go:build (linux || darwin || freebsd) && !cgo // OUR OWN Dlopen/Dlsym implementation - NO dependencies! // Uses runtime.cgocall approach similar to syscall6. diff --git a/internal/dl/dl_wrappers_arm64.s b/internal/dl/dl_wrappers_arm64.s index 145fa43..92f9534 100644 --- a/internal/dl/dl_wrappers_arm64.s +++ b/internal/dl/dl_wrappers_arm64.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && arm64 && !cgo +//go:build (linux || darwin || freebsd) && arm64 && !cgo #include "textflag.h" diff --git a/internal/dl/dl_wrappers_unix.s b/internal/dl/dl_wrappers_unix.s index 64f56dc..3ce2162 100644 --- a/internal/dl/dl_wrappers_unix.s +++ b/internal/dl/dl_wrappers_unix.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && amd64 && !cgo +//go:build (linux || darwin || freebsd) && amd64 && !cgo #include "textflag.h" diff --git a/internal/syscall/syscall_unix_amd64.go b/internal/syscall/syscall_unix_amd64.go index a54052d..7fa2bf2 100644 --- a/internal/syscall/syscall_unix_amd64.go +++ b/internal/syscall/syscall_unix_amd64.go @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && amd64 +//go:build (linux || darwin || freebsd) && amd64 // System V AMD64 ABI syscall implementation (Linux, macOS, FreeBSD, etc.) // This calling convention is IDENTICAL on all Unix-like systems. diff --git a/internal/syscall/syscall_unix_amd64.s b/internal/syscall/syscall_unix_amd64.s index 3c09d1b..bee2949 100644 --- a/internal/syscall/syscall_unix_amd64.s +++ b/internal/syscall/syscall_unix_amd64.s @@ -1,4 +1,4 @@ -//go:build (linux || darwin) && amd64 +//go:build (linux || darwin || freebsd) && amd64 #include "textflag.h" #include "abi_amd64.h" From ff326fd56dcbe8c01d2c56062f0495188af405f0 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 29 Mar 2026 14:38:39 +0300 Subject: [PATCH 5/5] docs: update platform support to 7 targets (Windows ARM64 + FreeBSD) - 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 --- CHANGELOG.md | 12 ++++++++++++ README.md | 12 +++++++----- docs/ARCHITECTURE.md | 5 +++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ea61b..4e00aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.0] - 2026-03-29 + +### Added +- **Windows ARM64 (Snapdragon X) support** — extended AAPCS64 ARM64 implementation to Windows via build tag changes. Uses `runtime.cgocall` (free on Windows without fakecgo). Tested on Samsung Galaxy Book 4 Edge with Snapdragon X Elite ([#31](https://github.com/go-webgpu/goffi/issues/31)) +- **FreeBSD amd64 support** — added `internal/dl/dl_freebsd.go` and `dl_freebsd_nocgo.go` for `libc.so.7` dynamic loading. FreeBSD uses identical System V ABI as Linux. Requires `-gcflags="github.com/go-webgpu/goffi/internal/fakecgo=-std"` for `CGO_ENABLED=0` builds +- **CI cross-compilation check** — new job validates all 7 supported platforms compile correctly (linux/darwin/windows × amd64 + arm64 + freebsd/amd64) + +### Changed +- Renamed ARM64 files to drop misleading "unix" suffix: `call_unix.go` → `call_arm64.go`, `syscall_unix_arm64.go/s` → `syscall_arm64.go/s` +- Extended `ffi/dl_windows.go` and `ffi/callback_windows.go` from `windows && amd64` to `windows` (all architectures) +- Extended 15+ build tags to include `freebsd` alongside `linux || darwin` + ## [0.4.2] - 2026-03-03 ### Fixed diff --git a/README.md b/README.md index 173ce24..a1e76f3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ffi.CallFunction(cif, sym, unsafe.Pointer(&result), args) |---|---------|---------| | **Zero CGO** | Pure Go | No C compiler needed. `go get` and build. | | **Fast** | 88–114 ns/op | Pre-computed CIF, zero per-call allocations | -| **Cross-platform** | 6 targets | Windows, Linux, macOS × AMD64 + ARM64 | +| **Cross-platform** | 7 targets | Windows, Linux, macOS, FreeBSD × AMD64 + ARM64 | | **Callbacks** | C→Go safe | `crosscall2` integration, works from any C thread | | **Type-safe** | Runtime validation | 5 typed error types with `errors.As()` support | | **Struct passing** | Full ABI | ≤8B (RAX), 9–16B (RAX+RDX), >16B (sret) | @@ -224,7 +224,7 @@ if err != nil { | Context support | Timeouts/cancellation | No | No | | C-thread callbacks | crosscall2 | crosscall2 | Full | | String/bool/slice args | Raw pointers only | Auto-marshaling | Full | -| Platform breadth | 6 targets | 8 GOARCH / 20+ OS×ARCH | All | +| Platform breadth | 7 targets | 8 GOARCH / 20+ OS×ARCH | All | | AMD64 overhead | 88–114 ns | Not published | ~140 ns (Go 1.26 claims ~30% reduction) | **Choose goffi** for GPU/real-time workloads: struct passing, zero per-call overhead, callback float returns, typed errors. @@ -266,11 +266,12 @@ if err != nil { | Platform | Arch | ABI | Since | CI | |----------|------|-----|-------|----| | Windows | amd64 | Win64 | v0.1.0 | Tested | +| Windows | arm64 | AAPCS64 | v0.5.0 | Tested (Snapdragon X) | | Linux | amd64 | System V | v0.1.0 | Tested | -| macOS | amd64 | System V | v0.1.1 | Tested | -| FreeBSD | amd64 | System V | v0.1.0 | Untested | | Linux | arm64 | AAPCS64 | v0.3.0 | Cross-compile verified | +| macOS | amd64 | System V | v0.1.1 | Tested | | macOS | arm64 | AAPCS64 | v0.3.7 | Tested (M3 Pro) | +| FreeBSD | amd64 | System V | v0.5.0 | Cross-compile verified | --- @@ -282,7 +283,8 @@ if err != nil { | v0.3.x | Released | ARM64 (AAPCS64), HFA, Apple Silicon | | v0.4.0 | Released | crosscall2 for C-thread callbacks | | v0.4.1 | Released | ABI compliance audit — 10/11 gaps fixed | -| **v0.5.0** | **Next** | Variadic functions, builder API, Windows struct packing | +| v0.4.2 | Released | purego compatibility (`-tags nofakecgo`) | +| **v0.5.0** | **Next** | Windows ARM64, FreeBSD, variadic functions, builder API | | v1.0.0 | Planned | API stability (SemVer 2.0), security audit | See [CHANGELOG.md](CHANGELOG.md) for version history and [ROADMAP.md](ROADMAP.md) for the full plan. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a5c32d7..02aa2d3 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -263,10 +263,11 @@ Five typed error types for precise error handling: `InvalidCallInterfaceError`, |----------|-------------|-----|--------| | **Linux** | AMD64 | System V | Production | | **Windows** | AMD64 | Win64 | Production | +| **Windows** | ARM64 | AAPCS64 | Production (tested on Snapdragon X) | | **macOS** | AMD64 | System V | Production | -| **FreeBSD** | AMD64 | System V | Production (untested) | -| **Linux** | ARM64 | AAPCS64 | Production | | **macOS** | ARM64 | AAPCS64 | Production (tested on M3 Pro) | +| **FreeBSD** | AMD64 | System V | Cross-compile verified | +| **Linux** | ARM64 | AAPCS64 | Production | ---