Check compiler options depending on host cpu

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2020-05-26 21:55:16 +02:00
parent a06d0d8449
commit ff0a7a38f7

View File

@ -124,35 +124,57 @@ AX_CHECK_COMPILE_FLAG([-Werror=unused-command-line-argument], [WERROR=-Werror=un
## Checks for supported compiler options.
AX_CHECK_COMPILE_FLAG([-mavx], [avx=true], [avx=false], [$WERROR])
AM_CONDITIONAL([HAVE_AVX], ${avx})
if $avx; then
AC_DEFINE([HAVE_AVX], [1], [Enable AVX instructions])
fi
AM_CONDITIONAL([HAVE_AVX], false)
AM_CONDITIONAL([HAVE_AVX2], false)
AM_CONDITIONAL([HAVE_FMA], false)
AM_CONDITIONAL([HAVE_SSE4_1], false)
AM_CONDITIONAL([HAVE_NEON], false)
AX_CHECK_COMPILE_FLAG([-mavx2], [avx2=true], [avx2=false], [$WERROR])
AM_CONDITIONAL([HAVE_AVX2], $avx2)
if $avx2; then
AC_DEFINE([HAVE_AVX2], [1], [Enable AVX2 instructions])
fi
case "${host_cpu}" in
AX_CHECK_COMPILE_FLAG([-mfma], [fma=true], [fma=false], [$WERROR])
AM_CONDITIONAL([HAVE_FMA], $fma)
if $fma; then
AC_DEFINE([HAVE_FMA], [1], [Enable FMA instructions])
fi
*86*)
AX_CHECK_COMPILE_FLAG([-msse4.1], [sse41=true], [sse41=false], [$WERROR])
AM_CONDITIONAL([HAVE_SSE4_1], $sse41)
if $sse41; then
AC_DEFINE([HAVE_SSE4_1], [1], [Enable SSE 4.1 instructions])
fi
AX_CHECK_COMPILE_FLAG([-mavx], [avx=true], [avx=false], [$WERROR])
AM_CONDITIONAL([HAVE_AVX], ${avx})
if $avx; then
AC_DEFINE([HAVE_AVX], [1], [Enable AVX instructions])
fi
AX_CHECK_COMPILE_FLAG([-mfpu=neon], [neon=true], [neon=false], [$WERROR])
AM_CONDITIONAL([HAVE_NEON], $neon)
if $neon; then
AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
fi
AX_CHECK_COMPILE_FLAG([-mavx2], [avx2=true], [avx2=false], [$WERROR])
AM_CONDITIONAL([HAVE_AVX2], $avx2)
if $avx2; then
AC_DEFINE([HAVE_AVX2], [1], [Enable AVX2 instructions])
fi
AX_CHECK_COMPILE_FLAG([-mfma], [fma=true], [fma=false], [$WERROR])
AM_CONDITIONAL([HAVE_FMA], $fma)
if $fma; then
AC_DEFINE([HAVE_FMA], [1], [Enable FMA instructions])
fi
AX_CHECK_COMPILE_FLAG([-msse4.1], [sse41=true], [sse41=false], [$WERROR])
AM_CONDITIONAL([HAVE_SSE4_1], $sse41)
if $sse41; then
AC_DEFINE([HAVE_SSE4_1], [1], [Enable SSE 4.1 instructions])
fi
;;
arm*)
AX_CHECK_COMPILE_FLAG([-mfpu=neon], [neon=true], [neon=false], [$WERROR])
AM_CONDITIONAL([HAVE_NEON], $neon)
if $neon; then
AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
fi
;;
*)
AC_MSG_WARN([No compiler options for $host_cpu])
esac
AX_CHECK_COMPILE_FLAG([-march=native], [arch_native=true], [arch_native=false], [$WERROR])
AM_CONDITIONAL([MARCH_NATIVE_OPT], $arch_native)