tools: detect appropriate debug optimization level
PATCH v2 1/1 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.
--- tools/Rules.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
@@ -137,7 +137,8 @@ SHLIB_libxenvchan = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN) ifeq ($(debug),y) # Disable optimizations and enable debugging information for macros -CFLAGS += -O0 -g3 +CFLAGS += $(call cc-option,$(CC),-Og,-O0) +CFLAGS += -g3 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>. PY_CFLAGS += $(PY_NOOPT_CFLAGS) endif
Signature · 7 lines
2.7.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Doug Goldstein writes ("[PATCH v2] tools: detect appropriate debug optimization level"):
Quoted 4 lines
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.
...
tools/Rules.mk SHLIB_libxenvchan = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN) · line 141
Quoted 3 lines
tools/Rules.mk +2
-1-CFLAGS += -O0 -g3 +CFLAGS += $(call cc-option,$(CC),-Og,-O0) +CFLAGS += -g3
I think CFLAGS is a variable which is expanded late, at each reference site - a `recursively expanded' variable.
The result is that the call to the compiler to test the -Og flag (implied by cc-option) will be executed potentially for every C source code file!
I think you need to use cc-option-add.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel