From ad0d2e0278211fe4056687c1119ae972f6193131 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 27 May 2014 16:13:02 -0700 Subject: [PATCH] libpayload: 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 '-g -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 V=1 GDB_DEBUG=1 and observed the modified compiler invocation line in the log. Change-Id: I4a902ad25157fa7f93614917f440e56145405a1d Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/201783 Reviewed-by: David Hendricks Reviewed-by: Trevor Bourget --- payloads/libpayload/Makefile.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc index 45376d29e5..47f90deba3 100644 --- a/payloads/libpayload/Makefile.inc +++ b/payloads/libpayload/Makefile.inc @@ -53,12 +53,18 @@ subdirs-$(CONFIG_LP_CBFS) += libcbfs subdirs-$(CONFIG_LP_LZMA) += liblzma INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) -CFLAGS = $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc -ggdb3 +CFLAGS = $(EXTRA_CFLAGS) $(INCLUDES) -pipe -nostdinc -ggdb3 CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs CFLAGS += -Wstrict-aliasing -Wshadow -Werror +ifneq ($(GDB_DEBUG),) +CFLAGS += -O0 -g +else +CFLAGS += -Os +endif + $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER) cmp $@ $< 2>/dev/null || cp $< $@