From dde4928c045d12e502cb109015a710cd9fdf2a04 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 22 Apr 2014 17:06:43 -0700 Subject: [PATCH] Provide a way to compile some files with -O0 option When preparing an image for source level debugging, it is convenient to be able to compile some modules with -O0, which makes it much easier to follow the execution flow. This patch allows to do it by defining GDB_DEBUG=1 in the environment before invoking make. Adding this feature as a common config flag is problematic, because we don't want to compile the entire image with -O0. BUG=none TEST=manual . ran make with GDB_DEBUG=1 and observed the modified compiler invocation line in the log. Change-Id: Ie0be653509509eeb64ea3a7229f54c0c812840a9 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/196359 --- Makefile.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index a37456d778..4d46ebb61e 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -208,7 +208,7 @@ INCLUDES += -Isrc/device/oprom/include # abspath is a workaround for romcc INCLUDES += -include $(src)/include/kconfig.h -CFLAGS = $(INCLUDES) -Os -pipe -g -nostdinc +CFLAGS = $(INCLUDES) -pipe -g -nostdinc CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs CFLAGS += -Wstrict-aliasing -Wshadow @@ -216,6 +216,11 @@ ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) CFLAGS += -Werror endif CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer +ifneq ($(GDB_DEBUG),) +CFLAGS += -O0 +else +CFLAGS += -Os +endif additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool $(objutil)/options