From cccae4a4de4d5e130c1056d7801834329e52b9cc Mon Sep 17 00:00:00 2001 From: Aki <75532970+AkiSakurai@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:47:15 +0800 Subject: [PATCH 1/2] Add platform-specific configurations for iOS and macOS ARM64 to prevent AVX code compilation on x64 macOS - Updated `Utils.cmake` to set appropriate `target_platforms_arg` for iOS and macOS when building on ARM64. - Added execution platforms `ios-arm64` and `macos-arm64` in `shim/BUCK` for specifying CPU and OS configurations. - fix #6691 --- build/Utils.cmake | 13 +++++++++++++ shim/BUCK | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/build/Utils.cmake b/build/Utils.cmake index 246bd68c837..bdda2b220ce 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -196,6 +196,19 @@ function(extract_sources sources_file) message(FATAL_ERROR "Unsupported ANDROID_ABI setting ${ANDROID_ABI}. Please add it here!") endif() endif() + + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(target_platforms_arg "--target-platforms=shim//:ios-arm64") + endif() + endif() + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(target_platforms_arg "--target-platforms=shim//:macos-arm64") + endif() + endif() + execute_process( COMMAND ${PYTHON_EXECUTABLE} ${executorch_root}/build/extract_sources.py diff --git a/shim/BUCK b/shim/BUCK index b18ee71454e..c4b0c91a04d 100644 --- a/shim/BUCK +++ b/shim/BUCK @@ -74,3 +74,19 @@ execution_platform( use_windows_path_separators = host_info().os.is_windows, visibility = ["PUBLIC"], ) + +execution_platform( + name = "ios-arm64", + cpu_configuration = "prelude//cpu:arm64", + os_configuration = "prelude//os:ios", + use_windows_path_separators = False, + visibility = ["PUBLIC"], +) + +execution_platform( + name = "macos-arm64", + cpu_configuration = "prelude//cpu:arm64", + os_configuration = "prelude//os:macos", + use_windows_path_separators = False, + visibility = ["PUBLIC"], +) From 4c1d38fe33da7ed3122b6120fbe064073e2a97ce Mon Sep 17 00:00:00 2001 From: Aki <75532970+AkiSakurai@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:07:59 +0800 Subject: [PATCH 2/2] build: Add macOS x86_64 target support for ARM hosts --- build/Utils.cmake | 2 ++ shim/BUCK | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/build/Utils.cmake b/build/Utils.cmake index bdda2b220ce..d81a2c8efaf 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -206,6 +206,8 @@ function(extract_sources sources_file) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") set(target_platforms_arg "--target-platforms=shim//:macos-arm64") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(target_platforms_arg "--target-platforms=shim//:macos-x86_64") endif() endif() diff --git a/shim/BUCK b/shim/BUCK index c4b0c91a04d..fa0d8464b42 100644 --- a/shim/BUCK +++ b/shim/BUCK @@ -90,3 +90,11 @@ execution_platform( use_windows_path_separators = False, visibility = ["PUBLIC"], ) + +execution_platform( + name = "macos-x86_64", + cpu_configuration = "prelude//cpu:x86_64", + os_configuration = "prelude//os:macos", + use_windows_path_separators = False, + visibility = ["PUBLIC"], +)