From nobody Tue Feb 10 12:59:14 2026 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=1683798713; cv=none; d=zohomail.com; s=zohoarc; b=iGPZuxnJxg1XIzNnj7/leeIEpf42cVvspJoBGBNWyhR2mjmsiZxeVqgPORGC9IVY8y1mb8AK2zYf35eTGOVny0xUgYw/L1kftlYTXlQwBZ0F3TX52Qs83XWDS6kaa6NDYd5LPjWrVI71dp98FLtiw2srBkVOxtrB/qULnWgkHZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683798713; h=Content-Type:Content-Transfer-Encoding:Cc: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=CeKvvM1jIb2vxrKSY2nYgD30BwzZrIEtxd7XjUxzTiI=; b=WW17F81pR4qoR1ri7mpi8Pn+vM2oi/2076chQhZZpEBItEupis3lf4jrhXb0AMuUXZ+I7ShY/HgOSDf3M5goOSPft38ZciZFewU4czfxtSglsVAlqQ6h9eKuOrydTp/cqNFnkPnNu2uShbL3u86hD8THhGYFYnyogBufzS+lB9o= 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 1683798713051382.3911968849591; Thu, 11 May 2023 02:51:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1px2xB-0000zK-Vz; Thu, 11 May 2023 05:51:18 -0400 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 1px2x2-0000j5-G5 for qemu-devel@nongnu.org; Thu, 11 May 2023 05:51:09 -0400 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 1px2x0-0006kL-E5 for qemu-devel@nongnu.org; Thu, 11 May 2023 05:51:08 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-cVZFkB1VOniKV5u9NxxAyw-1; Thu, 11 May 2023 05:51:02 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-965c6f849b9so917739666b.2 for ; Thu, 11 May 2023 02:51:02 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id nr1-20020a1709068b8100b00959b3c30f2csm3768559ejc.222.2023.05.11.02.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 02:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683798664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CeKvvM1jIb2vxrKSY2nYgD30BwzZrIEtxd7XjUxzTiI=; b=SIzB9YMvgsTHxxntFbaPftRphcf60vhWcXdfaYOq0IBEjUzd1aBLTob9f1kBWWTYrneBn6 QBIifp5yWcovOsX3NS8y9gTSrwYVkkPi+1ojlNbxyrHF2Koxy9r35bk7ZFstvqqdRSIMKq muHsbeeZhX9KZdStmyBeOQy+lD6hBd0= X-MC-Unique: cVZFkB1VOniKV5u9NxxAyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683798660; x=1686390660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CeKvvM1jIb2vxrKSY2nYgD30BwzZrIEtxd7XjUxzTiI=; b=hlv8/oTcraZhfkA738jsErw7Mn+Y853nHnvkzIU3ctW3tWPSG4dYh5xR+pizBkvsV/ LjKe9Ug97Xc5xqKf4RU2zo/14xgvXAqO7Ce9ua3twBPovi9PQbGW70BOk7mwq2qdaMxs yzoyt0KirdVW8lnU90TislJ/TbTLJZeSkaMbm8B2IHkur5Db2tnbfiMqtIwPvJ7REyFK NlAB5fZ5h8Z1/CIhi1ze4SlclLiN9xo/91rM/fJrdZGlS/0hllLSJkCMPrQlV63Au6RW bSWQdSesToUL3eeoQX5pg9+dXbtRnW4fWmBTZugK5k1WkPsyTXxb5qZJ5WC259eJmxHj iDTg== X-Gm-Message-State: AC+VfDxr+GPPfHdrY6MjhFHdYZqjPGy7PMYX5cNhlhFctgzDiaKYKY1o cQMhffLodtuk+b26/PyHo7sBA9WAYx/sgqPKOlQowjXbFFoELWUErJTz9zYU8EjN0u1EnYJLZWs g9Bwvso6jFPEGUYhH9/qjtMhyndQX3M5dUMNgdxhk4OAUn5Mjr1cc8FbV08jh9cRWOQ9Pf9KuIJ U= X-Received: by 2002:a17:907:804:b0:94f:adb2:171f with SMTP id wv4-20020a170907080400b0094fadb2171fmr16631975ejb.28.1683798660575; Thu, 11 May 2023 02:51:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PpVUDt+cegdHpqeusmI/jpjhdU8GTr+6Xq++R7V7p9DmWeuutcKw9LMIv6NL4AQHxU/8fhw== X-Received: by 2002:a17:907:804:b0:94f:adb2:171f with SMTP id wv4-20020a170907080400b0094fadb2171fmr16631955ejb.28.1683798660124; Thu, 11 May 2023 02:51:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 16/24] build: move remaining compiler flag tests to meson Date: Thu, 11 May 2023 11:50:13 +0200 Message-Id: <20230511095021.1397802-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511095021.1397802-1-pbonzini@redhat.com> References: <20230511095021.1397802-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset=UTF-8 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1683798713884100011 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. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- configure | 79 ++++++++--------------------------------------------- meson.build | 49 ++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 69 deletions(-) diff --git a/configure b/configure index 10a9025beaf8..a7c3fcc26609 100755 --- a/configure +++ b/configure @@ -163,14 +163,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". @@ -376,19 +376,6 @@ windmc=3D"${WINDMC-${cross_prefix}windmc}" 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 @@ -1931,7 +1875,6 @@ echo "MESON=3D$meson" >> $config_host_mak echo "NINJA=3D$ninja" >> $config_host_mak echo "PKG_CONFIG=3D${pkg_config}" >> $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 00566ac26d3c..0c5d2cf634fa 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.40.1