[libvirt] [PATCH 2/4] Require use of GCC 4.4 or CLang compilers
Daniel P. Berrange
berrange at redhat.com
Wed Jul 5 11:25:18 UTC 2017
On Wed, Jul 05, 2017 at 11:34:10AM +0100, Daniel P. Berrange wrote:
> We only ever test libvirt with GCC or CLang which provides a
> GCC compatible compilation environment. Between them, these
> compilers cover every important operating system platform,
> even Windows.
>
> Mandate their use to make it explicit that we don't care about
> compilers like Microsoft VCC or other UNIX vendor C compilers.
>
> GCC 4.4 was picked as the baseline, since RHEL-6 ships 4.4.7
> and that lets us remove a large set of checks. There is a slight
> issue that CLang reports itself as GCC 4.2, so we must also check
> if __clang__ is defined. We could check a particular CLang version
> too, but that would require someone to figure out a suitable min
> version which is fun because OS-X reports totally different CLang
> version numbers from CLang builds on Linux/BSD
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> config-post.h | 20 +++++-----
> src/internal.h | 116 ++++++++++++++++-----------------------------------------
> 2 files changed, 44 insertions(+), 92 deletions(-)
>
> diff --git a/config-post.h b/config-post.h
> index 75e7d02..4bddbac 100644
> --- a/config-post.h
> +++ b/config-post.h
> @@ -74,6 +74,10 @@
> # undef WITH_CAPNG
> #endif /* LIBVIRT_NSS */
>
> +#ifndef __GNUC__
> +# error "Libvirt requires GCC >= 4.4, or CLang"
> +#endif
> +
> /*
> * Define __GNUC_PREREQ to a sane default if it isn't yet defined.
> * This is done here so that it's included as early as possible; gnulib relies
> @@ -81,13 +85,11 @@
> * This doesn't happen on many non-glibc systems.
> * When __GNUC_PREREQ is not defined, gnulib defines it to 0, which breaks things.
> */
> -#ifdef __GNUC__
> -# ifndef __GNUC_PREREQ
> -# if defined __GNUC__ && defined __GNUC_MINOR__
> -# define __GNUC_PREREQ(maj, min) \
> - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
> -# else
> -# define __GNUC_PREREQ(maj, min) 0
> -# endif
> -# endif
> +#ifndef __GNUC_PREREQ
> +# define __GNUC_PREREQ(maj, min) \
> + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
> +#endif
> +
> +#if !__GNUC_PREREQ(4, 4) || defined(__clang__)
Opps, messed up precedence there - it should have been
#if !(__GNUC_PREREQ(4, 4) || defined(__clang__))
> +# error "Libvirt requires GCC >= 4.4, or CLang"
> #endif
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list