|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# This source code is licensed under the BSD-style license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | + |
| 8 | +# Unlike build_size_test.sh, this script: |
| 9 | +# - does not attempt to disable exceptions and RTTI |
| 10 | +# - as a consequence, is able to build optimized kernels |
| 11 | +# - uses MinSizeRel builds |
| 12 | +# - is not currently intended to run in CI |
| 13 | +# - sets -g to make it easier to use tools like bloaty to investigate size |
| 14 | + |
| 15 | +set -e |
| 16 | + |
| 17 | +# shellcheck source=/dev/null |
| 18 | +source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh" |
| 19 | + |
| 20 | +cmake_install_executorch_lib() { |
| 21 | + echo "Installing libexecutorch.a" |
| 22 | + clean_executorch_install_folders |
| 23 | + update_tokenizers_git_submodule |
| 24 | + CXXFLAGS="-g" retry cmake -DBUCK2="$BUCK2" \ |
| 25 | + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ |
| 26 | + -DCMAKE_INSTALL_PREFIX=cmake-out \ |
| 27 | + -DCMAKE_BUILD_TYPE=MinSizeRel \ |
| 28 | + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ |
| 29 | + -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \ |
| 30 | + -DOPTIMIZE_SIZE=ON \ |
| 31 | + -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ |
| 32 | + -Bcmake-out . |
| 33 | + cmake --build cmake-out -j9 --target install --config MinSizeRel |
| 34 | +} |
| 35 | + |
| 36 | +test_cmake_size_test() { |
| 37 | + CXXFLAGS="-g" retry cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test |
| 38 | + |
| 39 | + echo "Build size test" |
| 40 | + cmake --build cmake-out/test -j9 --config MinSizeRel |
| 41 | + |
| 42 | + echo 'ExecuTorch with no ops binary size, unstripped:' |
| 43 | + ls -al cmake-out/test/size_test |
| 44 | + |
| 45 | + echo 'ExecuTorch with portable ops binary size, unstripped:' |
| 46 | + ls -al cmake-out/test/size_test_all_ops |
| 47 | + |
| 48 | + echo 'ExecuTorch with optimized ops binary size, unstripped:' |
| 49 | + ls -al cmake-out/test/size_test_all_optimized_ops |
| 50 | +} |
| 51 | + |
| 52 | +if [[ -z $PYTHON_EXECUTABLE ]]; then |
| 53 | + PYTHON_EXECUTABLE=python3 |
| 54 | +fi |
| 55 | + |
| 56 | +cmake_install_executorch_lib |
| 57 | +test_cmake_size_test |
0 commit comments