Commit Graph

12 Commits

Author SHA1 Message Date
Eric Blake
d940e3bdb9 build: silence some compiler warnings from gnulib
Gnulib claims that there are some classes of warnings that are
worth enabling during development, but where silencing those
warnings causes code bloat that is not necessary in an optimized
build.  The code bloat to silence the warnings is only enabled
by -Dlint.  Follow the lead of coreutils in setting up -Dlint
whenever full warnings are requested.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-Dlint, and move _FORTIFY_SOURCE to config.h instead of CFLAGS.
2012-01-19 13:14:10 -07:00
Eric Blake
f17e0e2182 build: reduce warnings from older gcc
Older gcc warns (on every file!) that -Wabi and -Wdeprecated only
make sense on C++ projects.  Newer gcc accepts these warnings for
C, but it is not clear that they can do anything useful, so it
is easier to just drop the warnings altogether.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wabi and -Wdeprecated on older gcc.
Reported by Peter Krempa.
2011-12-05 10:14:55 -07:00
Eric Blake
75da320087 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.
2011-12-02 13:00:57 -07:00
Eric Blake
059d746ddb build: update to latest gnulib
* .gnulib: Update to latest, for improved 'make syntax-check' and
compiler warnings.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS):
Re-silence -Wformat-nonliteral.
* cfg.mk (_test_script_regex): Recognize our test scripts.
* gnulib/local/lib/*.diff: Drop, now that gnulib has this.
* tests/virsh-optparse: Fix use of compare.
* tests/virsh-schedinfo: Likewise.
2011-12-01 14:12:59 -07:00
Matthias Bolte
9ba4eb3c08 tests: Lower stack usage below 4096 bytes
Make virtTestLoadFile allocate the buffer to read the file into.

Fix logic error in virtTestLoadFile, stop reading on the first empty line.

Use virFileReadLimFD in virtTestCaptureProgramOutput to avoid manual
buffer handling.
2011-04-30 19:59:52 +02:00
Eric Blake
02c39a2f6d build: fix gitignore sorting
Make it so we don't have to 'git add -f' particular files like
po/POTFILES.in all the time (tested by fixing one of our
special-case files as part of the patch).

* .gnulib: Update to latest.
* bootstrap: Resync from coreutils.
* .gitignore: Sort whitelist entries correctly, including ignoring
files rather than directories.
* m4/virt-compile-warnings.m4: Convert tabs to space.
2011-04-07 15:03:53 -06:00
Jim Fehlig
3df6fd706c Fix build for older gcc
With gcc 4.3.4 I'm seeing the following warning failure

cc1: warnings being treated as errors
cc1: error: -funit-at-a-time is required for inlining of functions
that are only called once [-Wdisabled-optimization]

Add -funit-at-a-time to WARN_CFLAGS.
2011-04-06 15:05:45 -06:00
Daniel P. Berrange
dba5ba62bb Don't try to enable stack protector on Win32
The GCC Win32 compiler will claim to support -fstack-protector,
but if it actually gets triggered by a suitable code pattern,
linking will fail. Other non-Linux OS likely suffer the same
way with gcc.

* m4/virt-compile-warnings.m4: Only use stack protector when
  the build target is Linux.
2011-04-05 17:43:40 +01:00
Daniel P. Berrange
a4e37ff1a3 Enable use of -Wold-style-definition compiler flag
A couple of functions were declared using the old style foo()
for no-parameters, instead of foo(void)

* src/xen/xen_hypervisor.c, tests/testutils.c: Replace () with (void)
  in some function declarations
* m4/virt-compile-warnings.m4: Enable -Wold-style-definition
2011-04-05 11:40:04 +01:00
Daniel P. Berrange
329e9dc629 Enable use of -Wmissing-noreturn
* src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
* src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
  with ATTRIBUTE_NO_RETURN
* tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
* m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
2011-04-05 11:39:58 +01:00
Daniel P. Berrange
7d76d5d506 Enable -Wmissing-format-attribute warning
Add a couple of missing ATTRIBUTE_FMT_PRINTF annotations

* tools/virsh.c, tests/testutils.c: Add printf format attribute
* m4/virt-compile-warnings.m4: Enable -Wmissing-format-attribute
2011-04-05 11:39:52 +01:00
Daniel P. Berrange
4825b521e2 Remove acinclude.m4 file
Split the bit acinclude.m4 file into smaller pieces named
as m4/virt-XXXXX.m4

* .gitignore: Ignore gettext related files
* acinclude.m4: Delete
* m4/virt-compile-warnings.m4: Checks for GCC compiler flags
* m4/virt-pkgconfig-back-compat.m4: Backcompat check for
  pkgconfig program
2011-04-05 11:39:44 +01:00