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
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif()

option(OPTIMIZE_SIZE "Build executorch runtime optimizing for binary size" OFF)
if(OPTIMIZE_SIZE)
if(EXECUTORCH_OPTIMIZE_SIZE)
# -Os: Optimize for size.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
else()
Expand Down
2 changes: 1 addition & 1 deletion docs/source/using-executorch-building-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The release build offers optimizations intended to improve performance and reduc
To further optimize the release build for size, use both:
```bash
-DCMAKE_BUILD_TYPE=Release \
-DOPTIMIZE_SIZE=ON
-DEXECUTORCH_OPTIMIZE_SIZE=ON
```

See [CMakeLists.txt](https://github.com/pytorch/executorch/blob/main/CMakeLists.txt)
Expand Down
2 changes: 1 addition & 1 deletion test/build_optimized_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cmake_install_executorch_lib() {
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DOPTIMIZE_SIZE=ON \
-DEXECUTORCH_OPTIMIZE_SIZE=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
-Bcmake-out .
cmake --build cmake-out -j9 --target install --config MinSizeRel
Expand Down
2 changes: 1 addition & 1 deletion test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cmake_install_executorch_lib() {
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DOPTIMIZE_SIZE=ON \
-DEXECUTORCH_OPTIMIZE_SIZE=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
${EXTRA_BUILD_ARGS} \
-Bcmake-out .
Expand Down
5 changes: 5 additions & 0 deletions tools/cmake/preset/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ define_overridable_option(
"Build with ET_EVENT_TRACER_ENABLED"
BOOL OFF
)
define_overridable_option(
EXECUTORCH_OPTIMIZE_SIZE
"Build executorch runtime optimizing for binary size"
BOOL OFF
)

# MARK: - Validations
# At this point all the options should be configured with their final value.
Expand Down
Loading