Skip to content

Commit a47ebc7

Browse files
authored
Use minimal PAL and nano libraries in Cortex-M size tests (#24216)
### Summary The Cortex-M size tests should measure ExecuTorch's contribution to binary size. The POSIX platform layer and, for GNU, the full C/C++ libraries with exception support and demangling obscure that contribution. Select minimal PAL for both existing configurations and `nano.specs` for the GNU build to reduce this overhead and make the tests more sensitive to changes in ExecuTorch. Initialize C and C++ flags with `nano.specs` so it applies during compilation and linking while preserving the build script's existing flags. Set the runtime size limits to 34,000 bytes for GNU and 57,000 bytes for Zephyr. The GNU configuration uses nano's abort-on-allocation-failure behavior. ### Test plan Built both size targets on base `0549e1ee61` using Cortex-M55, C++17, Release with size optimization and logging disabled; GNU Arm 15.2.Rel1 and Zephyr SDK 1.0.1 (GCC 14.3.0). Stripped ELF file sizes in bytes: | Configuration | Binary | Before | After | Saved | |---|---|---:|---:|---:| | GNU bare-metal | `size_test` | 117,348 | 33,372 | 83,976 | | GNU bare-metal | `size_test_all_ops` | 1,245,820 | 1,156,180 | 89,640 | | Zephyr | `size_test` | 56,332 | 55,800 | 532 | | Zephyr | `size_test_all_ops` | 1,155,048 | 1,154,512 | 536 | All 263 C/C++ compile commands and both size-test compile/link commands select nano.specs while retaining the existing compiler flags. Both GNU binaries retain FileDataLoader and contain no exception-unwinder or demangler symbols. Workflow YAML parsing, shell syntax, and both size limits pass. Authored with AI assistance using Codex.
1 parent 62367c0 commit a47ebc7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎.github/workflows/pull.yml‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,12 @@ jobs:
729729
setup_script_args=""
730730
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
731731
toolchain_prefix=arm-none-eabi-
732-
threshold="118000" # GCC 15.2 baseline: 115868 bytes, 2026-05-13
732+
threshold="34000" # GCC 15.2, minimal PAL + nano baseline: 33372 bytes, 2026-10-27
733733
toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
734734
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
735735
setup_script_args="--target-toolchain zephyr"
736736
toolchain_prefix=arm-zephyr-eabi-
737-
threshold="136020" # 136 KiB
737+
threshold="57000" # Zephyr SDK 1.0.1, minimal PAL baseline: 55800 bytes, 2026-10-27
738738
toolchain_cmake=examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
739739
else
740740
echo "Unsupported OS selection: ${{ matrix.os }}"
@@ -752,11 +752,17 @@ jobs:
752752
# Setup cmake target to desired toolchain
753753
toolchain_cmake=$(realpath ${toolchain_cmake})
754754
755-
# Build and run size test
755+
# Measure the embedded runtime with minimal PAL.
756756
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
757-
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
757+
# Use nano libc and libstdc++ without exception support.
758+
bash test/build_size_test.sh \
759+
"-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake}" \
760+
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
761+
-DEXECUTORCH_PAL_DEFAULT=minimal \
762+
-DCMAKE_C_FLAGS_INIT=--specs=nano.specs \
763+
-DCMAKE_CXX_FLAGS_INIT=--specs=nano.specs
758764
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
759-
CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
765+
CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DEXECUTORCH_PAL_DEFAULT=minimal -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
760766
cmake --build cmake-out -j9 --target install --config Release
761767
CXXFLAGS=${cxx_flags} cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_SIZE_TEST_NO_OS_LINK=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
762768
cmake --build cmake-out/test -j9 --config Release

0 commit comments

Comments
 (0)