qemu-devel
[Top][All Lists]
Advanced

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

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


From: Peter Maydell
Subject: Re: [PATCH 27/30] build: move compiler version check to meson
Date: Fri, 9 Dec 2022 11:52:36 +0000

On Fri, 9 Dec 2022 at 11:40, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> 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.

> -# 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
>
> +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

The new code makes it much harder to move our compiler version
requirements forward in future, because there's no longer a simple
"check for normal clang X or apple clang Y" test where we can
bump up X and Y based on what's provided in the various host
platforms we have to support. Doesn't meson provide a way to do
the version check on the version number the way we were doing
previously?

thanks
-- PMM



reply via email to

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