gh-99108: Disable HACL SIMD code on older versions of Android (#124304)

Disable HACL SIMD code on older versions of Android
This commit is contained in:
Malcolm Smith 2024-09-23 21:28:03 +01:00 committed by GitHub
parent 7ee9921734
commit 41e7992e31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 83 additions and 63 deletions

18
configure generated vendored
View file

@ -30654,7 +30654,10 @@ case "$ac_sys_system" in
esac esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2" >&5 # The SIMD files use aligned_alloc, which is not available on older versions of
# Android.
if test "$ac_sys_system" != "Linux-android" || test "$ANDROID_API_LEVEL" -ge 28; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2" >&5
printf %s "checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2... " >&6; } printf %s "checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2... " >&6; }
if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y} if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y}
then : then :
@ -30714,11 +30717,18 @@ else $as_nop
: :
fi fi
fi
# The SIMD files use aligned_alloc, which is not available on older versions of
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 # Android.
#
# Although AVX support is not guaranteed on Android
# (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a
# runtime CPUID check.
if test "$ac_sys_system" != "Linux-android" || test "$ANDROID_API_LEVEL" -ge 28; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5
printf %s "checking whether C compiler accepts -mavx2... " >&6; } printf %s "checking whether C compiler accepts -mavx2... " >&6; }
if test ${ax_cv_check_cflags__Werror__mavx2+y} if test ${ax_cv_check_cflags__Werror__mavx2+y}
then : then :
@ -30777,7 +30787,7 @@ else $as_nop
: :
fi fi
fi

View file

@ -7817,8 +7817,11 @@ case "$ac_sys_system" in
esac esac
AC_SUBST([LIBHACL_CFLAGS]) AC_SUBST([LIBHACL_CFLAGS])
dnl This can be extended here to detect e.g. Power8, which HACL* should also support. # The SIMD files use aligned_alloc, which is not available on older versions of
AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[ # Android.
if test "$ac_sys_system" != "Linux-android" || test "$ANDROID_API_LEVEL" -ge 28; then
dnl This can be extended here to detect e.g. Power8, which HACL* should also support.
AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[
[LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"] [LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"]
AC_DEFINE([HACL_CAN_COMPILE_SIMD128], [1], [HACL* library can compile SIMD128 implementations]) AC_DEFINE([HACL_CAN_COMPILE_SIMD128], [1], [HACL* library can compile SIMD128 implementations])
@ -7835,12 +7838,19 @@ AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[
AC_MSG_RESULT([standard]) AC_MSG_RESULT([standard])
fi fi
], [], [-Werror]) ], [], [-Werror])
fi
AC_SUBST([LIBHACL_SIMD128_FLAGS]) AC_SUBST([LIBHACL_SIMD128_FLAGS])
AC_SUBST([LIBHACL_SIMD128_OBJS]) AC_SUBST([LIBHACL_SIMD128_OBJS])
AX_CHECK_COMPILE_FLAG([-mavx2],[ # The SIMD files use aligned_alloc, which is not available on older versions of
# Android.
#
# Although AVX support is not guaranteed on Android
# (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a
# runtime CPUID check.
if test "$ac_sys_system" != "Linux-android" || test "$ANDROID_API_LEVEL" -ge 28; then
AX_CHECK_COMPILE_FLAG([-mavx2],[
[LIBHACL_SIMD256_FLAGS="-mavx2"] [LIBHACL_SIMD256_FLAGS="-mavx2"]
AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations])
@ -7856,8 +7866,8 @@ AX_CHECK_COMPILE_FLAG([-mavx2],[
[LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"]
AC_MSG_RESULT([standard]) AC_MSG_RESULT([standard])
fi fi
], [], [-Werror]) ], [], [-Werror])
fi
AC_SUBST([LIBHACL_SIMD256_FLAGS]) AC_SUBST([LIBHACL_SIMD256_FLAGS])
AC_SUBST([LIBHACL_SIMD256_OBJS]) AC_SUBST([LIBHACL_SIMD256_OBJS])