Skip to content

Commit

Permalink
Add debug option to Kconfig to enable debugging
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nashif committed Feb 6, 2016
1 parent f1a3ba3 commit eb1fdf5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion scripts/Makefile.x86.preparch
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit eb1fdf5

Please sign in to comment.