Skip to content

Conversation

BujSet
Copy link
Contributor

@BujSet BujSet commented Jun 24, 2025

Summary

This change adds a cmake preset for Arm Zephyr RTOS toolchain. This requires the toolchain cmake compilation target to be added to PATH (see #12077 for more details). This change includes update to CI flows, modifying the CI build_size_test to run the test using either arm bare metal or Zephyr toolchains. Additionally, the CI for building presets is updated to target the new cmake Zephyr preset.

Test plan

Tested with test/build_size_test.sh to determine the correct threshold for running the size test for the arm zephyr toolchain. When the CI runs the size test for the arm zephyr toolchain, the new cmake preset is used directly. The following commands are run by the CI, and can be manually invoked to confirm functionality:

CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0" cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
cmake --build cmake-out -j9 --target install --config Release
CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0"  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$(realpath examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake) -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
cmake --build cmake-out/test -j9 --config Release
arm-zephyr-eabi-strip cmake-out/test/size_test
ls -la cmake-out/test/size_test

Output should corroborate CI test threshold, reporting a resultant size_test binary size of ~125Kb (threshold set to 130KB toin CI test tolerate variability).

Copy link

pytorch-bot bot commented Jun 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/11923

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 Cancelled Job, 3 Unrelated Failures

As of commit f404ad8 with merge base de24e18 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 24, 2025
@BujSet BujSet self-assigned this Jun 24, 2025
@BujSet
Copy link
Contributor Author

BujSet commented Jun 24, 2025

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Jun 24, 2025
@BujSet BujSet added ciflow/trunk ciflow/binaries and removed release notes: none Do not include this in the release notes labels Jun 24, 2025
@BujSet BujSet force-pushed the arm_zephyr_cmake_preset branch 8 times, most recently from 5736206 to f14844f Compare June 25, 2025 23:57
@BujSet BujSet marked this pull request as ready for review June 25, 2025 23:58
@@ -0,0 +1,111 @@
#
Copy link
Contributor

Choose a reason for hiding this comment

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

examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake can we overload this file, and introduce perhaps PREFIX or TRIPLET i.e. arm-none-eabi- vs. arm-zephyr-eabi-?

See $ANDROID_NDK/build/cmake/android.toolchain.cmake as an example.

Copy link
Contributor Author

@BujSet BujSet Jun 27, 2025

Choose a reason for hiding this comment

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

Hm, I'm been trying to make changes to support this, but in doing so, the changes are becoming quite a bit more invasive. Every arm script (e.g. examples/arm/setup.sh, examples/arm/run.sh, backends/arm/scripts/build_executorch.sh ...) would need to take additional flags to use the arm-none-eabi-gcc.cmake but overloaded with a flag to specify that we shouldn't use the bare metal toolchain, but use the zephyr one instead. It is a bit of file duplication, but changes to the existing scripts are much more minimal if we retain arm-zephyr-eabi-gcc.cmake file separately. What do you think? I'm of the preference of keeping the arm-zephyr-eabi-gcc.cmake file for now, and maybe a later PR could consolidate the two?

@digantdesai digantdesai requested a review from zingo June 26, 2025 03:25
@digantdesai
Copy link
Contributor

@zingo - FYI

@zingo zingo added the module: arm Issues related to arm backend label Jun 26, 2025
@BujSet BujSet force-pushed the arm_zephyr_cmake_preset branch from 42b1860 to f404ad8 Compare July 2, 2025 22:40
@BujSet BujSet merged commit 5f70823 into pytorch:main Jul 3, 2025
299 of 308 checks passed
@BujSet BujSet deleted the arm_zephyr_cmake_preset branch July 3, 2025 14:00
Tanish2101 pushed a commit to Tanish2101/executorch that referenced this pull request Jul 9, 2025
### Summary
This change adds a cmake preset for Arm Zephyr RTOS toolchain. This
requires the toolchain cmake compilation target to be added to `PATH`
(see pytorch#12077 for more details). This change includes update to CI flows,
modifying the CI `build_size_test` to run the test using either arm bare
metal or Zephyr toolchains. Additionally, the CI for building presets is
updated to target the new cmake Zephyr preset.

### Test plan

Tested with `test/build_size_test.sh` to determine the correct threshold
for running the size test for the arm zephyr toolchain. When the CI runs
the size test for the arm zephyr toolchain, the new cmake preset is used
directly. The following commands are run by the CI, and can be manually
invoked to confirm functionality:

```
CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0" cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
cmake --build cmake-out -j9 --target install --config Release
CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0"  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$(realpath examples/zephyr/arm-x86-64-eabi-gcc.cmake) -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
cmake --build cmake-out/test -j9 --config Release
arm-zephyr-eabi-strip cmake-out/test/size_test
ls -la cmake-out/test/size_test
```

Output should corroborate CI test threshold, reporting a resultant
`size_test` binary size of ~125Kb (threshold set to 130KB toin CI test
tolerate variability).

---------

Co-authored-by: ZephyrUser <[email protected]>
Co-authored-by: Github Executorch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants