From a43bca0a8cca828d180b0e3e4f9de62ef998c0d3 Mon Sep 17 00:00:00 2001 From: Lars-Ove Karlsson Date: Tue, 25 Feb 2025 14:53:28 +0100 Subject: [PATCH] cmake: compiler: Added property flag for optimization fast CMSIS modules dsp and nn sets the optimization flag -Ofast for their libraries. I've now made a new compiler property optimization_fast to avoid using ifdefs in the cmsis CMakeLists.txt files. I've update GCC and arcmwdt (not sure if arcmwdt supports -Ofast) Signed-off-by: Lars-Ove Karlsson --- cmake/compiler/arcmwdt/compiler_flags.cmake | 3 ++- cmake/compiler/compiler_flags_template.cmake | 2 ++ cmake/compiler/gcc/compiler_flags.cmake | 1 + cmake/compiler/iar/compiler_flags.cmake | 2 ++ modules/cmsis-dsp/CMakeLists.txt | 4 +--- modules/cmsis-nn/CMakeLists.txt | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/compiler/arcmwdt/compiler_flags.cmake b/cmake/compiler/arcmwdt/compiler_flags.cmake index 52f82c4273b..2827c954e75 100644 --- a/cmake/compiler/arcmwdt/compiler_flags.cmake +++ b/cmake/compiler/arcmwdt/compiler_flags.cmake @@ -14,7 +14,8 @@ list(APPEND CXX_EXCLUDED_OPTIONS set_compiler_property(PROPERTY no_optimization -O0) set_compiler_property(PROPERTY optimization_debug -O0) set_compiler_property(PROPERTY optimization_speed -O2) -set_compiler_property(PROPERTY optimization_size -Os) +set_compiler_property(PROPERTY optimization_size -Os) +set_compiler_property(PROPERTY optimization_fast -O3) ####################################################### # This section covers flags related to warning levels # diff --git a/cmake/compiler/compiler_flags_template.cmake b/cmake/compiler/compiler_flags_template.cmake index c4fa86c124f..bd8733ce9d0 100644 --- a/cmake/compiler/compiler_flags_template.cmake +++ b/cmake/compiler/compiler_flags_template.cmake @@ -15,6 +15,8 @@ set_compiler_property(PROPERTY optimization_size) set_compiler_property(PROPERTY optimization_size_aggressive) +set_compiler_property(PROPERTY optimization_fast) + ####################################################### # This section covers flags related to warning levels # ####################################################### diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 438c216d87c..48afd244ac7 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -21,6 +21,7 @@ endif() set_compiler_property(PROPERTY optimization_speed -O2) set_compiler_property(PROPERTY optimization_size -Os) set_compiler_property(PROPERTY optimization_size_aggressive -Oz) +set_compiler_property(PROPERTY optimization_fast -Ofast) if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0") set_compiler_property(PROPERTY optimization_lto -flto=auto) diff --git a/cmake/compiler/iar/compiler_flags.cmake b/cmake/compiler/iar/compiler_flags.cmake index c72929fe027..ccbb6ceb82b 100644 --- a/cmake/compiler/iar/compiler_flags.cmake +++ b/cmake/compiler/iar/compiler_flags.cmake @@ -17,6 +17,8 @@ set_compiler_property(PROPERTY optimization_size -Ohz) set_compiler_property(PROPERTY optimization_size_aggressive -Ohz) +set_compiler_property(PROPERTY optimization_fast --no_size_constraints) + ####################################################### # This section covers flags related to warning levels # ####################################################### diff --git a/modules/cmsis-dsp/CMakeLists.txt b/modules/cmsis-dsp/CMakeLists.txt index e5ebbfcf172..2a0924cc25c 100644 --- a/modules/cmsis-dsp/CMakeLists.txt +++ b/modules/cmsis-dsp/CMakeLists.txt @@ -8,7 +8,7 @@ if(CONFIG_CMSIS_DSP) zephyr_library() - zephyr_library_compile_options(-Ofast) + zephyr_library_compile_options($) zephyr_include_directories( ${CMSIS_DSP_DIR}/Include @@ -47,8 +47,6 @@ if(CONFIG_CMSIS_DSP) endif() endif() - zephyr_library_compile_options(-Ofast) - zephyr_compile_definitions_ifndef(CONFIG_ARM __GNUC_PYTHON__) # BasicMathFunctions diff --git a/modules/cmsis-nn/CMakeLists.txt b/modules/cmsis-nn/CMakeLists.txt index 0fdf3db9675..7c05e8a585a 100644 --- a/modules/cmsis-nn/CMakeLists.txt +++ b/modules/cmsis-nn/CMakeLists.txt @@ -8,7 +8,7 @@ if(CONFIG_CMSIS_NN) zephyr_library() - zephyr_library_compile_options(-Ofast) + zephyr_library_compile_options($) zephyr_include_directories(${CMSIS_NN_DIR}/Include)