From 2e49249a719f701b690246965ee88bc60690376e Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 19 Jun 2017 11:25:45 +1000 Subject: [PATCH] build system: Split setting of compiler optimisation level from assertions on/off --- Kconfig | 41 ++++++++++++++++++++++++++++------------- make/project.mk | 5 ++++- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Kconfig b/Kconfig index b1f5586dbc..bac2f8c638 100644 --- a/Kconfig +++ b/Kconfig @@ -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 diff --git a/make/project.mk b/make/project.mk index cdaba04742..a0779b464a 100644 --- a/make/project.mk +++ b/make/project.mk @@ -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