Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/zephyr.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake"
}
},
{
"name": "arm-baremetal",
"displayName": "Build ExecuTorch for Arm baremetal",
"inherits": ["common"],
"cacheVariables": {
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/arm_baremetal.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake"
}
}
]
}
48 changes: 10 additions & 38 deletions backends/arm/scripts/build_executorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ _setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly ins

et_build_root="${et_root_dir}/arm_test"
build_type="Release"
build_devtools=false
build_with_etdump=false
build_devtools=OFF
build_with_etdump=OFF

help() {
echo "Usage: $(basename $0) [options]"
Expand All @@ -38,8 +38,8 @@ for arg in "$@"; do
-h|--help) help ;;
--et_build_root=*) et_build_root="${arg#*=}";;
--build_type=*) build_type="${arg#*=}";;
--devtools) build_devtools=true ;;
--etdump) build_with_etdump=true ;;
--devtools) build_devtools=ON ;;
--etdump) build_with_etdump=ON ;;
--toolchain=*) toolchain="${arg#*=}";;
*)
;;
Expand All @@ -48,7 +48,7 @@ done

if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
else
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
Expand All @@ -74,40 +74,12 @@ cd "${et_root_dir}"
echo "Build ExecuTorch target libs ${build_type} into '${et_build_dir}'" ;
echo "--------------------------------------------------------------------------------" )

build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=OFF "
if [ "$build_devtools" = true ] ; then
build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=ON "
fi

build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
if [ "$build_with_etdump" = true ] ; then
# Add DevTools flags use in the Target build below
build_with_etdump_flags="-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=OFF \
-DFLATCC_ALLOW_WERROR=OFF "
fi

echo "Building with Devtools: ${build_devtools_flags} ${build_with_etdump_flags}"


# Build
cmake \
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_CORTEX_M=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
${build_devtools_flags} \
${build_with_etdump_flags} \
-B"${et_build_dir}" \
"${et_root_dir}"

echo "[$(basename $0)] Configured CMAKE"
cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_DEVTOOLS=$build_devtools \
-DEXECUTORCH_BUILD_ARM_ETDUMP=$build_with_etdump \
--preset arm-baremetal -B${et_build_dir}

cmake --build ${et_build_dir} -j$(nproc) --target install --config ${build_type} --

Expand Down
25 changes: 25 additions & 0 deletions tools/cmake/preset/arm_baremetal.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 Arm Limited and/or its affiliates.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this PR is OK, I want to brainstorm here a bit more.

There are two, I think, orthogonal things we are mixing here, (1) Arm-ness, (2) Baremetal-ness. Can we split? For the preset its OK, I am talking about things like EXECUTORCH_BUILD_ARM_BAREMETAL the things it guards are not strictly related to Arm.

This will come up when we try to do Arm Cortex-m + Ethos on Zephyr. Passing ARM_BAREMETAL would be confusing at best.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changing it to something like EXECUTORCH_BUILD_ARM_ETHOSU seems reasonable to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess depends on the things we want to guard with this build flavor. We need to split this EXEUCTORCH_BUILD_ARM_BAREMETAL into EXECUTORCH_BUILD_ARM_ETHOSU and EXECUTORCH_BUILD_BAREMETAL. I can also see Cortex-M (no NPU) builds and not sure if the ETHOSU is the right suffix either.

#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER OFF)
set_overridable_option(EXECUTORCH_BUILD_ARM_BAREMETAL ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
set_overridable_option(EXECUTORCH_BUILD_CORTEX_M ON)
set_overridable_option(EXECUTORCH_ENABLE_LOGGING ON)

define_overridable_option(
EXECUTORCH_BUILD_ARM_ETDUMP "Build etdump support for Arm" BOOL OFF
)

if("${EXECUTORCH_BUILD_ARM_ETDUMP}")
set(EXECUTORCH_BUILD_DEVTOOLS ON)
set(EXECUTORCH_ENABLE_EVENT_TRACER ON)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF)
set(FLATCC_ALLOW_WERROR OFF)
else()
set(EXECUTORCH_ENABLE_EVENT_TRACER OFF)
endif()
Loading