From c2f7718b63018038e3cbd366d472c241958ef72d Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Fri, 18 Oct 2019 22:29:35 +0200 Subject: [PATCH] Only set the AVX512 flags with GCC when compiling with a version that supports the flag. --- configure.ac | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 47baa529d2..7ccf1d023c 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,13 @@ AC_USE_SYSTEM_EXTENSIONS AX_COMPILER_VENDOR AX_COMPILER_VERSION +# Check whether we have a recent enough GCC +if test "$ax_cv_c_compiler_vendor" = "gnu"; then + AX_COMPARE_VERSION([$ax_cv_c_compiler_version], [ge], [8.1.0], + [gcc_handles_avx512="yes"], + [gcc_handles_avx512="no"]) +fi + # Restrict support. AC_C_RESTRICT @@ -462,14 +469,18 @@ if test "$enable_opt" = "yes" ; then ;; esac elif test "$ax_cv_c_compiler_vendor" = "gnu"; then - case "$ax_gcc_arch" in - *skylake-avx512*) - GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512" - ;; - *) - AC_MSG_WARN([No additional flags needed for gravity on this platform]) - ;; - esac + if test "$gcc_handles_avx512" = "yes"; then + case "$ax_gcc_arch" in + *skylake-avx512*) + [GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512"], + ;; + *) + AC_MSG_WARN([No additional flags needed for gravity on this platform]) + ;; + esac + else + AC_MSG_WARN([No additional flags needed for gravity on this platform]) + fi else AC_MSG_WARN([Do not know what best gravity vectorization flags to choose for this compiler]) fi -- GitLab