Bug 2071075 - Build the macOS onnxruntime toolchains on Linux workers. r=jcristau

The aarch64 task was already a cross build on the Intel b-osx-1015 workers, so neither build executes what it
compiles. build.py's --osx_arch only acts on a macOS host, so the Darwin cmake variables are passed directly,
the way build-llvm-common.sh does for compiler-rt, with linux64-clang-toolchain replacing the Mach-O
macosx64-clang and the mac cmake/ninja fetches. Deployment targets are set explicitly to Firefox's (10.15
x86_64, 11.0 arm64).

-fuse-ld=lld goes in the compile flags because cmake's try_compile checks, including the one behind
--enable_lto, don't inherit CMAKE_*_LINKER_FLAGS and would silently disable LTO. CMAKE_ASM_COMPILER_TARGET is
needed or the .S files are assembled for the host.

Differential Revision: https://phabricator.services.mozilla.com/D325157
This commit is contained in:
Ryan VanderMeulen
2026-09-11 15:34:21 +00:00
committed by rvandermeulen@mozilla.com
parent 0f715ac101
commit 1dfefda069
2 changed files with 35 additions and 14 deletions
+2 -10
View File
@@ -83,7 +83,6 @@ onnxruntime-i686-windows-msvc:
onnxruntime-x86_64-apple-darwin:
description: "ONNX Runtime (macOS x64)"
worker-type: b-osx-1015
treeherder:
symbol: TM(onnx)
run:
@@ -93,16 +92,12 @@ onnxruntime-x86_64-apple-darwin:
toolchain-artifact: public/build/onnxruntime-x86_64-apple-darwin.tar.zst
fetches:
toolchain:
- macosx64-clang-toolchain
- linux64-clang-toolchain
- macosx64-sdk-toolchain
fetch:
- macosx64-cmake
- macosx64-ninja
onnxruntime-aarch64-apple-darwin:
description: "ONNX Runtime (macOS aarch64)"
worker-type: b-osx-1015
treeherder:
symbol: TMA64(onnx)
run:
@@ -112,11 +107,8 @@ onnxruntime-aarch64-apple-darwin:
toolchain-artifact: public/build/onnxruntime-aarch64-apple-darwin.tar.zst
fetches:
toolchain:
- macosx64-clang-toolchain
- linux64-clang-toolchain
- macosx64-sdk-toolchain
fetch:
- macosx64-cmake
- macosx64-ninja
onnxruntime-arm-linux-androideabi:
+33 -4
View File
@@ -30,9 +30,38 @@ export CXX=clang++
# Extra setup per platform
case ${target_platform} in
Darwin)
# Use taskcluster clang instead of host compiler on OSX
case $target_arch in
arm64)
target_triple=aarch64-apple-darwin
macosx_deployment_target=11.0
;;
x86_64)
target_triple=x86_64-apple-darwin
macosx_deployment_target=10.15
;;
*)
echo "ERROR: unsupported Darwin architecture $target_arch" >&2
exit 1
;;
esac
osx_sysroot=`cd ${MOZ_FETCHES_DIR}/MacOSX*.sdk; pwd`
extra_args=(--cmake_extra_defines CMAKE_OSX_SYSROOT=${osx_sysroot} --osx_arch $target_arch)
# cmake probes the mac-only sw_vers; the version it sees doesn't matter.
mkdir -p "$PWD/fakebin"
printf '#!/bin/sh\necho 10.15\n' > "$PWD/fakebin/sw_vers"
chmod +x "$PWD/fakebin/sw_vers"
export PATH="$PATH:$PWD/fakebin"
extra_args=(--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_SYSTEM_PROCESSOR=$target_arch
CMAKE_OSX_ARCHITECTURES=$target_arch
CMAKE_OSX_SYSROOT=${osx_sysroot}
CMAKE_OSX_DEPLOYMENT_TARGET=$macosx_deployment_target
CMAKE_C_COMPILER_TARGET=$target_triple
CMAKE_CXX_COMPILER_TARGET=$target_triple
CMAKE_ASM_COMPILER_TARGET=$target_triple
CMAKE_AR=${MOZ_FETCHES_DIR}/clang/bin/llvm-ar
CMAKE_RANLIB=${MOZ_FETCHES_DIR}/clang/bin/llvm-ranlib)
TARGET_FLAGS="-fuse-ld=lld -Wno-unused-command-line-argument"
prefix=lib
extension=dylib
HARDENING_FLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong"
@@ -148,8 +177,8 @@ python3 tools/ci_build/build.py \
--cmake_extra_defines PYTHON_EXECUTABLE=$(which python3)\
--cmake_extra_defines ONNX_USE_LITE_PROTO=ON\
--disable_exceptions \
--cmake_extra_defines CMAKE_C_FLAGS_INIT="$HARDENING_FLAGS"\
--cmake_extra_defines CMAKE_CXX_FLAGS_INIT="$HARDENING_FLAGS $EXTRA_CXX_FLAGS"\
--cmake_extra_defines CMAKE_C_FLAGS_INIT="$HARDENING_FLAGS $TARGET_FLAGS"\
--cmake_extra_defines CMAKE_CXX_FLAGS_INIT="$HARDENING_FLAGS $TARGET_FLAGS $EXTRA_CXX_FLAGS"\
"${extra_args[@]}"
###