cmake + ci: guard -arch flag against empty CMAKE_OSX_ARCHITECTURES on macOS - #943
Merged
kirithika7 merged 2 commits intoAug 12, 2026
Conversation
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.
Problem
Native (non-cross-compiled) macOS builds crash:
Root cause
Both the
ARMandARM64asm-compile branches insource/CMakeLists.txtunconditionally add-arch ${CMAKE_OSX_ARCHITECTURES}to the assembler args wheneverAPPLEis set, regardless of whetherCMAKE_OSX_ARCHITECTURESis actually populated.CMAKE_OSX_ARCHITECTURESis 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,-archends 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_ARM64in #877 (to support cross-compiling x86_64 → arm64), but neither the pre-existingARMbranch nor the newARM64branch 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.txtGuard both occurrences with
if(APPLE AND CMAKE_OSX_ARCHITECTURES)so-archis 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.ymlExplicitly set
-DCMAKE_OSX_ARCHITECTURES=arm64across all six macOScmakeinvocations (8bit, 10bit, 12bit, and the three multilib components)