Skip to contentSkip to conversation

configure: Fix -Werror issues

PATCH Applied Peter Maydell 3 participants 26 messages Jul 18, 2012 – Aug 11, 2012

lore
Share & tools
lore
#0 lore raw

cover configure: Fix -Werror issues

This patch series:
1. turns off -Werror for configure tests
2. fixes a large pile of warnings in various configure tests
3. turns on -Werror for configure tests again, but in a way that means that errors mean configure stops so the warnings are as obvious to developers as they would be for a -Werror compile of the main code

The "turn off -Werror" patch has already been sent to the list; I've included it here as it is a dependency, but it should probably be committed ASAP even if the rest of this series needs review and updating. I've also put all of Stefan's recent patches in since without them configure won't run once -Werror is reenabled.

NB: this works for me, but it's possible there are some still lurking warnings in a few compilation tests that are themselves protected by tests for some library/host I don't have. They should be easy to fix as they turn up, though, and the configure failure message is clear about how to work around in the meantime.

Peter Maydell (7):
configure: Don't run configure tests with -Werror enabled
configure: -march=i486 belongs in QEMU_CFLAGS, not CFLAGS
configure: Fix compile warning in PNG test
configure: Fix warnings in VDE library probe
configure: Fix compile warning in utimensat/futimens test
configure: -I\$(SRC_PATH) goes in QEMU_INCLUDES not QEMU_CFLAGS
configure: Check for -Werror causing failures when compiling tests

Stefan Weil (4):
configure: Fix build with ALSA audio driver
configure: Fix build with capabilities
configure: Replace bash code by standard shell code
configure: Fix errors in test for__sync_fetch_and_and

 configure |   73 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 57 insertions(+), 16 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/11 configure: Don't run configure tests with -Werror enabled

Don't run configure tests with -Werror in the compiler flags. The idea of -Werror is that it makes problems very obvious to developers, so they get fixed quickly. However, when running configure tests, failures due to -Werror are far from obvious -- they simply result in the test quietly failing when it should have passed. Not using -Werror is in line with recommended practice in the Autoconf world.

This commit is essentially backing out the changes in commit 417c9d72. Instead we fix the problem that commit was trying to address in a different way: we add -Werror only for the test of the nss headers, with a comment that this is specifically intended to detect a bug in some releases of nss.

We also have to clean up a bug in the smartcard test where it was trying to include smartcard_cflags in the test compile flags: this would always result in a failure with -Werror, because they include an escaped "$(SRC_PATH)" which is only valid when used in the final makefile.

---
 configure |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
configure +18 -4
index 0a3896e..383fa3d 100755
@@ -1156,9 +1156,10 @@ gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
 gcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
-if test "$werror" = "yes" ; then
-    gcc_flags="-Werror $gcc_flags"
-fi
+# Note that we do not add -Werror to gcc_flags here, because that would
+# enable it for all configure tests. If a configure test failed due
+# to -Werror this would just silently disable some features,
+# so it's too error prone.
 cat > $TMPC << EOF
 int main(void) { return 0; }
 EOF
@@ -2656,8 +2657,16 @@ EOF
         smartcard_cflags="-I\$(SRC_PATH)/libcacard"
         libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
         libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
+        test_cflags="$libcacard_cflags"
+        # The header files in nss < 3.13.3 have a bug which causes them to
+        # emit a warning. If we're going to compile QEMU with -Werror, then
+        # test that the headers don't have this bug. Otherwise we would pass
+        # the configure test but fail to compile QEMU later.
+        if test "$werror" = "yes"; then
+            test_cflags="-Werror $test_cflags"
+        fi
         if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
-          compile_prog "$smartcard_cflags $libcacard_cflags" "$libcacard_libs"; then
+          compile_prog "$test_cflags" "$libcacard_libs"; then
             smartcard_nss="yes"
             QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
             libs_softmmu="$libcacard_libs $libs_softmmu"
@@ -2903,6 +2912,11 @@ if test -z "$zero_malloc" ; then
     fi
 fi
 
