diff options
authorEric Blake <>2011-12-02 11:56:58 -0700
committerEric Blake <>2011-12-02 13:00:57 -0700
commit75da3200876a8b92ab78b15d3772809fef794faf (patch)
parentapparmor: allow tunnelled migrations. (diff)
build: fix build at -O2 on rawhide
I had previously tested commit 059d746 with -O intentionally omitted from my CFLAGS; but that means that I missed out on this warning from gcc 4.6.2 when optimizations are enabled: util/buf.c: In function 'virBufferGetIndent': util/buf.c:86:1: error: function might be candidate for attribute 'pure' [-Werror=suggest-attribute=pure] While it is probably a good idea to add the attributes and silence this warning, it's also invasive; 'make -k' found more than 75 such complaints. And it doesn't help that gcc 4.6.2 is still buggy (coreutils reported a case where gcc 4.6.2 incorrectly suggested marking a function pure that incremented a global variable; fixed in gcc 4.7). So the best fix for now is to disable the warning. It also doesn't help that I stumbled across another problem - gcc documents that -Wsuggest-attribute=pure only warns if you use -O, or if you use -fipa-pure-const. But in practice, when I omitted -O but added -fipa-pure-const, the warnings are fickle - I got warnings for simple compilation that disappeared when I also added -fPIC. And the way libtool compiles things is with -fPIC first, then without -fPIC but with errors sent to /dev/null - which meant that without disabling -Wsuggest-attribute=pure, I got a compile error with no message. :( See * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence -Wsuggest-attribute warnings for now.
1 files changed, 8 insertions, 0 deletions
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 213b3db70..a17e4b764 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -116,6 +116,14 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
+ # Need -fipa-pure-const in order to make -Wsuggest-attribute=pure
+ # fire even without -O.
+ gl_WARN_ADD([-fipa-pure-const])
+ # We should eventually enable this, but right now there are at
+ # least 75 functions triggering warnings.
+ gl_WARN_ADD([-Wno-suggest-attribute=pure])
+ gl_WARN_ADD([-Wno-suggest-attribute=const])
if test "$enable_compile_warnings" = "error"