qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 27/30] build: move compiler version check to meson


From: Paolo Bonzini
Subject: [PATCH 27/30] build: move compiler version check to meson
Date: Fri, 9 Dec 2022 12:24:06 +0100

Instead of checking with preprocessor defines, use the Meson compiler object.
Because of the mess Apple does with its versioning scheme, check for an
option that was added in clang 6.0 instead of looking at the version number.

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

diff --git a/configure b/configure
index d5491fc3b986..a7c95535fd01 100755
--- a/configure
+++ b/configure
@@ -1033,31 +1033,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__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
-#   error You need at least XCode Clang v10.0 to compile QEMU
-#  endif
-# else
-#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
-#   error You need at least Clang v6.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 v6.0 (or XCode Clang 
v10.0)"
-fi
-
 # Resolve default for --enable-plugins
 if test "$static" = "yes" ; then
   if test "$plugins" = "yes"; then
diff --git a/meson.build b/meson.build
index 01c6ac0045bc..3316ff005cfc 100644
--- a/meson.build
+++ b/meson.build
@@ -190,6 +190,17 @@ 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.has_argument('-Wpragma-pack')
+    # ok
+  else
+    error('You either need GCC v7.4 or Clang v6.0 (or XCode Clang v10.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.38.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]