build system: Split setting of compiler optimisation level from assertions on/off

This commit is contained in:
Angus Gratton 2017-06-19 11:25:45 +10:00
parent 45c926f8f0
commit 2e49249a71
2 changed files with 32 additions and 14 deletions

41
Kconfig
View File

@ -23,26 +23,41 @@ endmenu
source "$COMPONENT_KCONFIGS_PROJBUILD"
choice OPTIMIZATION_LEVEL
prompt "Optimization level"
menu "Compiler options"
choice OPTIMIZATION_COMPILER
prompt "Optimization Level"
default OPTIMIZATION_LEVEL_DEBUG
help
This option sets optimization level.
- for "Release" setting, -Os flag is added to CFLAGS,
and -DNDEBUG flag is added to CPPFLAGS.
This option sets compiler optimization level (gcc -O argument).
- for "Release" setting, -Os flag is added to CFLAGS.
- for "Debug" setting, -Og flag is added to CFLAGS.
To override any of these settings, set CFLAGS and/or CPPFLAGS
in project makefile, before including $(IDF_PATH)/make/project.mk.
"Release" with -Os produces smaller & faster compiled code but it
may be harder to correlated code addresses to source files when debugging.
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
custom optimization levels may be unsupported.
config OPTIMIZATION_LEVEL_DEBUG
bool "Debug"
bool "Debug (-Og)"
config OPTIMIZATION_LEVEL_RELEASE
bool "Release"
bool "Release (-Os)"
endchoice
config OPTIMIZATION_ASSERTIONS
prompt "Enable assertions"
bool
default y
help
Enable assertions.
If disabled, -DNDEBUG is added to CFLAGS.
endmenu # Optimization level
menu "Component config"
source "$COMPONENT_KCONFIGS"
endmenu

View File

@ -235,11 +235,14 @@ COMMON_FLAGS = \
# Optimization flags are set based on menuconfig choice
ifneq ("$(CONFIG_OPTIMIZATION_LEVEL_RELEASE)","")
OPTIMIZATION_FLAGS = -Os
CPPFLAGS += -DNDEBUG
else
OPTIMIZATION_FLAGS = -Og
endif
ifeq ("$(CONFIG_OPTIMIZATION_ASSERTIONS)", "")
CPPFLAGS += -DNDEBUG
endif
# Enable generation of debugging symbols
# (we generate even in Release mode, as this has no impact on final binary size.)
DEBUG_FLAGS ?= -ggdb