Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't default to -fno-exceptions -fno-rtti #7746

Merged
merged 10 commits into from
Jan 28, 2025
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
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ if(EXECUTORCH_ENABLE_EVENT_TRACER)
endif()

# -ffunction-sections -fdata-sections: breaks function and data into sections so
# they can be properly gc'd. -s: strip symbol. -fno-exceptions -fno-rtti:
# disables exceptions and runtime type.
# they can be properly gc'd. -s: strip symbol.
set(CMAKE_CXX_FLAGS_RELEASE
"-ffunction-sections -fdata-sections -fno-exceptions -fno-rtti ${CMAKE_CXX_FLAGS_RELEASE}"
"-ffunction-sections -fdata-sections ${CMAKE_CXX_FLAGS_RELEASE}"
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
Expand Down
4 changes: 2 additions & 2 deletions backends/arm/scripts/build_quantized_ops_aot_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ echo "--------------------------------------------------------------------------

# Since we only want to build the quantized_aot lib in the specified folder,
# we want exactly the configuration set below and deleting the cache is OK.
rm -f cmake-out-aot-lib/CMakeCache.txt
rm -f cmake-out-aot-lib/CMakeCache.txt

cmake \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_BUILD_TYPE=${build_type} \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
Expand Down
6 changes: 3 additions & 3 deletions backends/cadence/build_cadence_fusionG3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ STEPWISE_BUILD=false

if $STEPWISE_BUILD; then
echo "Building ExecuTorch"
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
Expand All @@ -37,7 +37,7 @@ if $STEPWISE_BUILD; then
-Bcmake-out .

echo "Building any Cadence-specific binaries on top"
cmake -DBUCK2="$BUCK" \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
-DCMAKE_TOOLCHAIN_FILE=/home/zonglinpeng/ws/zonglinpeng/executorch/backends/cadence/cadence.cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -61,7 +61,7 @@ if $STEPWISE_BUILD; then
else
echo "Building Cadence toolchain with ExecuTorch packages"
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
cmake -DBUCK2="$BUCK" \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
-DHAVE_SYS_STAT_H=ON \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
Expand Down
6 changes: 3 additions & 3 deletions backends/cadence/build_cadence_hifi4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ STEPWISE_BUILD=false

if $STEPWISE_BUILD; then
echo "Building ExecuTorch"
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
Expand All @@ -36,7 +36,7 @@ if $STEPWISE_BUILD; then
-Bcmake-out .

echo "Building any Cadence-specific binaries on top"
cmake -DBUCK2="$BUCK" \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -60,7 +60,7 @@ if $STEPWISE_BUILD; then
else
echo "Building Cadence toolchain with ExecuTorch packages"
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
cmake -DBUCK2="$BUCK" \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
Expand Down
4 changes: 2 additions & 2 deletions backends/cadence/build_cadence_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ main() {
cd "${EXECUTORCH_ROOT}"

rm -rf cmake-out
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
Expand All @@ -33,7 +33,7 @@ main() {
local build_dir="cmake-out/${example_dir}"
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
rm -rf ${build_dir}
cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_CADENCE_CPU_RUNNER=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
Expand Down
8 changes: 2 additions & 6 deletions test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cmake_install_executorch_lib() {
echo "Installing libexecutorch.a"
clean_executorch_install_folders

retry cmake -DBUCK2="$BUCK2" \
CXXFLAGS="-fno-exceptions -fno-rtti" retry cmake -DBUCK2="$BUCK2" \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -27,7 +27,7 @@ cmake_install_executorch_lib() {
}

test_cmake_size_test() {
retry cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
CXXFLAGS="-fno-exceptions -fno-rtti" retry cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test

echo "Build size test"
cmake --build cmake-out/test -j9 --config Release
Expand All @@ -39,10 +39,6 @@ test_cmake_size_test() {
ls -al cmake-out/test/size_test_all_ops
}

if [[ -z $BUCK2 ]]; then
BUCK2=buck2
fi

if [[ -z $PYTHON_EXECUTABLE ]]; then
PYTHON_EXECUTABLE=python3
fi
Expand Down