chore: fixing build on mac#21685
Merged
ludamad merged 1 commit intomerge-train/spartanfrom Mar 17, 2026
Merged
Conversation
ludamad
approved these changes
Mar 17, 2026
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.
fix: ARM64 devcontainer builds — skip
-marchon ARM and use explicit zig aarch64 targetSummary
Fixes SIGILL (Illegal Instruction) crashes and build failures on ARM64 Mac (M3/Apple Silicon) devcontainers caused by incorrect
-marchhandling introduced in #21611.Problem
PR #21611 originally fixed ARM64 devcontainer builds by using explicit
aarch64-linux-gnu.2.35zig targets. During the merge, that approach was replaced with cmake-based auto-detection that setsTARGET_ARCH=genericon ARM and passes-march=genericto the compiler. This caused two distinct failures:1. SIGILL crashes (
Illegal instruction)The zig compiler wrappers still used
-target native-linux-gnu.2.35, which auto-detects the host CPU. On CI (AWS Graviton with SVE extensions), this produces binaries containing SVE instructions. These cached binaries are then downloaded on Apple Silicon devcontainers (ARM64 without SVE), causing SIGILL when executed — e.g.honk_solidity_key_gencrashing duringbarretenberg/solbootstrap.The
-march=genericflag was supposed to override this, but-march=genericis not a valid value on aarch64. It's an x86 concept. LLVM/zig silently ignored it, so the native CPU detection still produced SVE instructions.2. Build failures (
unknown CPU: 'armv8')Even attempting
-march=armv8-a(a valid GCC/Clang aarch64 value) fails because zig uses its own CPU naming scheme (e.g.generic,cortex_a72,apple_m3), not GCC-style architecture strings. Zig interprets-march=armv8-aas CPU namearmv8, which doesn't exist →error: unknown CPU: 'armv8'.Bottom line: The
-marchcmake approach fundamentally doesn't work with zig on ARM. Zig has its own architecture targeting via-target, which is the correct mechanism.What this PR changes
1.
arch.cmake— Skip-marchauto-detection on ARMRemoved the ARM branch from the auto-detection. On x86_64, we still auto-detect
TARGET_ARCH=skylake. On ARM, we don't setTARGET_ARCHat all, so no-marchflag is passed — the zig wrappers handle architecture targeting instead.2.
zig-cc.sh/zig-c++.sh— Explicit aarch64 target on ARM LinuxRestored the original fix from #21611 that was dropped during merge. On ARM64 Linux, the wrappers now use
-target aarch64-linux-gnu.2.35instead of-target native-linux-gnu.2.35. This produces generic ARM64 code without CPU-specific extensions (SVE, etc.), ensuring cached binaries work on all ARM64 machines — Graviton, Apple Silicon, Ampere, etc.x86_64 behavior is unchanged (still uses
-target native).Context: what happened after #21611
After #21611 merged with the cmake auto-detection approach, it triggered a cascade of follow-up PRs trying to fix the fallout:
-march)NOT CMAKE_CROSSCOMPILINGguard for cross-compile failuresnative_build_dirCMAKE_SYSTEM_PROCESSORto ARM64 cross-compile presetsThis PR supersedes the still-open PRs above by addressing the root cause:
-marchvia cmake doesn't work with zig on ARM. The zig-targetmechanism is the correct approach.