Don't let -Xarch_x86_64 break Apple builds that use -Werror - #134
Merged
Conversation
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.
Member
Author
Verified on real iOS CISince 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
Same runner image, same Xcode 26.4.1, same |
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.
What
Fixes
-Xarch_x86_64 -msse4.2breaking Apple builds that compile with-Werror.Why
#133 made the SSE minspec arch-aware, using
-Xarch_x86_64for universal builds so the flag only reaches the x86_64 slice. That is correct whenCMAKE_OSX_ARCHITECTURESdescribes 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_ARCHITECTURESis only an upper bound. An iOS build configured through leetal/ios-cmake'sOS64COMBINEDreportsarm64;x86_64(x86_64 being the simulator slice), yet theiphoneosbuild compiles arm64 only. clang then sees an-Xarch_x86_64that applies to nothing: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.2with no-Xarch_and so cannot hit this.