From ff0a7a38f75c529a2e1f88b7d21963dcb622124d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 26 May 2020 21:55:16 +0200 Subject: [PATCH] Check compiler options depending on host cpu Signed-off-by: Stefan Weil --- configure.ac | 72 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 4ba2cb67..05af6fc0 100644 --- a/configure.ac +++ b/configure.ac @@ -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)