kconfig: add a compiler speed optimization

Zephyr currently allows users to choose a compiler optimization
between -O0, -Og and -Os, the default being the latter as it offers a
good compromise between speed and flash usage. In cases the speed
matters and/or the flash usage doesn't, optimizing for speed with -O2
is another alternative. For example in case of a simple application
doing cryptographic signature validation with mbedtls, the flash size
increase by about 15% compared to -Os, while it provides a 15% speed
boost for a RSA signature and 30% speed boost for a ECC signature.

This patches therefore adds a new option CONFIG_SPEED_OPTIMIZATIONS
corresponding to the -O2 flag, but keep the default set to
CONFIG_SIZE_OPTIMIZATIONS.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Aurelien Jarno 2018-06-16 23:40:04 +02:00 committed by Anas Nashif
parent 92a6898bd2
commit e8413d18f5
2 changed files with 9 additions and 0 deletions

View file

@ -91,11 +91,14 @@ endif()
set_ifndef(OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG "-O0")
set_ifndef(OPTIMIZE_FOR_DEBUG_FLAG "-Og")
set_ifndef(OPTIMIZE_FOR_SIZE_FLAG "-Os")
set_ifndef(OPTIMIZE_FOR_SPEED_FLAG "-O2")
if(CONFIG_NO_OPTIMIZATIONS)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG})
elseif(CONFIG_DEBUG_OPTIMIZATIONS)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_DEBUG_FLAG})
elseif(CONFIG_SPEED_OPTIMIZATIONS)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SPEED_FLAG})
elseif(CONFIG_SIZE_OPTIMIZATIONS)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SIZE_FLAG}) # Default
else()

View file

@ -152,6 +152,12 @@ config SIZE_OPTIMIZATIONS
Compiler optimizations will be set to -Os independently of other
options.
config SPEED_OPTIMIZATIONS
bool "Optimize for speed"
help
Compiler optimizations will be set to -O2 independently of other
options.
config DEBUG_OPTIMIZATIONS
bool "Optimize debugging experience"
help