From patchwork Wed Nov 11 13:07:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 38135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 15DEBB6F2B for ; Thu, 12 Nov 2009 00:17:20 +1100 (EST) Received: from localhost ([127.0.0.1]:37656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8D4X-0005xz-0n for incoming@patchwork.ozlabs.org; Wed, 11 Nov 2009 08:17:17 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8CxZ-000848-OX for qemu-devel@nongnu.org; Wed, 11 Nov 2009 08:10:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8CxU-00080j-KL for qemu-devel@nongnu.org; Wed, 11 Nov 2009 08:10:04 -0500 Received: from [199.232.76.173] (port=39505 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8CxU-00080e-DD for qemu-devel@nongnu.org; Wed, 11 Nov 2009 08:10:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30360) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8CxT-0006Kk-V2 for qemu-devel@nongnu.org; Wed, 11 Nov 2009 08:10:00 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nABD9xS4022882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Nov 2009 08:09:59 -0500 Received: from redhat.com (dhcp-0-94.tlv.redhat.com [10.35.0.94]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nABD9ts4025986; Wed, 11 Nov 2009 08:09:57 -0500 Date: Wed, 11 Nov 2009 15:07:26 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, quintela@trasno.org Message-ID: <20091111130726.GA29714@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCHv2] configure: use correct cflags in compiler checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org linux-user build on fedora 11 breaks because fallocate is broken on that system if -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 are specified, which is what QEMU uses. We do have a configure check to catch this and disable fallocate, however, it turns out that default QEMU_CFLAGS/LDFLAGS were assigned in script *after* all compiler checks: so during checks we were not running compiler with same flags that we used for build later. Fix this by moving QEMU_CFLAGS to before compiler checks, and using comple_prog when checking for fallocate. This also fixes the fact that we do some compiler checks while assigning the flags, right below a comment that says "no cc tests beyond this point". Move a couple of left-over checks to compile_prog so that this applies to them. Signed-off-by: Michael S. Tsirkin --- Changes from v1: kill ARCH_CFLAGS and update dup test as well configure | 43 ++++++++++++++++++++++--------------------- 1 files changed, 22 insertions(+), 21 deletions(-) diff --git a/configure b/configure index fb66246..0b69b4f 100755 --- a/configure +++ b/configure @@ -91,6 +91,26 @@ ar="${cross_prefix}${ar}" objcopy="${cross_prefix}${objcopy}" ld="${cross_prefix}${ld}" +# default flags for all hosts +QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS" +CFLAGS="-g $CFLAGS" +QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" +QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" +QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" +QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS" +QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS" +LDFLAGS="-g $LDFLAGS" + +gcc_flags="-Wold-style-declaration -Wold-style-definition" +cat > $TMPC << EOF +int main(void) { } +EOF +for flag in $gcc_flags; do + if compile_prog "$QEMU_CFLAGS" "$flag" ; then + QEMU_CFLAGS="$flag $QEMU_CFLAGS" + fi +done + # check that the C compiler works. cat > $TMPC < /dev/null ; then +if compile_prog "" "" ; then fallocate=yes fi @@ -1600,7 +1620,7 @@ int main(void) return 0; } EOF -if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then +if compile_prog "" "" ; then dup3=yes fi @@ -1733,28 +1753,9 @@ fi # End of CC checks # After here, no more $cc or $ld runs -# default flags for all hosts -QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS" -CFLAGS="-g $CFLAGS" if test "$debug" = "no" ; then CFLAGS="-O2 $CFLAGS" fi -QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" -QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" -QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" -QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS" -QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS" -LDFLAGS="-g $LDFLAGS" - -gcc_flags="-Wold-style-declaration -Wold-style-definition" -cat > $TMPC << EOF -int main(void) { } -EOF -for flag in $gcc_flags; do - if compile_prog "$QEMU_CFLAGS" "$flag" ; then - QEMU_CFLAGS="$flag $QEMU_CFLAGS" - fi -done # Consult white-list to determine whether to enable werror # by default. Only enable by default for git builds