[PR #49] fix: keep iOS arm64 cgo off LDAPR #49

Open
opened 2026-10-13 21:08:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-apple/pull/49
Author: @flood4life
Created: 9/26/2026
Status: 🔄 Open

Base: master ← Head: fix/ios-arm64-no-ldapr


📝 Commits (1)

  • 8d37364 fix: keep iOS arm64 cgo off LDAPR

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 Sources/WireGuardKitGo/Makefile (+6 -1)

📄 Description

Summary

  • Apple Clang can lower __atomic_load_n(..., __ATOMIC_CONSUME) in Go's cgo runtime to LDAPR. A10 and A11 do not implement that instruction, so AmneziaVPNNetworkExtension SIGILLs in _cgo_wait_runtime_init_done on the first call into libwg-go (wgSetLogger).
  • Build the iphoneos arm64 c-archive with -mcpu=apple-a10 and rcpc/lse disabled, and set GOARM64=v8.0. macOS CGO_CFLAGS stay -arch only.

Reported on the client: https://github.com/amnezia-vpn/amnezia-client/issues/2946

The client recipe downloads a tag, not master. After this merges, it needs a tag. https://github.com/amnezia-vpn/amnezia-client/pull/3217 is blocked on that tag and will bump awg-apple to it.

Tested

Local build of this Makefile diff on Xcode 26.6 and Go 1.26.7. master before this PR was the same Makefile blob as tag v3.1.4 (16cb2d58); the blob in this PR is 6c9652bd.

  • make ARCHS=arm64 PLATFORM_NAME=iphoneos produced libwg-go-arm64.a (41,829,664 bytes) with zero 4-byte-aligned words matching 0xF8BFC000.
  • __cgo_wait_runtime_init_done+20 is ldar x8, [x8] (0xC8DFFD08), not the crash instruction ldapr x8, [x8] (0xF8BFC108).
  • On this Clang, -arch arm64 alone already emits LDAR. -mcpu=apple-m1 emits ldapr x8, [x8], and these flags turn that into LDAR.
  • make -p ARCHS="arm64 x86_64" PLATFORM_NAME=macosx expands CGO_ARM64_BASELINE to empty. macOS CGO_CFLAGS stay the SDK plus -arch.

Not covered: an A10 iPad, and the client's Bake-Prebuilts-iOS job (Go 1.26.0). A clean scan does not prove the tunnel connects. If the scan is clean and the iPad still SIGILLs, check the new crash PC before changing anything else. Clang can also emit LDAPUR.

Test plan

  • make ARCHS=arm64 PLATFORM_NAME=iphoneos and confirm libwg-go-arm64.a has no LDAPR Xt, [Xn] words (encoding & 0xFFFFFC00 == 0xF8BFC000)
  • __cgo_wait_runtime_init_done uses LDAR
  • PLATFORM_NAME=macosx leaves CGO_CFLAGS as the SDK plus -arch only
  • Tag the merge and connect a self-hosted AmneziaWG profile from an A10 iPad

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-apple/pull/49 **Author:** [@flood4life](https://github.com/flood4life) **Created:** 9/26/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/ios-arm64-no-ldapr` --- ### 📝 Commits (1) - [`8d37364`](https://github.com/amnezia-vpn/amneziawg-apple/commit/8d373648a273df0ad760d884a08eae56a54e6db3) fix: keep iOS arm64 cgo off LDAPR ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Sources/WireGuardKitGo/Makefile` (+6 -1) </details> ### 📄 Description ## Summary - Apple Clang can lower `__atomic_load_n(..., __ATOMIC_CONSUME)` in Go's cgo runtime to `LDAPR`. A10 and A11 do not implement that instruction, so `AmneziaVPNNetworkExtension` SIGILLs in `_cgo_wait_runtime_init_done` on the first call into `libwg-go` (`wgSetLogger`). - Build the iphoneos arm64 c-archive with `-mcpu=apple-a10` and `rcpc`/`lse` disabled, and set `GOARM64=v8.0`. macOS `CGO_CFLAGS` stay `-arch` only. Reported on the client: https://github.com/amnezia-vpn/amnezia-client/issues/2946 The client recipe downloads a tag, not `master`. After this merges, it needs a tag. https://github.com/amnezia-vpn/amnezia-client/pull/3217 is blocked on that tag and will bump `awg-apple` to it. ## Tested Local build of this Makefile diff on Xcode 26.6 and Go 1.26.7. `master` before this PR was the same Makefile blob as tag `v3.1.4` (`16cb2d58`); the blob in this PR is `6c9652bd`. - `make ARCHS=arm64 PLATFORM_NAME=iphoneos` produced `libwg-go-arm64.a` (41,829,664 bytes) with zero 4-byte-aligned words matching `0xF8BFC000`. - `__cgo_wait_runtime_init_done+20` is `ldar x8, [x8]` (`0xC8DFFD08`), not the crash instruction `ldapr x8, [x8]` (`0xF8BFC108`). - On this Clang, `-arch arm64` alone already emits `LDAR`. `-mcpu=apple-m1` emits `ldapr x8, [x8]`, and these flags turn that into `LDAR`. - `make -p ARCHS="arm64 x86_64" PLATFORM_NAME=macosx` expands `CGO_ARM64_BASELINE` to empty. macOS `CGO_CFLAGS` stay the SDK plus `-arch`. Not covered: an A10 iPad, and the client's `Bake-Prebuilts-iOS` job (Go 1.26.0). A clean scan does not prove the tunnel connects. If the scan is clean and the iPad still SIGILLs, check the new crash PC before changing anything else. Clang can also emit `LDAPUR`. ## Test plan - [x] `make ARCHS=arm64 PLATFORM_NAME=iphoneos` and confirm `libwg-go-arm64.a` has no `LDAPR Xt, [Xn]` words (`encoding & 0xFFFFFC00 == 0xF8BFC000`) - [x] `__cgo_wait_runtime_init_done` uses `LDAR` - [x] `PLATFORM_NAME=macosx` leaves `CGO_CFLAGS` as the SDK plus `-arch` only - [ ] Tag the merge and connect a self-hosted AmneziaWG profile from an A10 iPad --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-apple#49
No description provided.