Skip to content
Merged
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
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,23 @@ endif()

add_subdirectory(third-party)

# Size-optimized builds disable exceptions, RTTI, and unwind tables.
# ExecuTorch's runtime uses Result<T>/Error instead of exceptions, so
# -fno-exceptions is safe. Suppressing .eh_frame via -fno-unwind-tables is safe
# because exceptions are disabled. Placed after add_subdirectory(third-party) to
# avoid leaking into third-party configure checks (e.g. gflags).
if(EXECUTORCH_OPTIMIZE_SIZE
AND NOT WIN32
AND NOT MSVC
)
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables -fno-unwind-tables"
)
Comment on lines +233 to +235
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

PR description says the change only adds -fno-asynchronous-unwind-tables/-fno-unwind-tables, but this hunk also adds -fno-exceptions and -fno-rtti to CMAKE_CXX_FLAGS_RELEASE. Please update the PR description (or drop the extra flags) so reviewers/users understand the full behavior change.

Copilot uses AI. Check for mistakes.
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} -fno-asynchronous-unwind-tables -fno-unwind-tables"
)
endif()

if(NOT DEFINED FXDIV_SOURCE_DIR)
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
${CMAKE_POSITION_INDEPENDENT_CODE}
Expand Down
Loading