Skip to content

Conversation

@BujSet
Copy link
Contributor

@BujSet BujSet commented Jun 27, 2025

Summary

Adds the command line option --target-toolchain to the examples/arm/setup.sh script so that Arm Zephyr toolchain for x86-64 Linux host systems can be used. Sourcing the generated setup_path.sh puts the selected toolchain on the PATH environment variable.

Test plan

Running:

./examples/arm/setup.sh --i-agree-to-the-contained-eula  --target-toolchain zephyr
source /home/zephyruser/executorch/examples/arm/ethos-u-scratch/setup_path.sh
arm-zephyr-eabi-gcc --version

Now produces the following output:

arm-zephyr-eabi-gcc (Zephyr SDK 0.17.2) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

While running:

./examples/arm/setup.sh --i-agree-to-the-contained-eula
source /home/zephyruser/executorch/examples/arm/ethos-u-scratch/setup_path.sh
arm-none-eabi-gcc --version

Still produces the following output:

arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@pytorch-bot
Copy link

pytorch-bot bot commented Jun 27, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 6eb6daa with merge base 1b42512 (image):
💚 Looks good so far! There are no failures yet. 💚

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 27, 2025
@BujSet BujSet added ciflow/trunk ciflow/binaries module: arm Issues related to arm backend labels Jun 27, 2025
@BujSet
Copy link
Contributor Author

BujSet commented Jun 27, 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 27, 2025
@BujSet BujSet self-assigned this Jun 27, 2025
@BujSet
Copy link
Contributor Author

BujSet commented Jun 27, 2025

@digantdesai @zingo @perheld The Arm Zephyr cmake Preset PR was getting too big and including features that weren't directly related to the goal of that PR. I'm splitting into other smaller, more modular PRs to make them easier to review and land. This one is exclusively adding the toolchain option to the setup.sh script.

cc @larryliu0820

@BujSet BujSet force-pushed the toolchain_select_arm_setup branch from f2d468c to 6eb6daa Compare June 30, 2025 14:16
@BujSet BujSet mentioned this pull request Jun 30, 2025
@BujSet BujSet changed the title Added Command Line Option to Choose Zephyr Toolchain over Arm Bare Metal When Possible Added Command Line Option to Select Arm Zephyr Toolchain Jun 30, 2025
@BujSet BujSet marked this pull request as ready for review June 30, 2025 18:28
@BujSet BujSet requested a review from digantdesai as a code owner June 30, 2025 18:28
Copy link
Contributor

@larryliu0820 larryliu0820 left a comment

Choose a reason for hiding this comment

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

LGTM

@BujSet BujSet merged commit adb5318 into pytorch:main Jun 30, 2025
287 of 288 checks passed
@BujSet BujSet deleted the toolchain_select_arm_setup branch June 30, 2025 19:50
BujSet added a commit that referenced this pull request Jul 3, 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/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]>
Tanish2101 pushed a commit to Tanish2101/executorch that referenced this pull request Jul 9, 2025
### Summary
Adds the command line option `--target-toolchain` to the
`examples/arm/setup.sh` script so that Arm Zephyr toolchain for x86-64
Linux host systems can be used. Sourcing the generated `setup_path.sh`
puts the selected toolchain on the `PATH` environment variable.

### Test plan

Running:
```
./examples/arm/setup.sh --i-agree-to-the-contained-eula  --target-toolchain zephyr
source /home/zephyruser/executorch/examples/arm/ethos-u-scratch/setup_path.sh
arm-zephyr-eabi-gcc --version
```

Now produces the following output:

```
arm-zephyr-eabi-gcc (Zephyr SDK 0.17.2) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

While running: 

```
./examples/arm/setup.sh --i-agree-to-the-contained-eula
source /home/zephyruser/executorch/examples/arm/ethos-u-scratch/setup_path.sh
arm-none-eabi-gcc --version
```

Still produces the following output:

```
arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
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: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants