Skip to content

cmake + ci: guard -arch flag against empty CMAKE_OSX_ARCHITECTURES on macOS - #943

Merged
kirithika7 merged 2 commits into
Multicorewareinc:masterfrom
Akilan-Sivakumar:fix-cmake-empty-osx-architectures
Aug 12, 2026
Merged

cmake + ci: guard -arch flag against empty CMAKE_OSX_ARCHITECTURES on macOS#943
kirithika7 merged 2 commits into
Multicorewareinc:masterfrom
Akilan-Sivakumar:fix-cmake-empty-osx-architectures

Conversation

@Akilan-Sivakumar

Copy link
Copy Markdown
Collaborator

Problem

Native (non-cross-compiled) macOS builds crash:

clang++: error: invalid arch name '-arch -DHIGH_BIT_DEPTH=0'
make[2]: *** [asm.S.o] Segmentation fault: 11

Root cause

Both the ARM and ARM64 asm-compile branches in source/CMakeLists.txt unconditionally add -arch ${CMAKE_OSX_ARCHITECTURES} to the assembler args whenever APPLE is set, regardless of whether CMAKE_OSX_ARCHITECTURES is actually populated.

CMAKE_OSX_ARCHITECTURES is empty by default for a native build (per the CMake docs: "If CMAKE_OSX_ARCHITECTURES is not set, the compiler's default target architecture is used. For compilers provided by Xcode, this is the host machine's architecture."). With it unset, -arch ends up with no value, and the next flag in the argument list (-DHIGH_BIT_DEPTH=0) gets consumed as the arch name - producing the malformed clang invocation above, which fails to parse and crashes the compiler driver.

This branch was extended for ARM64/CROSS_COMPILE_ARM64 in #877 (to support cross-compiling x86_64 → arm64), but neither the pre-existing ARM branch nor the new ARM64 branch guards against the empty case, so a plain native build breaks.

Changes

This PR fixes the issue at both levels - the root cause in CMake, and defensive hardening in CI:

1. source/CMakeLists.txt

Guard both occurrences with if(APPLE AND CMAKE_OSX_ARCHITECTURES) so -arch is only added when the variable is explicitly set (i.e. when cross-compiling). When unset, clang falls back to its own documented native host-arch default.

2. .github/workflows/ci.yml

Explicitly set -DCMAKE_OSX_ARCHITECTURES=arm64 across all six macOS cmake invocations (8bit, 10bit, 12bit, and the three multilib components)

@kirithika7
kirithika7 merged commit fe9bc85 into Multicorewareinc:master Aug 12, 2026
72 checks passed
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.

2 participants