Skip to content

Don't let -Xarch_x86_64 break Apple builds that use -Werror - #134

Merged
bkaradzic-microsoft merged 1 commit into
masterfrom
bk-fix-xarch-unused
Jul 27, 2026
Merged

Don't let -Xarch_x86_64 break Apple builds that use -Werror#134
bkaradzic-microsoft merged 1 commit into
masterfrom
bk-fix-xarch-unused

Conversation

@bkaradzic-microsoft

Copy link
Copy Markdown
Member

What

Fixes -Xarch_x86_64 -msse4.2 breaking Apple builds that compile with -Werror.

Why

#133 made the SSE minspec arch-aware, using -Xarch_x86_64 for universal builds so the flag only reaches the x86_64 slice. That is correct when CMAKE_OSX_ARCHITECTURES describes the slices that actually get compiled -- which holds for a macOS universal build, but not for Xcode in general.

Xcode picks slices per SDK at build time, so CMAKE_OSX_ARCHITECTURES is only an upper bound. An iOS build configured through leetal/ios-cmake's OS64COMBINED reports arm64;x86_64 (x86_64 being the simulator slice), yet the iphoneos build compiles arm64 only. clang then sees an -Xarch_x86_64 that applies to nothing:

clang: error: argument unused during compilation: '-Xarch_x86_64 -msse4.2'
       [-Werror,-Wunused-command-line-argument]

This reproduces in BabylonNative's iOS CI (BabylonJS/BabylonNative#1795), which builds with -Werror.

How

Pair the flag with -Wno-unused-command-line-argument, scoped to the universal-build branch only. Every x86_64 slice that is actually compiled still gets the SSE4.2 minspec; slices that aren't no longer fail the build. Single-slice builds are untouched -- they pass a plain -msse4.2 with no -Xarch_ and so cannot hit this.

CMAKE_OSX_ARCHITECTURES is only an upper bound on the slices Xcode actually
compiles: it picks slices per SDK at build time. An iOS build configured for
"arm64;x86_64" (leetal/ios-cmake's OS64COMBINED, where x86_64 is the simulator
slice) compiles only arm64 against the iphoneos SDK, so the -Xarch_x86_64
applies to nothing and clang reports it as an unused argument -- fatal for
projects building with -Werror.

Pair the flag with -Wno-unused-command-line-argument so the SSE minspec still
reaches every x86_64 slice that is built, without breaking the slices that
aren't.
@bkaradzic-microsoft

Copy link
Copy Markdown
Member Author

Verified on real iOS CI

Since bgfx.cmake has no CI of its own, I validated this against the build that actually reproduces the failure. I pointed a throwaway BabylonNative branch's bgfx.cmake GIT_TAG at d8e3ba1 (this PR's commit) and ran just the two iOS jobs that fail on BabylonJS/BabylonNative#1795:

Job Before (bgfx.cmake 7062f11) After (this PR, d8e3ba1)
iOS_Xcode26 / build ❌ exit 65 ✅ 4m4s
iOS_Installation / test-install ❌ exit 65 ✅ 3m14s

Same runner image, same Xcode 26.4.1, same PLATFORM=OS64COMBINED configure -- the only difference is this commit. The temporary branch has been deleted.

@bkaradzic-microsoft
bkaradzic-microsoft merged commit 6c55158 into master Jul 27, 2026
@bkaradzic-microsoft
bkaradzic-microsoft deleted the bk-fix-xarch-unused branch July 27, 2026 23:46
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.

1 participant