Skip to content

Fix invalid target triple for MAC_UNIVERSAL builds #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wcandillon
Copy link

My apologies for this AI-generated PR. I am the maintainer of https://github.com/wcandillon/react-native-webgpu and we've always relied on ios-cmake for our CMake builds. It has been tremendously helpful. This AI-generated change helped us fix our macOS build. Below is the AI-generated description of the change:

  ## Problem
  When building for `MAC_UNIVERSAL` platform, CMake fails with the error:
  clang: error: version 'arm64' in target triple 'arm64-apple-macosx11.0-arm64' is invalid

  This occurs because the toolchain generates an invalid target triple `x86_64-arm64-apple-macosx11.0` by combining multiple architectures with dashes, which clang cannot parse.

  ## Root Cause
  The `MAC_UNIVERSAL` configuration was setting `APPLE_TARGET_TRIPLE_INT` to `${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}` where `ARCHS_SPLIT` becomes `x86_64-arm64`. This creates an invalid target triple format that clang rejects.

  ## Solution
  Remove the target triple setting for `MAC_UNIVERSAL` builds and let CMake handle the universal build using the standard `-arch x86_64 -arch arm64` approach. This follows the same pattern used by other COMBINED builds in the toolchain.

  Universal builds should rely on the `-arch` flags rather than target triples, as:
  - Target triples are meant for single architectures
  - Universal builds are handled at the linker level by combining object files from different architectures
  - CMake's built-in universal build support works correctly without explicit target triples

My apologies for this AI-generated PR. I am the maintainer of https://github.com/wcandillon/react-native-webgpu and we've always relied on ios-cmake for our CMake builds. It has been tremendously helpful. This AI-generated change helped us fix our macOS build.
Below is the AI-generated description of the change:
```
  ## Problem
  When building for `MAC_UNIVERSAL` platform, CMake fails with the error:
  clang: error: version 'arm64' in target triple 'arm64-apple-macosx11.0-arm64' is invalid

  This occurs because the toolchain generates an invalid target triple `x86_64-arm64-apple-macosx11.0` by combining multiple architectures with dashes, which clang cannot parse.

  ## Root Cause
  The `MAC_UNIVERSAL` configuration was setting `APPLE_TARGET_TRIPLE_INT` to `${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}` where `ARCHS_SPLIT` becomes `x86_64-arm64`. This creates an invalid target triple format that clang rejects.

  ## Solution
  Remove the target triple setting for `MAC_UNIVERSAL` builds and let CMake handle the universal build using the standard `-arch x86_64 -arch arm64` approach. This follows the same pattern used by other COMBINED builds in the toolchain.

  Universal builds should rely on the `-arch` flags rather than target triples, as:
  - Target triples are meant for single architectures
  - Universal builds are handled at the linker level by combining object files from different architectures
  - CMake's built-in universal build support works correctly without explicit target triples
```
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