From 3f6fc35cc28387e327cb6f47feb00061ed17b84c Mon Sep 17 00:00:00 2001 From: Mamoru TASAKA Date: Sat, 30 Apr 2022 13:32:34 +0900 Subject: [PATCH] configure.ac: reset compiler flags before calling AC_CHECK_DECLS With autoconf 2.71, [AC_CHECK_DECLS] calls new internal macro [_AC_UNDECLARED_BUILTIN], which raises error with unknown compiler flag. On non-x86 archs, -mavx or so is not recognized, so configure fails on such architecture. To fix this, reset vector related compiler flags before calling AC_CHECK_DECLS. --- configure.ac | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 863f3baca6..3e3ab12eb6 100644 --- a/configure.ac +++ b/configure.ac @@ -711,11 +711,19 @@ AC_CHECK_HEADERS([sys/types.h sys/un.h arpa/inet.h dirent.h grp.h fcntl.h inttyp save_cxxflags="${CXXFLAGS}" save_cppflags="${CPPFLAGS}" -CXXFLAGS="${CXXFLAGS} -msse3" -CPPFLAGS="${CPPFLAGS} -msse3" +sse3_flags="-msse3" +avx_flags="-mavx" +CXXFLAGS="${save_cxxflags} ${sse3_flags}" +CPPFLAGS="${save_cppflags} ${sse3_flags}" +AC_LINK_IFELSE([AC_LANG_PROGRAM([],)], [], [sse_flags=""]) +CXXFLAGS="${save_cxxflags} ${avx_flags}" +CPPFLAGS="${save_cppflags} ${avx_flags}" +AC_LINK_IFELSE([AC_LANG_PROGRAM([],)], [], [avx_flags=""]) +CXXFLAGS="${save_cxxflags} ${sse3_flags}" +CXXFLAGS="${save_cxxflags} ${sse3_flags}" AC_CHECK_HEADERS([intrin.h x86intrin.h pmmintrin.h xmmintrin.h emmintrin.h]) -CXXFLAGS="${save_cxxflags} -mavx" -CPPFLAGS="${save_cppflags} -mavx" +CXXFLAGS="${save_cxxflags} ${avx_flags}" +CPPFLAGS="${save_cppflags} ${avx_flags}" AC_CHECK_HEADERS([immintrin.h avxintrin.h]) AC_CHECK_DECLS([_xgetbv, xgetbv, __xgetbv, cpuid, _cpuid, __cpuid],