mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-15 20:55:59 +00:00
Introduce toolchain_cc_optimize_for_* family of macros. Each macro represents a general optimization class. Each macro is then responsible for setting an output variable to that class-of-optimization's flag. The names of these output variables are decided from the root CMakeLists.txt. No functional change expected. Clang's optimization flags are compatible with gcc, and are thus inherited. This is motivated by the wish to abstract Zephyr's usage of toolchains, permitting easier porting to other (commercial) toolchains. Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
26 lines
909 B
CMake
26 lines
909 B
CMake
# See root CMakeLists.txt for description and expectations of this macro
|
|
#
|
|
# NOTE: Some GNU toolchains break with plain '-Os' or '-Og', but is fixable
|
|
# with tweaks. So allow user to override, via ifndef, the compile flags that
|
|
# CONFIG_{NO,DEBUG,SPEED,SIZE}_OPTIMIZATIONS will cause, yet still leaving the
|
|
# selection logic in kconfig.
|
|
#
|
|
# These macros leaves it up to the root CMakeLists.txt to choose the CMake
|
|
# variable names to store the optimization flags in.
|
|
|
|
macro(toolchain_cc_optimize_for_no_optimizations_flag dest_var_name)
|
|
set_ifndef(${dest_var_name} "-O0")
|
|
endmacro()
|
|
|
|
macro(toolchain_cc_optimize_for_debug_flag dest_var_name)
|
|
set_ifndef(${dest_var_name} "-Og")
|
|
endmacro()
|
|
|
|
macro(toolchain_cc_optimize_for_speed_flag dest_var_name)
|
|
set_ifndef(${dest_var_name} "-O2")
|
|
endmacro()
|
|
|
|
macro(toolchain_cc_optimize_for_size_flag dest_var_name)
|
|
set_ifndef(${dest_var_name} "-Os")
|
|
endmacro()
|