]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Allow cross-compilation with SIMD (x86_84) (#104)
authoredo <edo.rus@gmail.com>
Wed, 7 Oct 2020 05:33:57 +0000 (08:33 +0300)
committerGitHub <noreply@github.com>
Wed, 7 Oct 2020 05:33:57 +0000 (22:33 -0700)
Replace runtime SIMD check with a compile-only test in case of
cross-compilation.

You can still use '--enable-simd=no' to build x86_64 code without
SIMD instructions.

configure.ac

index 3fd7e5d589491aae486c140ae3b88755721050fe..e469981b055e3b6b7387ea2b59801b863329af54 100644 (file)
@@ -208,12 +208,7 @@ AC_ARG_ENABLE(simd,
 
 # Clag is crashing with -g -O2, so we'll get rid of -g for now.
 CXXFLAGS=`echo "$CXXFLAGS" | sed 's/-g //'`
-
-if test x"$enable_simd" != x"no"; then
-    # For x86-64 SIMD, g++ >=5 or clang++ >=7 is required
-    if test x"$host_cpu" = x"x86_64"; then
-       AC_LANG(C++)
-       AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
+m4_define(SIMD_X86_64_TEST, [[#include <stdio.h>
 #include <immintrin.h>
 __attribute__ ((target("default"))) int test_ssse3(int x) { return x; }
 __attribute__ ((target("default"))) int test_sse2(int x) { return x; }
@@ -233,7 +228,18 @@ __attribute__ ((target("ssse3"))) void more_testing(char* buf, int len)
        in8_2 = _mm_lddqu_si128((__m128i_u*)&buf[i + 16]);
     }
 }
-]], [[if (test_ssse3(42) != 42 || test_sse2(42) != 42 || test_avx2(42) != 42) exit(1);]])],[CXX_OK=yes],[CXX_OK=no],[CXX_OK=no])
+]])
+
+if test x"$enable_simd" != x"no"; then
+    # For x86-64 SIMD, g++ >=5 or clang++ >=7 is required
+    if test x"$host_cpu" = x"x86_64"; then
+       AC_LANG(C++)
+       if test x"$host_cpu" = x"$build_cpu"; then
+           AC_RUN_IFELSE([AC_LANG_PROGRAM([SIMD_X86_64_TEST],[[if (test_ssse3(42) != 42 || test_sse2(42) != 42 || test_avx2(42) != 42) exit(1);]])],
+               [CXX_OK=yes],[CXX_OK=no])
+       else
+           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([SIMD_X86_64_TEST])],[CXX_OK=yes],[CXX_OK=no])
+       fi
        AC_LANG(C)
        if test x"$CXX_OK" = x"yes"; then
            # AC_MSG_RESULT() is called below.