Skip to content

fix: use explicit zig arch targets instead of native#21682

Merged
AztecBot merged 1 commit into
nextfrom
cl/arm_arch_fix
Apr 24, 2026
Merged

fix: use explicit zig arch targets instead of native#21682
AztecBot merged 1 commit into
nextfrom
cl/arm_arch_fix

Conversation

@charlielye

@charlielye charlielye commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Supersedes #21685. Fixes SIGILL crashes on ARM64 Mac devcontainers caused by zig's -target native detecting host CPU features (SVE on Graviton) and emitting instructions Apple Silicon can't execute.

#21611 tried to fix this with -march=generic from cmake, but that's not a valid AArch64 flag — zig silently ignored it. #21685 fixed ARM only; this PR also fixes x86 and simplifies the architecture targeting:

  • zig wrappers: Replace -target native with explicit aarch64/x86_64 targets on both architectures, preventing host-specific CPU feature detection (SVE, AVX-512, etc.). Error on unsupported architectures.
  • arch.cmake: Hardcode -march=skylake on x86, skip on ARM. Remove TARGET_ARCH variable and auto-detection logic entirely.
  • CMakePresets.json: Remove all TARGET_ARCH entries from cross-compile presets (invalid generic on arm64-linux, redundant skylake on amd64-linux/windows).

Note on TARGET_ARCH removal

TARGET_ARCH was originally introduced in #2660 (Oct 2023) so the publish-bb.yml GitHub Actions workflow could target westmere for broader x86 compatibility when shipping standalone bb binaries. That workflow was deleted in #12347 (Feb 2025), so there are no remaining consumers of configurable arch targeting.

If bb binaries are ever distributed to end users on pre-skylake x86 hardware again, this would need to be reintroduced (e.g. via -DCMAKE_CXX_FLAGS=-march=westmere or a new variable). For now, all consumers are assumed to be on modern hardware where skylake is the minimum.

Test plan

  • CI barretenberg build passes on ARM and x86
  • M3 devcontainer: NO_CACHE=1 rebuild produces working binaries (no SIGILL)

@charlielye charlielye added the ci-barretenberg Run all barretenberg/cpp checks. label Mar 17, 2026
@charlielye charlielye force-pushed the cl/arm_arch_fix branch 3 times, most recently from 569345d to 0ce4775 Compare March 17, 2026 18:20
@charlielye charlielye added ci-full-no-test-cache and removed ci-barretenberg Run all barretenberg/cpp checks. labels Mar 17, 2026

@mrzeszutko mrzeszutko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested in a devcontainer on mac with M3 (NO_CACHE=1) and it works

Base automatically changed from merge-train/spartan to next March 20, 2026 22:34
## Summary

Supersedes #21685. Fixes SIGILL crashes on ARM64 Mac devcontainers caused by zig's `-target native` detecting host CPU features (SVE on Graviton) and emitting instructions Apple Silicon can't execute.

#21611 tried to fix this with `-march=generic` from cmake, but that's not a valid AArch64 flag — zig silently ignored it. #21685 fixed ARM only; this PR also fixes x86 and simplifies the architecture targeting:

- **zig wrappers**: Replace `-target native` with explicit `aarch64`/`x86_64` targets on both architectures, preventing host-specific CPU feature detection (SVE, AVX-512, etc.). Error on unsupported architectures.
- **arch.cmake**: Hardcode `-march=skylake` on x86, skip on ARM. Remove `TARGET_ARCH` variable and auto-detection logic entirely.
- **CMakePresets.json**: Remove all `TARGET_ARCH` entries from cross-compile presets (invalid `generic` on arm64-linux, redundant `skylake` on amd64-linux/windows).

## Note on TARGET_ARCH removal

`TARGET_ARCH` was originally introduced in #2660 (Oct 2023) so the `publish-bb.yml` GitHub Actions workflow could target `westmere` for broader x86 compatibility when shipping standalone bb binaries. That workflow was deleted in #12347 (Feb 2025), so there are no remaining consumers of configurable arch targeting.

If bb binaries are ever distributed to end users on pre-skylake x86 hardware again, this would need to be reintroduced (e.g. via `-DCMAKE_CXX_FLAGS=-march=westmere` or a new variable). For now, all consumers are assumed to be on modern hardware where skylake is the minimum.

## Test plan
- [ ] CI barretenberg build passes on ARM and x86
- [ ] M3 devcontainer: `NO_CACHE=1` rebuild produces working binaries (no SIGILL)
@AztecBot AztecBot enabled auto-merge April 24, 2026 07:17
@AztecBot AztecBot added this pull request to the merge queue Apr 24, 2026
Merged via the queue into next with commit bf60496 Apr 24, 2026
20 checks passed
@AztecBot AztecBot deleted the cl/arm_arch_fix branch April 24, 2026 08:07
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