From b43501451733193b265de30fd79a764363a2a473 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 12 Mar 2018 23:06:51 -0500 Subject: [PATCH] tools: detect appropriate debug optimization level When building debug use -Og as the optimization level if its available, otherwise retain the use of -O0. -Og has been added by GCC to enable all optimizations that to not affect debugging while retaining full debugability. Signed-off-by: Doug Goldstein Acked-by: Wei Liu --- tools/Rules.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/Rules.mk b/tools/Rules.mk index 296b722372..3848bcf1f7 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -164,8 +164,13 @@ LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libexten SHLIB_libxenvchan = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN) ifeq ($(debug),y) -# Disable optimizations -CFLAGS += -O0 -fno-omit-frame-pointer +CFLAGS += -fno-omit-frame-pointer +# Use optimizations compatible with debugging otherwise disable optimizations +ifneq ($(call cc-option,$(CC),-Og,n),n) +CFLAGS += -Og +else +CFLAGS += -O0 +endif # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=. PY_CFLAGS += $(PY_NOOPT_CFLAGS) else -- 2.30.2