+# Now we've finished running tests it's OK to add -Werror to the compiler flags
+if test "$werror" = "yes"; then
+    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
+fi
+
 if test "$solaris" = "no" ; then
     if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
         LDFLAGS="-Wl,--warn-common $LDFLAGS"
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/11 configure: Fix build with ALSA audio driver

In reply to Peter Maydell

From: Stefan Weil <[email protected]>

Since commit 417c9d72d48275d19c60861896efd4962d21aca2, all configure tests normally run with -Werror.

Some of these tests now fail because they raised a compiler warning.

Here a build breakage for ALSA (configure --audio-drv-list=alsa) is fixed.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 383fa3d..63156a7 100755
@@ -1889,7 +1889,7 @@ for drv in $audio_drv_list; do
     case $drv in
     alsa)
     audio_drv_probe $drv alsa/asoundlib.h -lasound \
-        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
+        "return snd_pcm_close((snd_pcm_t *)0);"
     libs_softmmu="-lasound $libs_softmmu"
     ;;
 
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/11 configure: Fix build with capabilities

In reply to Peter Maydell

From: Stefan Weil <[email protected]>

Since commit 417c9d72d48275d19c60861896efd4962d21aca2 all configure tests normally run with -Werror. Some of these tests now fail because they raised a compiler warning.

This patch fixes support for capabilities.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 63156a7..feadbe7 100755
@@ -2083,7 +2083,7 @@ if test "$cap" != "no" ; then
   cat > $TMPC <<EOF
 #include <stdio.h>
 #include <sys/capability.h>
-int main(void) { cap_t caps; caps = cap_init(); }
+int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
 EOF
   if compile_prog "" "-lcap" ; then
     cap=yes
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/11 configure: Replace bash code by standard shell code

In reply to Peter Maydell

From: Stefan Weil <[email protected]>

"+=" does not work with dash and other simple /bin/sh implementations.

The new code prepends the flag while the old code either did not work (it continued after an error message which typically was not read) or appended the flag. That difference should not matter here.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index feadbe7..f54415d 100755
@@ -2810,7 +2810,7 @@ int main(int argc, char **argv)
 }
 EOF
   if ! compile_prog "" "" ; then
-    CFLAGS+="-march=i486"
+    CFLAGS="-march=i486 $CFLAGS"
   fi
 fi
 
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH 5/11 configure: -march=i486 belongs in QEMU_CFLAGS, not CFLAGS

In reply to Peter Maydell

The distinction between QEMU_CFLAGS and CFLAGS is that the former is for flags without which QEMU can't compile, whereas the latter is for flags like "-g -O2" which the user can safely override. "-march=i486" is in the former category, and so belongs in QEMU_CFLAGS.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index f54415d..3de4ea7 100755
@@ -2810,7 +2810,7 @@ int main(int argc, char **argv)
 }
 EOF
   if ! compile_prog "" "" ; then
-    CFLAGS="-march=i486 $CFLAGS"
+    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
   fi
 fi
 
Signature · 1 line
1.7.5.4
#6 lore raw

PATCH 6/11 configure: Fix errors in test for__sync_fetch_and_and

In reply to Peter Maydell

From: Stefan Weil <[email protected]>

The old test code raises two compiler warnings which are errors since commit 417c9d72d48275d19c60861896efd4962d21aca2.

These errors could result in compilations with compiler flag -march486 (so all nice features of newer processors got lost).

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 3de4ea7..aced52e 100755
@@ -2797,7 +2797,7 @@ fi
 # specification is necessary
 if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
   cat > $TMPC << EOF
-int sfaa(unsigned *ptr)
+static int sfaa(int *ptr)
 {
   return __sync_fetch_and_and(ptr, 0);
 }
Signature · 1 line
1.7.5.4
#7 lore raw

PATCH 7/11 configure: Fix compile warning in PNG test

In reply to Peter Maydell

Fix compile warning (variable 'png_ptr' set but not used) in the PNG detection test code.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index aced52e..784325a 100755
@@ -1727,7 +1727,7 @@ cat > $TMPC <<EOF
 int main(void) {
     png_structp png_ptr;
     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    return 0;
+    return png_ptr != 0;
 }
 EOF
   if $pkg_config libpng --modversion >/dev/null 2>&1; then
