Commit e8413d18 authored by Aurelien Jarno's avatar Aurelien Jarno Committed by Anas Nashif
Browse files

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: default avatarAurelien Jarno <aurelien@aurel32.net>
parent 92a6898b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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()
+6 −0
Original line number Diff line number Diff line
@@ -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