Skip to content

Fix macOS arm64 build: limit fenv polyfill to x86_64 - #307

Open
ethanbass wants to merge 1 commit into
genetics-statistics:masterfrom
ethanbass:macos-arm64-fenv
Open

ethanbass wants to merge 1 commit into
genetics-statistics:masterfrom
ethanbass:macos-arm64-fenv

Conversation

@ethanbass

@ethanbass ethanbass commented Oct 24, 2026 •

Copy link
Copy Markdown

Fixes #287.

The feenableexcept/fedisableexcept polyfill in src/debug.cpp reads the x86 fields fenv_t.__control and __mxcsr, which don't exist on Apple Silicon, so the build fails there. Its only callers, in enable_segfpe()/disable_segfpe(), are already inside #if defined(__x86_64__). This adds the same condition to the polyfill's guard. Nothing changes on Linux or on Intel Macs.

Tested on macOS 14 (arm64) with Apple clang and Homebrew GSL and OpenBLAS: it builds, and test/dev_tests.rb passes (4 runs, 21 assertions, 0 failures).

The C/C++ CI workflow was already failing on master (ce5e778) before this change.

Claude found this fix, built and tested it, and wrote this description. I can confirm that GEMMA didn't build on my M1 Mac before this change and it does now.

The polyfill reads fenv_t's __control and __mxcsr fields, which exist
only on Intel. On Apple Silicon fenv_t has __fpcr/__fpsr instead, so
debug.cpp fails to compile. The callers are already guarded by
__x86_64__, so the polyfill is unused on arm64.

Fixes genetics-statistics#287
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.

macOS incompatibility

1 participant