[Pkg-libvirt-commits] [libguestfs] 84/146: Use -fno-strict-overflow throughout the build.

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 17:00:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch master
in repository libguestfs.

commit f0ec293554e3b4968fc523a21fd10f944051191b
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Dec 15 22:26:51 2014 +0000

    Use -fno-strict-overflow throughout the build.
    
    Builds of bison-generated files currently fail with:
    
    index-parse.y: In function 'yyparse':
    index-parse.c:1256:6: error: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Werror=strict-overflow]
         if (yyss + yystacksize - 1 <= yyssp)
            ^
    
    This error only occurred on one machine, and it was unclear why.  It
    turned out to be because the other build machines I use had:
    
      CFLAGS="-Wall" ./configure ...
    
    whereas on the failing machine I was just using ./configure w/o CFLAGS.
    
    This caused the compile flags of index-parse.c to be changed from:
    
      gcc -Wstrict-overflow ... index-parse.c
    
    to:
    
      gcc -Wstrict-overflow -Wall ... index-parse.c
    
    but since -Wstrict-overflow is short for -Wstrict-overflow=2, and
    -Wall is short for -Wstrict-overflow=1, and since the error only
    occurs at level >= 2, using CFLAGS="-Wall" was effectively turned off
    the warning.
    
    Anyway, I believe the optimizations that GCC does when
    -fstrict-overflow is enabled to be dubious, frequently dangerous, and
    useless.  They are only done because we want C99 to work on
    architectures that don't exist in reality (and which even if they did
    exist, libguestfs would probably not support).
    
    The Linux kernel uses -fno-strict-overflow, and we should too, for the
    same reasons.
    
    (cherry picked from commit 2162d09b2c9e138779d95f1fc7c3409765a5a40c)
---
 configure.ac | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/configure.ac b/configure.ac
index d3b9fbb..cfd3b78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,14 @@ test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
 
 AM_PROG_CC_C_O
 
+# Provide a global place to set CFLAGS.  (Note that setting AM_CFLAGS
+# is no use because it doesn't override target_CFLAGS).
+#---
+# Kill -fstrict-overflow which is a license for the C compiler to make
+# dubious and often unsafe optimizations, in a time-wasting attempt to
+# deal with CPU architectures that do not exist.
+CFLAGS="$CFLAGS -fno-strict-overflow -Wno-strict-overflow"
+
 dnl Work out how to specify the linker script to the linker.
 VERSION_SCRIPT_FLAGS=-Wl,--version-script=
 `/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null` || \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list