Signature · 1 line
1.7.5.4
Reviewed-by on v1 7/11
#8 lore raw

Re: [Qemu-devel] [PATCH 07/11] configure: Fix compile warning in PNG test

Am 18.07.2012 16:10, schrieb Peter Maydell:

Quoted 13 lines

Fix compile warning (variable 'png_ptr' set but not used) in the PNG detection test code.

---
  configure |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
configure +0 -0
index aced52e..784325a 100755

configure cat > $TMPC <<EOF · line 1733

Quoted 8 lines
configure +1 -1
@@ -1727,7 +1727,7 @@ cat > $TMPC <<EOF
  int main(void) {
      png_structp png_ptr;
      png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    return 0;
+    return png_ptr != 0;
  }
  EOF
    if $pkg_config libpng --modversion >/dev/null 2>&1; then
#9 lore raw

PATCH 8/11 configure: Fix warnings in VDE library probe

In reply to Peter Maydell

Fix compile warnings in the VDE library probe ("passing argument 1 of 'vde_open_real' discards 'const' qualifier from pointer target type", ditto argument 2).

---
 configure |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
configure +2 -1
index 784325a..9c2a84d 100755
@@ -1820,7 +1820,8 @@ if test "$vde" != "no" ; then
 int main(void)
 {
     struct vde_open_args a = {0, 0, 0};
-    vde_open("", "", &a);
+    char s[] = "";
+    vde_open(s, s, &a);
     return 0;
 }
 EOF
Signature · 1 line
1.7.5.4
#10 lore raw

PATCH 9/11 configure: Fix compile warning in utimensat/futimens test

In reply to Peter Maydell

Fix compile warning in the utimensat/futimens test ("implicit declaration of function 'utimensat'", ditto futimens) by adding a missing include.

---
 configure |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
configure +1 -0
index 9c2a84d..638e486 100755
@@ -2341,6 +2341,7 @@ cat > $TMPC << EOF
 #define _ATFILE_SOURCE
 #include <stddef.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 
 int main(void)
 {
Signature · 1 line
1.7.5.4
Reviewed-by on v1 9/11
#11 lore raw

Re: [Qemu-devel] [PATCH 09/11] configure: Fix compile warning in utimensat/futimens test

Am 18.07.2012 16:10, schrieb Peter Maydell:

Quoted 14 lines

Fix compile warning in the utimensat/futimens test ("implicit declaration of function 'utimensat'", ditto futimens) by adding a missing include.

---
  configure |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
configure +0 -0
index 9c2a84d..638e486 100755

configure cat > $TMPC << EOF · line 2347

Quoted 7 lines
configure +1 -0
@@ -2341,6 +2341,7 @@ cat > $TMPC << EOF
  #define _ATFILE_SOURCE
  #include <stddef.h>
  #include <fcntl.h>
+#include <sys/stat.h>
 
  int main(void)
  {
#12 lore raw

PATCH 10/11 configure: -I\$(SRC_PATH) goes in QEMU_INCLUDES not QEMU_CFLAGS

In reply to Peter Maydell

If the smartcard configure check passes, add '-I\$(SRC_PATH)/libcacard' to QEMU_INCLUDES, not QEMU_CFLAGS. Otherwise the unexpanded SRC_PATH will cause a warning in every following configure test.

---
 configure |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
configure +3 -2
index 638e486..8140464 100755
@@ -2656,7 +2656,7 @@ if test "$smartcard" != "no" ; then
 #include <pk11pub.h>
 int main(void) { PK11_FreeSlot(0); return 0; }
 EOF
-        smartcard_cflags="-I\$(SRC_PATH)/libcacard"
+        smartcard_includes="-I\$(SRC_PATH)/libcacard"
         libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
         libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
         test_cflags="$libcacard_cflags"
@@ -2670,7 +2670,8 @@ EOF
         if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
           compile_prog "$test_cflags" "$libcacard_libs"; then
             smartcard_nss="yes"
-            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
+            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
+            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
             libs_softmmu="$libcacard_libs $libs_softmmu"
         else
             if test "$smartcard_nss" = "yes"; then
Signature · 1 line
1.7.5.4
#13 lore raw

PATCH 11/11 configure: Check for -Werror causing failures when compiling tests

In reply to Peter Maydell

Add support for checking whether test case code can compile without warnings, by recompiling each successful test with -Werror. If the -Werror version doesn't pass, we bail out. This gives us the same level of visibility of warnings in test code as --enable-werror provides for the main compile.

---
 configure |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)
configure +28 -4
index 8140464..1939bdb 100755
@@ -27,16 +27,40 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+do_cc() {
+    # Run the compiler, capturing its output to the log.
+    echo $cc "$@" >> config.log
+    $cc "$@" >> config.log 2>&1 || return $?
+    # Test passed. If this is an --enable-werror build, rerun
+    # the test with -Werror and bail out if it fails. This
+    # makes warning-generating-errors in configure test code
+    # obvious to developers.
+    if test "$werror" != "yes"; then
+        return 0
+    fi
+    # Don't bother rerunning the compile if we were already using -Werror
+    case "$*" in
+        *-Werror*)
+           return 0
+        ;;
+    esac
+    echo $cc -Werror "$@" >> config.log
+    $cc -Werror "$@" >> config.log 2>&1 && return $?
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1
+}
+
 compile_object() {
-  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
-  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
+  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
 }
 
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
-  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
+  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
 }
 
 # symbolically link $1 to $2.  Portable version of "ln -sf".
Signature · 1 line
1.7.5.4
#14 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 33 lines · Peter Maydell

Add support for checking whether test case code can compile without warnings, by recompiling each successful test with -Werror. If the -Werror version doesn't pass, we bail out. This gives us the same level of visibility of warnings in test code as --enable-werror provides for the main compile.

---
 configure |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)
configure +14 -0
index 8140464..1939bdb 100755
@@ -27,16 +27,40 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+do_cc() {
+    # Run the compiler, capturing its output to the log.
+    echo $cc "$@" >> config.log
+    $cc "$@" >> config.log 2>&1 || return $?
+    # Test passed. If this is an --enable-werror build, rerun
+    # the test with -Werror and bail out if it fails. This
+    # makes warning-generating-errors in configure test code
+    # obvious to developers.
+    if test "$werror" != "yes"; then
+        return 0
+    fi
+    # Don't bother rerunning the compile if we were already using -Werror
+    case "$*" in
+        *-Werror*)

configure printf " '%s'" "$0" "$@" >> config.log · line 53

Quoted 10 lines
configure +10 -0
+           return 0
+        ;;
+    esac
+    echo $cc -Werror "$@" >> config.log
+    $cc -Werror "$@" >> config.log 2>&1 && return $?
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1

This should be degraded to a warning, I'm getting configure breakage in some cases:
config-host.mak is out-of-date, running configure
ERROR: configure test passed without -Werror but failed with -Werror. This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

gcc -Werror -m32 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -o /tmp/qemu-conf--24538-.exe /tmp/qemu-conf--24538-.c -m32 -g
cc1: warnings being treated as errors /tmp/qemu-conf--24538-.c:2: error: unknown option after '#pragma GCC diagnostic' kind

Quoted 21 lines
configure +4 -5
+}
+
 compile_object() {
-  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
-  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
+  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
 }
 
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
-  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
+  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
 }
 
 # symbolically link $1 to $2.  Portable version of "ln -sf".
--

1.7.5.4

#15 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 8 lines · Blue Swirl

configure printf " '%s'" "$0" "$@" >> config.log · line 53

Quoted 5 lines · Peter Maydell
configure +5 -0
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1

This should be degraded to a warning

The idea is that by running configure with --enable-werror (either explicitly or implicitly for a git build) you've asked for compile warnings to cause build failure. We're just doing that in configure as well as for the main build.

Quoted 2 lines

, I'm getting configure breakage
in some cases:

The thesis of the patch series is that these represent bugs to be fixed.

-- PMM

#16 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 15 lines · Peter Maydell
Quoted 8 lines · Blue Swirl

configure printf " '%s'" "$0" "$@" >> config.log · line 53

Quoted 5 lines · Peter Maydell
configure +5 -0
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1

This should be degraded to a warning

The idea is that by running configure with --enable-werror (either explicitly or implicitly for a git build) you've asked for compile warnings to cause build failure. We're just doing that in configure as well as for the main build.

Quoted 4 lines
Quoted 2 lines

, I'm getting configure breakage
in some cases:

The thesis of the patch series is that these represent bugs to be fixed.

Yes, but then the errors should be fixed by the series. When adding new GCC warning flags, I also fixed the causes for the warning first. Committing known build breakages is not OK.

Quoted 2 lines

-- PMM

#17 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 10 lines · Blue Swirl
Quoted 4 lines · Peter Maydell
Quoted 1 line · Blue Swirl

, I'm getting configure breakage in some cases:

The thesis of the patch series is that these represent bugs to be fixed.

Yes, but then the errors should be fixed by the series. When adding new GCC warning flags, I also fixed the causes for the warning first. Committing known build breakages is not OK.

I fixed all the ones I saw on my system, obviously. I'll have a look at this one.

I think it would be worth committing patches 1-10 now anyway : those fix configure issues (patch 1 in particular fixes the problem of tests silently failing when they should pass).

-- PMM

#18 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 12 lines · Peter Maydell
Quoted 10 lines · Blue Swirl
Quoted 4 lines · Peter Maydell
Quoted 1 line · Blue Swirl

, I'm getting configure breakage in some cases:

The thesis of the patch series is that these represent bugs to be fixed.

Yes, but then the errors should be fixed by the series. When adding new GCC warning flags, I also fixed the causes for the warning first. Committing known build breakages is not OK.

Quoted 6 lines

I fixed all the ones I saw on my system, obviously. I'll have a look at this one.

I think it would be worth committing patches 1-10 now anyway : those fix configure issues (patch 1 in particular fixes the problem of tests silently failing when they should pass).

OK, I'll test those.

Quoted 2 lines

-- PMM

#19 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

In reply to Peter Maydell
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Blue Swirl
Quoted 4 lines · Peter Maydell
Quoted 1 line · Blue Swirl

, I'm getting configure breakage in some cases:

The thesis of the patch series is that these represent bugs to be fixed.

Yes, but then the errors should be fixed by the series. When adding new GCC warning flags, I also fixed the causes for the warning first. Committing known build breakages is not OK.

Quoted 6 lines

I fixed all the ones I saw on my system, obviously. I'll have a look at this one.

I think it would be worth committing patches 1-10 now anyway : those fix configure issues (patch 1 in particular fixes the problem of tests silently failing when they should pass).

I'm getting this error, probably because now Valgrind support is enabled:
CC coroutine-ucontext.o
cc1: warnings being treated as errors /src/qemu/coroutine-ucontext.c:204: error: unknown option after '#pragma GCC diagnostic' kind /src/qemu/coroutine-ucontext.c:209: error: unknown option after '#pragma GCC diagnostic' kind

Maybe the compiler does not understand this pragma and Valgrind check should also fail in that case.

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib
--enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8)
Quoted 2 lines

-- PMM

#20 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 10 lines · Blue Swirl

I'm getting this error, probably because now Valgrind support is enabled:
CC coroutine-ucontext.o
cc1: warnings being treated as errors /src/qemu/coroutine-ucontext.c:204: error: unknown option after '#pragma GCC diagnostic' kind /src/qemu/coroutine-ucontext.c:209: error: unknown option after '#pragma GCC diagnostic' kind

Maybe the compiler does not understand this pragma and Valgrind check should also fail in that case.

Yeah, I think this is one of the few tests which want to explicitly check "is this construct going to provoke a compiler warning" -- fix is for that test to explictly put -Werror in the cflags in the compile_prog line.

-- PMM

#21 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 9 lines · Peter Maydell
Quoted 8 lines · Blue Swirl

I'm getting this error, probably because now Valgrind support is enabled:
CC coroutine-ucontext.o
cc1: warnings being treated as errors /src/qemu/coroutine-ucontext.c:204: error: unknown option after '#pragma GCC diagnostic' kind /src/qemu/coroutine-ucontext.c:209: error: unknown option after '#pragma GCC diagnostic' kind

Quoted 7 lines
Quoted 2 lines

Maybe the compiler does not understand this pragma and Valgrind check should also fail in that case.

Yeah, I think this is one of the few tests which want to explicitly check "is this construct going to provoke a compiler warning" -- fix is for that test to explictly put -Werror in the cflags in the compile_prog line.

Now with your Xen configure patches in place, I'm not getting errors with this applied except for Clang (which I didn't test earlier). Maybe this should be applied.

clang -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g /tmp/qemu-conf--25992-.c:4:32: warning: self-comparison always evaluates to true [-Wtautological-compare]
int main(void) { return preadv == preadv; }

                               ^

1 warning generated.
clang -Werror -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g /tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
int main(void) { return preadv == preadv; }

                               ^

1 error generated.
ERROR: configure test passed without -Werror but failed with -Werror.

clang -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g /tmp/qemu-conf--25992-.c:13:26: warning: self-comparison always evaluates to true [-Wtautological-compare]

    return epoll_create1 == epoll_create1;
                         ^

1 warning generated.
clang -Werror -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g /tmp/qemu-conf--25992-.c:13:26: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]

    return epoll_create1 == epoll_create1;
                         ^

1 error generated.
ERROR: configure test passed without -Werror but failed with -Werror.

clang -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -I/usr/include/nss -I/usr/include/nspr -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g
/tmp/qemu-conf--25992-.c:3:13: warning: explicitly assigning a variable of type 'char **' to itself [-Wself-assign]

    environ = environ;
    ~~~~~~~ ^ ~~~~~~~

1 warning generated.
clang -Werror -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -I/usr/include/libpng12 -I/usr/include/nss -I/usr/include/nspr -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o /tmp/qemu-conf--25992-.exe /tmp/qemu-conf--25992-.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g
/tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable of type 'char **' to itself [-Werror,-Wself-assign]

    environ = environ;
    ~~~~~~~ ^ ~~~~~~~

1 error generated.
ERROR: configure test passed without -Werror but failed with -Werror.

I used this hack to get more than one warning:

configure +0 -1
index d8ec050..eb2ed2f 100755
@@ -46,11 +46,11 @@ do_cc() {
     esac
     echo $cc -Werror "$@" >> config.log
     $cc -Werror "$@" >> config.log 2>&1 && return $?
-    echo "ERROR: configure test passed without -Werror but failed

with -Werror."

-    echo "This is probably a bug in the configure script. The failing command"
-    echo "will be at the bottom of config.log."
-    echo "You can run configure with --disable-werror to bypass this check."
-    exit 1
+    echo "ERROR: configure test passed without -Werror but failed

with -Werror." >> config.log
+ echo "This is probably a bug in the configure script. The failing
command" >> config.log
+ echo "will be at the bottom of config.log." >> config.log
+ echo "You can run configure with --disable-werror to bypass this
check." >> config.log
+# exit 1
}

compile_object() {

Quoted 2 lines

-- PMM

#22 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 13 lines · Blue Swirl
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Blue Swirl

I'm getting this error, probably because now Valgrind support is enabled:
CC coroutine-ucontext.o
cc1: warnings being treated as errors /src/qemu/coroutine-ucontext.c:204: error: unknown option after '#pragma GCC diagnostic' kind /src/qemu/coroutine-ucontext.c:209: error: unknown option after '#pragma GCC diagnostic' kind

Maybe the compiler does not understand this pragma and Valgrind check should also fail in that case.

Quoted 8 lines
Quoted 4 lines

Yeah, I think this is one of the few tests which want to explicitly check "is this construct going to provoke a compiler warning" -- fix is for that test to explictly put -Werror in the cflags in the compile_prog line.

Now with your Xen configure patches in place, I'm not getting errors with this applied except for Clang (which I didn't test earlier). Maybe this should be applied.

Yes, I think that (assuming we are going to go down this route at all) it would be good to apply this 11/11 patch now in good time before the freeze. Does anybody want to object?

thanks
-- PMM

#23 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

Quoted 19 lines · Peter Maydell
Quoted 18 lines · Blue Swirl
Quoted 16 lines · Peter Maydell
Quoted 10 lines · Blue Swirl

I'm getting this error, probably because now Valgrind support is enabled:
CC coroutine-ucontext.o
cc1: warnings being treated as errors /src/qemu/coroutine-ucontext.c:204: error: unknown option after '#pragma GCC diagnostic' kind /src/qemu/coroutine-ucontext.c:209: error: unknown option after '#pragma GCC diagnostic' kind

Maybe the compiler does not understand this pragma and Valgrind check should also fail in that case.

Yeah, I think this is one of the few tests which want to explicitly check "is this construct going to provoke a compiler warning" -- fix is for that test to explictly put -Werror in the cflags in the compile_prog line.

Quoted 7 lines
Quoted 3 lines

Now with your Xen configure patches in place, I'm not getting errors with this applied except for Clang (which I didn't test earlier). Maybe this should be applied.

Yes, I think that (assuming we are going to go down this route at all) it would be good to apply this 11/11 patch now in good time before the freeze. Does anybody want to object?

I'll send a patch that fixes configure with Clang.

Quoted 3 lines

thanks
-- PMM

Applied
#24 lore raw

Re: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests

In reply to Peter Maydell

Thanks, applied.

Quoted 64 lines · Peter Maydell

Add support for checking whether test case code can compile without warnings, by recompiling each successful test with -Werror. If the -Werror version doesn't pass, we bail out. This gives us the same level of visibility of warnings in test code as --enable-werror provides for the main compile.

---
 configure |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)
configure +28 -5
index 8140464..1939bdb 100755
@@ -27,16 +27,40 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+do_cc() {
+    # Run the compiler, capturing its output to the log.
+    echo $cc "$@" >> config.log
+    $cc "$@" >> config.log 2>&1 || return $?
+    # Test passed. If this is an --enable-werror build, rerun
+    # the test with -Werror and bail out if it fails. This
+    # makes warning-generating-errors in configure test code
+    # obvious to developers.
+    if test "$werror" != "yes"; then
+        return 0
+    fi
+    # Don't bother rerunning the compile if we were already using -Werror
+    case "$*" in
+        *-Werror*)
+           return 0
+        ;;
+    esac
+    echo $cc -Werror "$@" >> config.log
+    $cc -Werror "$@" >> config.log 2>&1 && return $?
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1
+}
+
 compile_object() {
-  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
-  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
+  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
 }
 
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
-  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
+  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
 }
 
 # symbolically link $1 to $2.  Portable version of "ln -sf".
--

1.7.5.4

Applied
#25 lore raw
In reply to Peter Maydell

Thanks, applied patches 1 to 10.

Quoted 41 lines · Peter Maydell

This patch series:
1. turns off -Werror for configure tests
2. fixes a large pile of warnings in various configure tests
3. turns on -Werror for configure tests again, but in a way that means that errors mean configure stops so the warnings are as obvious to developers as they would be for a -Werror compile of the main code

The "turn off -Werror" patch has already been sent to the list; I've included it here as it is a dependency, but it should probably be committed ASAP even if the rest of this series needs review and updating. I've also put all of Stefan's recent patches in since without them configure won't run once -Werror is reenabled.

NB: this works for me, but it's possible there are some still lurking warnings in a few compilation tests that are themselves protected by tests for some library/host I don't have. They should be easy to fix as they turn up, though, and the configure failure message is clear about how to work around in the meantime.

Peter Maydell (7):
configure: Don't run configure tests with -Werror enabled
configure: -march=i486 belongs in QEMU_CFLAGS, not CFLAGS
configure: Fix compile warning in PNG test
configure: Fix warnings in VDE library probe
configure: Fix compile warning in utimensat/futimens test
configure: -I\$(SRC_PATH) goes in QEMU_INCLUDES not QEMU_CFLAGS
configure: Check for -Werror causing failures when compiling tests

Stefan Weil (4):
configure: Fix build with ALSA audio driver
configure: Fix build with capabilities
configure: Replace bash code by standard shell code
configure: Fix errors in test for__sync_fetch_and_and

 configure |   73 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 57 insertions(+), 16 deletions(-)

--
1.7.5.4