build: Added CONFIG_NO_OPTIMIZATIONS

Added a new config option which lowers the compiler
optimizations to -O0 independently of other flags.

CONFIG_COVERAGE uses it now instead of having its own
choice in CMakeLists.txt

Fixes #5720

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2018-01-22 15:35:54 +01:00 committed by Anas Nashif
parent 3ed51aca39
commit f60527a138
3 changed files with 16 additions and 5 deletions

View file

@ -74,7 +74,8 @@ endif()
# We need to set an optimization level.
# Default to -Os
# unless CONFIG_DEBUG is set, then it is -Og
# unless CONFIG_NO_OPTIMIZATIONS is set, then it is -O0
# or unless CONFIG_DEBUG is set, then it is -Og
#
# also, some toolchain's break with -Os, and some toolchain's break
# with -Og so allow them to override what flag to use
@ -83,11 +84,11 @@ endif()
# come after these options and override them
set_ifndef(OPTIMIZE_FOR_SIZE_FLAG "-Os")
set_ifndef(OPTIMIZE_FOR_DEBUG_FLAG "-Og")
set_ifndef(OPTIMIZE_FOR_COVERAGE_FLAG "-O0")
if(CONFIG_DEBUG)
set_ifndef(OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG "-O0")
if(CONFIG_NO_OPTIMIZATIONS)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG})
elseif(CONFIG_DEBUG)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_DEBUG_FLAG})
elseif(CONFIG_COVERAGE)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_COVERAGE_FLAG})
else()
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SIZE_FLAG}) # Default
endif()

View file

@ -136,6 +136,15 @@ config NATIVE_APPLICATION
Build as a native application that can run on the host and using
resources and libraries provided by the host.
config NO_OPTIMIZATIONS
bool "Lower compiler optimziations to -O0"
default n
help
When selected, compiler optimizations will be set to -O0 independently of
other options.
Note that this flag shall only control the compiler optimization level, and
that no extra debug code shall be conditionally compiled based on it.
config COMPILER_OPT
string
prompt "Custom compiler options"

View file

@ -27,6 +27,7 @@ config TEST_EXTRA_STACKSIZE
config COVERAGE
bool "Create coverage data"
depends on NATIVE_APPLICATION
select NO_OPTIMIZATIONS
default n
help
This option will build your application with the -coverage option