@@ -7847,24 +7847,34 @@ AC_SUBST([LIBHACL_CFLAGS])
7847
7847
# The *mmintrin.h headers are x86-family-specific, so can't be used on WASI.
7848
7848
if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then
7849
7849
dnl This can be extended here to detect e.g. Power8, which HACL* should also support.
7850
- AX_CHECK_COMPILE_FLAG ( [ -msse -msse2 -msse3 -msse4.1 -msse4.2] ,[
7851
- [ LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"]
7852
-
7853
- AC_DEFINE ( [ HACL_CAN_COMPILE_SIMD128] , [ 1] , [ HACL* library can compile SIMD128 implementations] )
7854
-
7855
- # macOS universal2 builds *support* the -msse etc flags because they're
7856
- # available on x86_64. However, performance of the HACL SIMD128 implementation
7857
- # isn't great, so it's disabled on ARM64.
7858
- AC_MSG_CHECKING ( [ for HACL* SIMD128 implementation] )
7859
- if test "$UNIVERSAL_ARCHS" == "universal2"; then
7860
- [ LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"]
7861
- AC_MSG_RESULT ( [ universal2] )
7862
- else
7863
- [ LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"]
7864
- AC_MSG_RESULT ( [ standard] )
7865
- fi
7850
+ # Older versions of the mmintrin headers shipped with clang may error if they are
7851
+ # included without using the corresponding -msse* option. See GH issue #130213.
7852
+ AC_MSG_CHECKING ( [ if __m128i can be used without -msse*] )
7853
+ AC_COMPILE_IFELSE (
7854
+ [ AC_LANG_PROGRAM ( [ #include <emmintrin.h>
7855
+ #include <tmmintrin.h>
7856
+ #include <smmintrin.h>] ,
7857
+ [ __m128i testvar;] ) ] ,
7858
+ [ AC_MSG_RESULT ( [ yes] )
7859
+ AX_CHECK_COMPILE_FLAG ( [ -msse -msse2 -msse3 -msse4.1 -msse4.2] ,[
7860
+ [ LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"]
7861
+
7862
+ AC_DEFINE ( [ HACL_CAN_COMPILE_SIMD128] , [ 1] , [ HACL* library can compile SIMD128 implementations] )
7863
+
7864
+ # macOS universal2 builds *support* the -msse etc flags because they're
7865
+ # available on x86_64. However, performance of the HACL SIMD128 implementation
7866
+ # isn't great, so it's disabled on ARM64.
7867
+ AC_MSG_CHECKING ( [ for HACL* SIMD128 implementation] )
7868
+ if test "$UNIVERSAL_ARCHS" == "universal2"; then
7869
+ [ LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"]
7870
+ AC_MSG_RESULT ( [ universal2] )
7871
+ else
7872
+ [ LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"]
7873
+ AC_MSG_RESULT ( [ standard] )
7874
+ fi
7866
7875
7867
- ] , [ ] , [ -Werror] )
7876
+ ] , [ ] , [ -Werror] )
7877
+ ] , [ AC_MSG_RESULT ( [ no] ) ] )
7868
7878
fi
7869
7879
AC_SUBST ( [ LIBHACL_SIMD128_FLAGS] )
7870
7880
AC_SUBST ( [ LIBHACL_SIMD128_OBJS] )
@@ -7877,23 +7887,31 @@ AC_SUBST([LIBHACL_SIMD128_OBJS])
7877
7887
# (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a
7878
7888
# runtime CPUID check.
7879
7889
if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then
7880
- AX_CHECK_COMPILE_FLAG ( [ -mavx2] ,[
7881
- [ LIBHACL_SIMD256_FLAGS="-mavx2"]
7882
- AC_DEFINE ( [ HACL_CAN_COMPILE_SIMD256] , [ 1] , [ HACL* library can compile SIMD256 implementations] )
7883
-
7884
- # macOS universal2 builds *support* the -mavx2 compiler flag because it's
7885
- # available on x86_64; but the HACL SIMD256 build then fails because the
7886
- # implementation requires symbols that aren't available on ARM64. Use a
7887
- # wrapped implementation if we're building for universal2.
7888
- AC_MSG_CHECKING ( [ for HACL* SIMD256 implementation] )
7889
- if test "$UNIVERSAL_ARCHS" == "universal2"; then
7890
- [ LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"]
7891
- AC_MSG_RESULT ( [ universal2] )
7892
- else
7893
- [ LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"]
7894
- AC_MSG_RESULT ( [ standard] )
7895
- fi
7896
- ] , [ ] , [ -Werror] )
7890
+ # Some versions of immintrin.h may not provide the __m256i type if no -mavx*
7891
+ # option is used. See GH issue #130213.
7892
+ AC_MSG_CHECKING ( [ if __m256i can be used without -mavx2] )
7893
+ AC_COMPILE_IFELSE (
7894
+ [ AC_LANG_PROGRAM ( [ #include <immintrin.h>] ,
7895
+ [ __m256i testvar;] ) ] ,
7896
+ [ AC_MSG_RESULT ( [ yes] )
7897
+ AX_CHECK_COMPILE_FLAG ( [ -mavx2] ,[
7898
+ [ LIBHACL_SIMD256_FLAGS="-mavx2"]
7899
+ AC_DEFINE ( [ HACL_CAN_COMPILE_SIMD256] , [ 1] , [ HACL* library can compile SIMD256 implementations] )
7900
+
7901
+ # macOS universal2 builds *support* the -mavx2 compiler flag because it's
7902
+ # available on x86_64; but the HACL SIMD256 build then fails because the
7903
+ # implementation requires symbols that aren't available on ARM64. Use a
7904
+ # wrapped implementation if we're building for universal2.
7905
+ AC_MSG_CHECKING ( [ for HACL* SIMD256 implementation] )
7906
+ if test "$UNIVERSAL_ARCHS" == "universal2"; then
7907
+ [ LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"]
7908
+ AC_MSG_RESULT ( [ universal2] )
7909
+ else
7910
+ [ LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"]
7911
+ AC_MSG_RESULT ( [ standard] )
7912
+ fi
7913
+ ] , [ ] , [ -Werror] )
7914
+ ] , [ AC_MSG_RESULT ( [ no] ) ] )
7897
7915
fi
7898
7916
AC_SUBST ( [ LIBHACL_SIMD256_FLAGS] )
7899
7917
AC_SUBST ( [ LIBHACL_SIMD256_OBJS] )
0 commit comments