From cb6ee577ff70d1665784482d803a6ae4d20d1c94 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Sun, 1 Jun 2025 15:33:12 +0200 Subject: [PATCH 1/2] Fix invalid target triple for MAC_UNIVERSAL builds 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 ``` --- ios.toolchain.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ios.toolchain.cmake b/ios.toolchain.cmake index 9046fd7..93cf56a 100644 --- a/ios.toolchain.cmake +++ b/ios.toolchain.cmake @@ -585,8 +585,9 @@ elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL") if(NOT ARCHS) set(ARCHS "x86_64;arm64") endif() - string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) + # For universal builds, don't set target triple - let CMake handle it + # string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + # set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_UNIVERSAL") set(SDK_NAME macosx) if(NOT ARCHS) From 8094de1147ff5f84e645c5b069224aaf1ef9193b Mon Sep 17 00:00:00 2001 From: Oliver Epper Date: Wed, 25 Jun 2025 16:31:01 +0200 Subject: [PATCH 2/2] Fix invalid target triple for MAC_CATALYST_UNIVERSAL builds --- ios.toolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios.toolchain.cmake b/ios.toolchain.cmake index 93cf56a..fa1df43 100644 --- a/ios.toolchain.cmake +++ b/ios.toolchain.cmake @@ -594,7 +594,7 @@ elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_UNIVERSAL") set(ARCHS "x86_64;arm64") endif() string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) + set(APPLE_TARGET_TRIPLE_INT apple-ios${DEPLOYMENT_TARGET}-macabi) else() message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") endif()