qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 17/24] build: move compiler version check to meson
Date: Thu, 11 May 2023 11:50:14 +0200	[thread overview]
Message-ID: <20230511095021.1397802-18-pbonzini@redhat.com> (raw)
In-Reply-To: <20230511095021.1397802-1-pbonzini@redhat.com>

Use the slighly nicer .version_compare() function for GCC; for Clang that is
not possible due to the mess that Apple does with version numbers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure   | 25 -------------------------
 meson.build | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index a7c3fcc26609..b58ea2aba1f3 100755
--- a/configure
+++ b/configure
@@ -1128,31 +1128,6 @@ if test "$targetos" = "bogus"; then
     error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
 fi
 
-# Check whether the compiler matches our minimum requirements:
-cat > $TMPC << EOF
-#if defined(__clang_major__) && defined(__clang_minor__)
-# ifdef __apple_build_version__
-#  if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
-#   error You need at least XCode Clang v12.0 to compile QEMU
-#  endif
-# else
-#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
-#   error You need at least Clang v10.0 to compile QEMU
-#  endif
-# endif
-#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
-# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
-#  error You need at least GCC v7.4.0 to compile QEMU
-# endif
-#else
-# error You either need GCC or Clang to compiler QEMU
-#endif
-int main (void) { return 0; }
-EOF
-if ! compile_prog "" "" ; then
-    error_exit "You need at least GCC v7.4 or Clang v10.0 (or XCode Clang v12.0)"
-fi
-
 if test "$static" = "yes" ; then
   if test "$plugins" = "yes"; then
     error_exit "static and plugins are mutually incompatible"
diff --git a/meson.build b/meson.build
index 0c5d2cf634fa..a751d86bc3ea 100644
--- a/meson.build
+++ b/meson.build
@@ -190,6 +190,26 @@ endif
 # Compiler flags #
 ##################
 
+foreach lang : all_languages
+  compiler = meson.get_compiler(lang)
+  if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4')
+    # ok
+  elif compiler.get_id() == 'clang' and compiler.compiles('''
+      #ifdef __apple_build_version__
+      # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
+      #  error You need at least XCode Clang v12.0 to compile QEMU
+      # endif
+      #else
+      # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
+      #  error You need at least Clang v10.0 to compile QEMU
+      # endif
+      #endif''')
+    # ok
+  else
+    error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU')
+  endif
+endforeach
+
 # 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
-- 
2.40.1



  parent reply	other threads:[~2023-05-11  9:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11  9:49 [PATCH 00/24] Meson changes for QEMU 8.1 Paolo Bonzini
2023-05-11  9:49 ` [PATCH 01/24] meson: regenerate meson-buildoptions.sh Paolo Bonzini
2023-05-11  9:49 ` [PATCH 02/24] meson: require 0.63.0 Paolo Bonzini
2023-05-11  9:50 ` [PATCH 03/24] meson: use prefer_static option Paolo Bonzini
2023-05-11  9:50 ` [PATCH 04/24] meson: remove static_kwargs Paolo Bonzini
2023-05-11  9:50 ` [PATCH 05/24] meson: add more version numbers to the summary Paolo Bonzini
2023-05-11  9:50 ` [PATCH 06/24] meson: drop unnecessary declare_dependency() Paolo Bonzini
2023-05-11  9:50 ` [PATCH 07/24] build: move glib detection and workarounds to meson Paolo Bonzini
2023-05-11  9:50 ` [PATCH 08/24] configure: remove pkg-config functions Paolo Bonzini
2023-05-11  9:50 ` [PATCH 09/24] configure, meson: move --enable-modules to Meson Paolo Bonzini
2023-05-11  9:50 ` [PATCH 10/24] meson: prepare move of QEMU_CFLAGS to meson Paolo Bonzini
2023-05-11  9:50 ` [PATCH 11/24] build: move sanitizer tests " Paolo Bonzini
2023-05-11  9:50 ` [PATCH 12/24] build: move SafeStack " Paolo Bonzini
2023-05-11  9:50 ` [PATCH 13/24] build: move coroutine backend selection " Paolo Bonzini
2023-05-11  9:50 ` [PATCH 14/24] build: move stack protector flag " Paolo Bonzini
2023-05-11  9:50 ` [PATCH 15/24] build: move warning " Paolo Bonzini
2023-05-11  9:50 ` [PATCH 16/24] build: move remaining compiler flag tests " Paolo Bonzini
2023-05-11  9:50 ` Paolo Bonzini [this message]
2023-05-11  9:50 ` [PATCH 18/24] build: move --disable-debug-info " Paolo Bonzini
2023-07-26  6:45   ` Michael Tokarev
2023-05-11  9:50 ` [PATCH 19/24] configure: remove compiler sanity check Paolo Bonzini
2024-01-18 19:23   ` Thomas Huth
2023-05-11  9:50 ` [PATCH 20/24] configure: do not rerun the tests with -Werror Paolo Bonzini
2023-05-11  9:50 ` [PATCH 21/24] configure: remove unnecessary mkdir Paolo Bonzini
2023-05-11  9:50 ` [PATCH 22/24] configure: reorder option parsing code Paolo Bonzini
2023-05-11  9:50 ` [PATCH 23/24] configure: remove unnecessary check Paolo Bonzini
2023-05-11  9:50 ` [PATCH 24/24] docs/devel: update build system docs Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230511095021.1397802-18-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).