diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 4d19bd23527..b55bd92d6a2 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -17,6 +17,9 @@ on: - scripts/build_apple_llm_demo.sh - scripts/create_frameworks.sh - Package.swift + - CMakePresets.json + - third-party/CMakeLists.txt + - backends/mlx/** - .ci/scripts/test_ios_ci.sh - extension/apple/** - extension/benchmark/apple/** diff --git a/CMakePresets.json b/CMakePresets.json index fe74bc437b7..34a35123ef6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -64,7 +64,7 @@ "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake", "PLATFORM": "OS64", "DEPLOYMENT_TARGET": "17.0", - "CMAKE_OSX_DEPLOYMENT_TARGET": "12.0" + "CMAKE_OSX_DEPLOYMENT_TARGET": "15.0" }, "condition": { "lhs": "${hostSystemName}", @@ -82,7 +82,7 @@ "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake", "PLATFORM": "SIMULATORARM64", "DEPLOYMENT_TARGET": "17.0", - "CMAKE_OSX_DEPLOYMENT_TARGET": "12.0" + "CMAKE_OSX_DEPLOYMENT_TARGET": "15.0" }, "condition": { "lhs": "${hostSystemName}", diff --git a/backends/mlx/CMakeLists.txt b/backends/mlx/CMakeLists.txt index 32be05462e4..2a3d1546755 100644 --- a/backends/mlx/CMakeLists.txt +++ b/backends/mlx/CMakeLists.txt @@ -266,12 +266,11 @@ ExternalProject_Add( CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${_mlx_build_type}" -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} ${_mlx_cxx_flags_arg} - # The preset's DEPLOYMENT_TARGET carries the correct per-slice - # minimum (iOS 17, macOS 14); the ios.toolchain leaves - # CMAKE_OSX_DEPLOYMENT_TARGET at 12.0 on the iOS slices and only - # syncs it for MAC. The shader-flag patch reads - # CMAKE_OSX_DEPLOYMENT_TARGET, so feed the preset value in as that, - # or the iOS metallib is stamped -mios-version-min=12.0. + # Feed the preset's per-slice DEPLOYMENT_TARGET in as + # CMAKE_OSX_DEPLOYMENT_TARGET: the ios.toolchain does not reliably + # carry it to this sub-build, and the shader-flag patch reads + # CMAKE_OSX_DEPLOYMENT_TARGET to stamp the metallib's minimum OS + # version, so without this the iOS metallib gets the wrong floor. -DCMAKE_OSX_DEPLOYMENT_TARGET=${_mlx_osx_deployment_target} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DPLATFORM=${PLATFORM} diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index adcb541b3c3..9073d479ed9 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -46,6 +46,20 @@ else() set(_flatbuffers_ep_additional_args) endif() +# The flatc and flatcc host tools are built for the build machine. On a non-MAC +# Apple build the parent's CMAKE_OSX_DEPLOYMENT_TARGET is an iOS floor the host +# compiler rejects, so the host sub-builds get this macOS floor instead, to +# match the package's macOS minimum. _executorch_apple_cross is true only for a +# non-MAC Apple build, where the host tool must not take the app's SDK or floor. +set(_executorch_host_macos_floor 14.0) +set(_executorch_apple_cross + "$,$>>" +) +set(_executorch_host_osx_args + "$<${_executorch_apple_cross}:-DCMAKE_OSX_SYSROOT=>" + "-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$" +) + # Allow reusing a prebuilt host flatc instead of building it from source. This is # required when cross-compiling with the Ninja generator on Windows: the WIN32 # branch above only supports the Visual Studio generator (it passes the VS-only @@ -73,10 +87,9 @@ ExternalProject_Add( # Unset the toolchain to build for the host instead of the toolchain set for # the project. -DCMAKE_TOOLCHAIN_FILE= - # If building for iOS, "unset" these variables to rely on the host (macOS) - # defaults. - $<$,$>>:-DCMAKE_OSX_SYSROOT=> - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + # flatc runs on the build machine, so it must target the host, not the app's + # iOS platform. See _executorch_host_osx_args above. + ${_executorch_host_osx_args} BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} ${_flatbuffers_ep_additional_args} @@ -140,8 +153,7 @@ ExternalProject_Add( -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_TOOLCHAIN_FILE= - $<$,$>>:-DCMAKE_OSX_SYSROOT=> - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + ${_executorch_host_osx_args} ${_flatcc_extra_cmake_args} BUILD_BYPRODUCTS /bin/flatcc ${_executorch_external_project_additional_args}