tools: detect appropriate debug optimization level
PATCH v4 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/Rules.mk +7 -2
@@ -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
Signature · 7 lines
2.16.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Doug Goldstein
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 <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines · Doug Goldstein
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 <[email protected]>--- tools/Rules.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tools/Rules.mk +0
-0@@ -164,8 +164,13 @@ LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libexten SHLIB_libxenvchan = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
tools/Rules.mk LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libexten · line 173
Quoted 10 lines
tools/Rules.mk +7
-2ifeq ($(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
Sadly the way cc-option is written made the support check always return true. cc-option would grep for -Og in the (error) to tell if it is supported or not, but the error message for -Og doesn't contain "-Og". It is like
cc1: error: argument to '-O' should be a non-negative integer
We need to think of another way to test it, or we just have to live with V1.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 34 lines · Wei Liu
Quoted 17 lines · Doug Goldstein
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 <[email protected]>--- tools/Rules.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tools/Rules.mk +0
-0@@ -164,8 +164,13 @@ LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libexten SHLIB_libxenvchan = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)tools/Rules.mk LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libexten · line 173
Quoted 10 lines
tools/Rules.mk +7
-2ifeq ($(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 +endifSadly the way cc-option is written made the support check always return true. cc-option would grep for -Og in the (error) to tell if it is supported or not, but the error message for -Og doesn't contain "-Og". It is like
Quoted 4 lines
cc1: error: argument to '-O' should be a non-negative integer
We need to think of another way to test it, or we just have to live with V1.
Wait, but even v1 is bogus because cc-option-add uses cc-option.
I'm afraid we will need to figure out a new way to detect if the option is supported.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel