From nobody Fri Dec 19 21:48:36 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1670585870; cv=none; d=zohomail.com; s=zohoarc; b=jnin5RNTpCaSMraGwrW5mg8LN/DLp/4AKk0uMJniMIal6GyMDB4MLHjhTvLwQtZ8xBFS46TiRq0hf2bKVOqBjLtk11aw0kn+aDeMIOx3TQ5S/sKjrY7gMpmU3jaGvcrtoKCWwG1iUDWKI6pMmFQ9ugm2gy125UJ++moIU5wIMuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670585870; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hi9wAKVzCZ1hT1TsF3V5eUrMQ7ppn0EvxBQacimafSo=; b=C2NkgVw2UcEe+TX8RZSkdpp3+dRGDk930H9T/Tfo7xxzdwyjUc5oysfAToqW/RKZsCa14uJq0QaYl5q2ah//EtMPgfX+ZvHnKWseiLoX0qIh4Te+NG4bCoOdXK2zM238Sek3m8KG6vNos2umWKI8zokRwpF/VyphZO6yNgNkIRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670585869864348.36412850164345; Fri, 9 Dec 2022 03:37:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3bXF-0005wm-Gw; Fri, 09 Dec 2022 06:27:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3bW1-0004ca-G6 for qemu-devel@nongnu.org; Fri, 09 Dec 2022 06:26:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3bVq-0001ZN-0w for qemu-devel@nongnu.org; Fri, 09 Dec 2022 06:26:01 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-358-kXKQrkhkMUiTKBIAY7sH5Q-1; Fri, 09 Dec 2022 06:25:42 -0500 Received: by mail-ej1-f71.google.com with SMTP id ds15-20020a170907724f00b007c0abebc958so2892867ejc.2 for ; Fri, 09 Dec 2022 03:25:42 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id v9-20020a170906292900b007c0aefd9339sm451176ejd.175.2022.12.09.03.25.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 03:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670585144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hi9wAKVzCZ1hT1TsF3V5eUrMQ7ppn0EvxBQacimafSo=; b=EYOCI+0oCmuuqGMqvNPCOsI7OM+2KGw0Ex7SrKqHnJov0+pIKItbuEw0Gon3jGoLECUYJg oEZ4MynlqnulKoQ15OimB3Ck5DXkwwtxJR8VX47EKZpeqGyT3MHQUitrlro9ORjZAROYYz AKzVjKZ+2tEyJbAuUF/it9gX6oC8UEc= X-MC-Unique: kXKQrkhkMUiTKBIAY7sH5Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hi9wAKVzCZ1hT1TsF3V5eUrMQ7ppn0EvxBQacimafSo=; b=nnbxcsP06hsuHKqj9yKrH5leTNj4mouD5MTyYWksqrmIUw/HAxN8CCp4MMUE5xolhr pZBDMcNLnq5Z4h1/ZkI53Fv0AoVPerqvpEZHC9p3JxQJSNjm2M5g6ciFALraQKOCz4rh deA0l3JJbIk9w6pHSq8YWNrPDURuwDy82FjNB1gW4jnIXYt+Jmk1RGRBxMLnAgGS9z7T SMQvPf+br1iP9OVhqaOXZoGl12nExVNK84loOawuHgaEwhPzC0dH4HRCDh6+QQOaWPL4 kwchYoFYdb0891SEMDh9HYhPPTZ3+ppU1ha59j78eS9R5eySy88LosuMyLzku+V/+B+Y 9LCg== X-Gm-Message-State: ANoB5pkfmajsA4yXqJS6uVuCI0dncu8vALpGvVTACsl/fOSTnUSkSqrS ARTmlIztDQp3cxEY5Z1WuJ7gjgEacdM46CkqNP1gzWKh3kdhLCbDFTTR3KTktLz/qf98CfhcqW1 9dWItv1jRzt2V+unVaDCANvX+0Bfr9pUQI4eGu6qlUi0lqJo94yjg/kSBuV/gtD3aZPA= X-Received: by 2002:a17:906:f856:b0:7c0:b0f9:e360 with SMTP id ks22-20020a170906f85600b007c0b0f9e360mr4512634ejb.16.1670585141299; Fri, 09 Dec 2022 03:25:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4H+o29F1rU7fRcwelOoA8l+BetiuHfH9JhrPQcIDCtTKZ1v4ifg9lzPVjC9Jlmj75G3ry4ew== X-Received: by 2002:a17:906:f856:b0:7c0:b0f9:e360 with SMTP id ks22-20020a170906f85600b007c0b0f9e360mr4512613ejb.16.1670585140755; Fri, 09 Dec 2022 03:25:40 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 26/30] build: move remaining compiler flag tests to meson Date: Fri, 9 Dec 2022 12:24:05 +0100 Message-Id: <20221209112409.184703-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209112409.184703-1-pbonzini@redhat.com> References: <20221209112409.184703-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1670585870583100003 Content-Type: text/plain; charset="utf-8" Remove the only remaining uses of QEMU_CFLAGS. Now that no feature tests are done in configure, it is possible to remove CONFIGURE_CFLAGS and CONFIGURE_LDFLAGS as well. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- configure | 79 ++++++++--------------------------------------------- meson.build | 49 ++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 69 deletions(-) diff --git a/configure b/configure index 6df61f4337e4..d5491fc3b986 100755 --- a/configure +++ b/configure @@ -158,14 +158,14 @@ do_cc() { =20 compile_object() { local_cflags=3D"$1" - do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags= -c -o $TMPO $TMPC + do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC } =20 compile_prog() { local_cflags=3D"$1" local_ldflags=3D"$2" - do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags= -o $TMPE $TMPC \ - $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $local_ldflags + do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \ + $LDFLAGS $EXTRA_LDFLAGS $local_ldflags } =20 # symbolically link $1 to $2. Portable version of "ln -sf". @@ -351,19 +351,6 @@ windres=3D"${WINDRES-${cross_prefix}windres}" pkg_config=3D"${PKG_CONFIG-${cross_prefix}pkg-config}" sdl2_config=3D"${SDL2_CONFIG-${cross_prefix}sdl2-config}" =20 -# default flags for all hosts -# We use -fwrapv to tell the compiler that we require a C dialect where -# left shift of signed integers is well defined and has the expected -# 2s-complement style results. (Both clang and gcc agree that it -# provides these semantics.) -QEMU_CFLAGS=3D"-fno-strict-aliasing -fno-common -fwrapv" -QEMU_CFLAGS=3D"-D_GNU_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE = $QEMU_CFLAGS" - -# Flags that are needed during configure but later taken care of by Meson -CONFIGURE_CFLAGS=3D"-std=3Dgnu11 -Wall" -CONFIGURE_LDFLAGS=3D - - check_define() { cat > $TMPC < $TMPC << EOF -static int sfaa(int *ptr) -{ - return __sync_fetch_and_and(ptr, 0); -} - -int main(void) -{ - int val =3D 42; - val =3D __sync_val_compare_and_swap(&val, 0, 1); - sfaa(&val); - return val; -} -EOF - if ! compile_prog "" "" ; then - QEMU_CFLAGS=3D"-march=3Di486 $QEMU_CFLAGS" - fi -fi =20 if test -z "${target_list+xxx}" ; then default_targets=3Dyes @@ -1834,7 +1778,6 @@ echo "MESON=3D$meson" >> $config_host_mak echo "NINJA=3D$ninja" >> $config_host_mak echo "PKG_CONFIG=3D${pkg_config_exe}" >> $config_host_mak echo "CC=3D$cc" >> $config_host_mak -echo "QEMU_CFLAGS=3D$QEMU_CFLAGS" >> $config_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak =20 # use included Linux headers diff --git a/meson.build b/meson.build index 4ec8104b73a3..01c6ac0045bc 100644 --- a/meson.build +++ b/meson.build @@ -190,10 +190,50 @@ endif # Compiler flags # ################## =20 -qemu_common_flags =3D config_host['QEMU_CFLAGS'].split() +# default flags for all hosts +# We use -fwrapv to tell the compiler that we require a C dialect where +# left shift of signed integers is well defined and has the expected +# 2s-complement style results. (Both clang and gcc agree that it +# provides these semantics.) + +qemu_common_flags =3D [ + '-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=3D64', '-D_LARGEFILE_SOURCE', + '-fno-strict-aliasing', '-fno-common', '-fwrapv' ] qemu_cflags =3D [] qemu_ldflags =3D [] =20 +if targetos =3D=3D 'darwin' + # Disable attempts to use ObjectiveC features in os/object.h since they + # won't work when we're compiling with gcc as a C compiler. + qemu_common_flags +=3D '-DOS_OBJECT_USE_OBJC=3D0' +elif targetos =3D=3D 'solaris' + # needed for CMSG_ macros in sys/socket.h + qemu_common_flags +=3D '-D_XOPEN_SOURCE=3D600' + # needed for TIOCWIN* defines in termios.h + qemu_common_flags +=3D '-D__EXTENSIONS__' +elif targetos =3D=3D 'haiku' + qemu_common_flags +=3D ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE'= , '-fPIC'] +endif + +# __sync_fetch_and_and requires at least -march=3Di486. Many toolchains +# use i686 as default anyway, but for those that don't, an explicit +# specification is necessary +if host_arch =3D=3D 'i386' and not cc.links(''' + static int sfaa(int *ptr) + { + return __sync_fetch_and_and(ptr, 0); + } + + int main(void) + { + int val =3D 42; + val =3D __sync_val_compare_and_swap(&val, 0, 1); + sfaa(&val); + return val; + }''') + qemu_common_flags =3D ['-march=3Di486'] + qemu_common_flags +endif + if get_option('gprof') qemu_common_flags +=3D ['-p'] qemu_ldflags +=3D ['-p'] @@ -203,6 +243,13 @@ if get_option('prefer_static') qemu_ldflags +=3D get_option('b_pie') ? '-static-pie' : '-static' endif =20 +# Meson currently only handles pie as a boolean for now, so if the user +# has explicitly disabled PIE we need to extend our cflags. +if not get_option('b_pie') + qemu_cflags +=3D cc.get_supported_arguments('-fno-pie') + qemu_ldflags +=3D cc.get_supported_link_arguments('-no-pie') +endif + if not get_option('stack_protector').disabled() stack_protector_probe =3D ''' int main(int argc, char *argv[]) --=20 2.38.1