[Xen-devel] [PATCH] libxl/Makefile: Don't optimize debug builds; add macro debugging information
libxl debug builds are built with optimization level -O1, inherited from the CFLAGS definition in StdGNU.mk. Optimizations confuse the debugger, and the comment justifying -O1 in StdGNU.mk should not apply for a userspace library. Disable optimization by appending -O0 to CFLAGS, which overrides the -O1 flag specified earlier. Also specify -g3, to add macro debugging information which allows gdb to expand macro invocations. This is useful as libxl uses many non-trivial macros. Signed-off-by: Euan Harris euan.har...@citrix.com --- tools/libxl/Makefile |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index df08c8a..26d8679 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -15,6 +15,12 @@ CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \ -Wno-declaration-after-statement -Wformat-nonliteral CFLAGS += -I. -fPIC +ifeq ($(debug),y) +# Disable optimizations and debugging information for macros +CFLAGS += -O0 -g3 +endif + + ifeq ($(CONFIG_Linux),y) LIBUUID_LIBS += -luuid endif -- 1.7.1 ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH] libxl/Makefile: Don't optimize debug builds; add macro debugging information
On Mon, 2014-12-01 at 10:39 +, Euan Harris wrote: libxl debug builds are built with optimization level -O1, inherited from the CFLAGS definition in StdGNU.mk. Optimizations confuse the debugger, and the comment justifying -O1 in StdGNU.mk should not apply for a userspace library. Disable optimization by appending -O0 to CFLAGS, which overrides the -O1 flag specified earlier. I think if this argument applies (I see no reason to disagree) then it should apply to the whole of tools/* or at least to tools/lib* and not just to libxl. IOW this probably belongs at a higher level somewhere. Also specify -g3, to add macro debugging information which allows gdb to expand macro invocations. This is useful as libxl uses many non-trivial macros. Useful, I'd never heard of this. Do you know which version of gcc introduced it? (AKA do we need to make it part of configure.ac to check availability or not). Not sure if you were proposing this change for 4.5 or not. Signed-off-by: Euan Harris euan.har...@citrix.com --- tools/libxl/Makefile |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index df08c8a..26d8679 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -15,6 +15,12 @@ CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \ -Wno-declaration-after-statement -Wformat-nonliteral CFLAGS += -I. -fPIC +ifeq ($(debug),y) +# Disable optimizations and debugging information for macros +CFLAGS += -O0 -g3 +endif + + ifeq ($(CONFIG_Linux),y) LIBUUID_LIBS += -luuid endif ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH] libxl/Makefile: Don't optimize debug builds; add macro debugging information
On Mon, 2014-12-01 at 11:55 +, Euan Harris wrote: On Mon, Dec 01, 2014 at 11:43:13AM +, Ian Campbell wrote: On Mon, 2014-12-01 at 10:39 +, Euan Harris wrote: libxl debug builds are built with optimization level -O1, inherited from the CFLAGS definition in StdGNU.mk. Optimizations confuse the debugger, and the comment justifying -O1 in StdGNU.mk should not apply for a userspace library. Disable optimization by appending -O0 to CFLAGS, which overrides the -O1 flag specified earlier. I think if this argument applies (I see no reason to disagree) then it should apply to the whole of tools/* or at least to tools/lib* and not just to libxl. IOW this probably belongs at a higher level somewhere. Ok, I'll submit a new patch putting it in tools/Rules.mk Thanks. Also specify -g3, to add macro debugging information which allows gdb to expand macro invocations. This is useful as libxl uses many non-trivial macros. Useful, I'd never heard of this. Do you know which version of gcc introduced it? (AKA do we need to make it part of configure.ac to check availability or not). It's documented in GCC 2.95.3 [1], which is as far back as the online manuals go. [1] https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC9 OK, I'm pretty sure that's (way) before our cut-off. Thanks. Not sure if you were proposing this change for 4.5 or not. It would be nice to have, but I was assuming that 4.5 was more or less closed by now. Exceptions can be asked/argued for. I'd be a bit wary of something like this since the knock-on effects might be a bit subtle. Completely fine during a dev window though. Ian. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel