From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUxd-0006f0-D3 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 10:10:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrUxX-0006NQ-6j for qemu-devel@nongnu.org; Wed, 18 Jul 2012 10:10:41 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:53934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUxW-0006N5-W9 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 10:10:35 -0400 From: Peter Maydell Date: Wed, 18 Jul 2012 15:10:28 +0100 Message-Id: <1342620628-12751-12-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1342620628-12751-1-git-send-email-peter.maydell@linaro.org> References: <1342620628-12751-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 11/11] configure: Check for -Werror causing failures when compiling tests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Weil , patches@linaro.org 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. Signed-off-by: Peter Maydell --- configure | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 8140464..1939bdb 100755 --- a/configure +++ b/configure @@ -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