From patchwork Mon Feb 24 19:08:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 25208 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1F972066C for ; Mon, 24 Feb 2014 19:08:25 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id le5sf12309449vcb.11 for ; Mon, 24 Feb 2014 11:08:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=R6MdYN3aKeDrriNlcZg4oNhbcekoEtz9k98vKi0CRng=; b=jHgzcsYGCwDTMVqpkMzaD4dTo3XlGaG9oPMIPSbLl/eLwRgKcF9xSE+FYl6bUnvT0s +zG6d4efWygR6zv7h1tbrDApELlIO/nJdlGAmoKs0d2TbeZIPTm8TG66qio7C0+HA+6K HR8ZMyZAZjRkxZezfKtLWouNGrjiElv1YOAguN//YNmVRwTNtYSnMdsDgxNvNJJApVoP sBRYaSVE3G7o3i2fbfK0MbVPV33YkvQ8DoYjxbq8QK59uRW0RZPjz4ofoFhpXYdg8HLB QYj5UpUx69atwv+lULXKDflnqXh4kt99M5Cpfs3KGmKnXEpQRDpz8X9XuQmzFParNXXX EFpw== X-Gm-Message-State: ALoCoQn3u6Ukvoo/xHqH433XJewuHa99oTXVj1d//oDNSVfgSpAPBQgevpsPNRj5MNqd4X567AxQ X-Received: by 10.236.18.196 with SMTP id l44mr209536yhl.52.1393268905056; Mon, 24 Feb 2014 11:08:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.169 with SMTP id o38ls1283872qge.37.gmail; Mon, 24 Feb 2014 11:08:24 -0800 (PST) X-Received: by 10.52.172.39 with SMTP id az7mr168489vdc.87.1393268904723; Mon, 24 Feb 2014 11:08:24 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id p9si6099801vdv.83.2014.02.24.11.08.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 11:08:24 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so6198980vcb.11 for ; Mon, 24 Feb 2014 11:08:24 -0800 (PST) X-Received: by 10.220.188.10 with SMTP id cy10mr13696436vcb.36.1393268904584; Mon, 24 Feb 2014 11:08:24 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp82979vcz; Mon, 24 Feb 2014 11:08:24 -0800 (PST) X-Received: by 10.180.72.195 with SMTP id f3mr15492642wiv.61.1393268903617; Mon, 24 Feb 2014 11:08:23 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id jy10si16114403wjc.173.2014.02.24.11.08.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 24 Feb 2014 11:08:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WI0t0-0005Mi-HK; Mon, 24 Feb 2014 19:08:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexey Kardashevskiy , Thomas Huth , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH] configure: Make C++ test work with --enable-werror Date: Mon, 24 Feb 2014 19:08:18 +0000 Message-Id: <1393268898-20599-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , gcc's C++ compiler complains about being passed some -W options which make sense for C but not for C++. This means we mustn't try a C++ compile with QEMU_CFLAGS, but only with a filtered version that removes the offending options. This filtering was already being done for uses of C++ in the build itself, but was omitted for the "does C++ work?" configure test. This only showed up when doing builds which explicitly enabled -Werror with --enable-werror, because the "do the compilers work" tests were mistakenly placed above the "default werror based on whether compiling from git" code. Further, when the test did fail configure would plunge on regardless of the error since we were running do_cc in a subshell. Fix this complex of errors: 1. Move the default-werror code up so that there are no invocations of compile_object and friends between it and the point where we set $werror explicitly based on the --enable-werror command line option. 2. Provide a mechanism for filtering QEMU_CFLAGS to create QEMU_CXXFLAGS, and use it for the test we run here. 3. Provide a do_cxx function to run a test with the C++ compiler rather than doing cute tricks with subshells and do_cc. Signed-off-by: Peter Maydell --- This was pretty confusing to debug (mostly because I got tripped up by the issue fixed by 1. above)... We could probably roll do_libtool into do_compiler, but I'd rather not mix that cleanup up with this build-breakage fix. configure | 70 +++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/configure b/configure index 00f9070..d5929d6 100755 --- a/configure +++ b/configure @@ -54,10 +54,13 @@ error_exit() { exit 1 } -do_cc() { - # Run the compiler, capturing its output to the log. - echo $cc "$@" >> config.log - $cc "$@" >> config.log 2>&1 || return $? +do_compiler() { + # Run the compiler, capturing its output to the log. First argument + # is compiler binary to execute. + local compiler="$1" + shift + echo $compiler "$@" >> config.log + $compiler "$@" >> 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 @@ -71,14 +74,39 @@ do_cc() { return 0 ;; esac - echo $cc -Werror "$@" >> config.log - $cc -Werror "$@" >> config.log 2>&1 && return $? + echo $compiler -Werror "$@" >> config.log + $compiler -Werror "$@" >> config.log 2>&1 && return $? error_exit "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." } +do_cc() { + do_compiler "$cc" "$@" +} + +do_cxx() { + do_compiler "$cxx" "$@" +} + +update_cxxflags() { + # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those + # options which some versions of GCC's C++ compiler complain about + # because they only make sense for C programs. + QEMU_CXXFLAGS= + for arg in $QEMU_CFLAGS; do + case $arg in + -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ + -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) + ;; + *) + QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg + ;; + esac + done +} + compile_object() { do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC } @@ -1320,6 +1348,19 @@ if test "$ARCH" = "unknown"; then fi fi +# Consult white-list to determine whether to enable werror +# by default. Only enable by default for git builds +z_version=`cut -f3 -d. $source_path/VERSION` + +if test -z "$werror" ; then + if test -d "$source_path/.git" -a \ + "$linux" = "yes" ; then + werror="yes" + else + werror="no" + fi +fi + # check that the C compiler works. cat > $TMPC <