Add debug option to Kconfig to enable debugging
This only disables optimizations for now, we should be able to select more debug options from here. it changes KBUILD_CFLAGS from -Os to -O0. Change-Id: I84515356f8af006b724d706c0647a671db54a6b5 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
f1a3ba3931
commit
eb1fdf5741
3 changed files with 19 additions and 4 deletions
9
Makefile
9
Makefile
|
@ -364,10 +364,7 @@ ZEPHYRINCLUDE := \
|
|||
|
||||
KBUILD_CPPFLAGS := -DKERNEL
|
||||
|
||||
DEFAULTFLAGS ?= -Os
|
||||
|
||||
KBUILD_CFLAGS := -c -g -std=c99 \
|
||||
$(DEFAULTFLAGS) \
|
||||
$(CONFIG_COMPILER_OPT) \
|
||||
-fno-reorder-functions \
|
||||
-fno-asynchronous-unwind-tables \
|
||||
|
@ -634,6 +631,12 @@ endif
|
|||
endif
|
||||
KBUILD_CFLAGS += $(stackp-flag)
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
KBUILD_CFLAGS += -O0
|
||||
else
|
||||
KBUILD_CFLAGS += -Os
|
||||
endif
|
||||
|
||||
export x86_FLAGS arm_FLAGS arc_FLAGS LDFLAG_LINKERCMD OUTPUT_FORMAT OUTPUT_ARCH
|
||||
|
||||
ARCHFLAGS = $($(SRCARCH)_FLAGS)
|
||||
|
|
|
@ -58,6 +58,14 @@ config KERNEL_BIN_NAME
|
|||
default "microkernel" if MICROKERNEL
|
||||
default "nanokernel" if NANOKERNEL
|
||||
|
||||
config DEBUG
|
||||
bool "Build kernel with debugging"
|
||||
default n
|
||||
help
|
||||
Build a kernel suitable for debugging. Right now, this option
|
||||
only disables optimization, more debugging variants can be selected
|
||||
from here to allow more debugging.
|
||||
|
||||
config COMPILER_OPT
|
||||
string
|
||||
prompt "Custom compiler options"
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
|
||||
|
||||
PERF_OPT_FLAG-y = -DPERF_OPT
|
||||
ALIGN_STACK_FLAG- = -mpreferred-stack-boundary=2
|
||||
SECTION_GC_FLAG = $(call cc-option,-ffunction-sections,) $(call cc-option,-fdata-sections,)
|
||||
LTO_FLAG-y = $(call cc-option,-flto,)
|
||||
PERF_OPT=$(if $(filter -Os,$(DEFAULTFLAGS)),,y)
|
||||
|
||||
PERF_OPT=$(if $(filter -Os,$(KBUILD_CFLAGS)),,y)
|
||||
PERF_OPT_FLAG = $(PERF_OPT_FLAG-$(PERF_OPT))
|
||||
|
||||
ALIGN_STACK_FLAG = $(ALIGN_STACK_FLAG-$(PERF_OPT))
|
||||
LTO_FLAG = $(LTO_FLAG-$(CONFIG_LTO))
|
||||
ifneq ($(CONFIG_PLATFORM_QUARK),y)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue