fix: use explicit zig arch targets instead of native#21682
Merged
Conversation
569345d to
0ce4775
Compare
mrzeszutko
approved these changes
Mar 18, 2026
mrzeszutko
left a comment
Contributor
There was a problem hiding this comment.
I tested in a devcontainer on mac with M3 (NO_CACHE=1) and it works
## 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)
dff3b9a to
22ba61d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #21685. Fixes SIGILL crashes on ARM64 Mac devcontainers caused by zig's
-target nativedetecting host CPU features (SVE on Graviton) and emitting instructions Apple Silicon can't execute.#21611 tried to fix this with
-march=genericfrom 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:-target nativewith explicitaarch64/x86_64targets on both architectures, preventing host-specific CPU feature detection (SVE, AVX-512, etc.). Error on unsupported architectures.-march=skylakeon x86, skip on ARM. RemoveTARGET_ARCHvariable and auto-detection logic entirely.TARGET_ARCHentries from cross-compile presets (invalidgenericon arm64-linux, redundantskylakeon amd64-linux/windows).Note on TARGET_ARCH removal
TARGET_ARCHwas originally introduced in #2660 (Oct 2023) so thepublish-bb.ymlGitHub Actions workflow could targetwestmerefor 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=westmereor a new variable). For now, all consumers are assumed to be on modern hardware where skylake is the minimum.Test plan
NO_CACHE=1rebuild produces working binaries (no SIGILL)