]> xenbits.xensource.com Git - xen.git/commitdiff
tools: detect appropriate debug optimization level
authorDoug Goldstein <cardoe@cardoe.com>
Tue, 13 Mar 2018 04:06:51 +0000 (23:06 -0500)
committerWei Liu <wei.liu2@citrix.com>
Tue, 13 Mar 2018 15:53:35 +0000 (15:53 +0000)
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 <cardoe@cardoe.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/Rules.mk

index 296b722372f37ae7c00940ec244570f5f31fb83a..3848bcf1f7bf4840c1a5a898572c9c6e84ed9ec7 100644 (file)
@@ -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=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 else