]> xenbits.xensource.com Git - libvirt.git/commit
build: fix build at -O2 on rawhide
authorEric Blake <eblake@redhat.com>
Fri, 2 Dec 2011 18:56:58 +0000 (11:56 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 2 Dec 2011 20:00:57 +0000 (13:00 -0700)
commit75da3200876a8b92ab78b15d3772809fef794faf
tree94edc9192f3013703711abde4218391e64de99f8
parent4cfdbfc46f0a7b777035a5b2af5ecbe7373a7e12
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 http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10197

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wsuggest-attribute warnings for now.
m4/virt-compile-warnings.m4