From 53c8ab748bafc42f7f63eeb5c3440faf6b1b8b4f Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Thu, 20 Feb 2025 14:13:45 +1100 Subject: [PATCH 1/4] Check availability of Intel SIMD types blake2module.c includes headers that use SIMD typedefs if an SIMD implementation will be built, but must not itself be compiled with the -m options that enable SIMD instructions. However, the *mmintrin headers are not always usable to get those typedefs if the corresponding -m option is not used. --- configure | 108 ++++++++++++++++++++++++++++++++++++++------------- configure.ac | 86 ++++++++++++++++++++++++---------------- 2 files changed, 133 insertions(+), 61 deletions(-) diff --git a/configure b/configure index 453b0123ded0a4..7d387935e8fd6e 100755 --- a/configure +++ b/configure @@ -32076,7 +32076,28 @@ esac # Android. # The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || 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 + # Older versions of the mmintrin headers shipped with clang may error if they are + # included without using the corresponding -msse* option. See GH issue #130213. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m128i can be used without -msse*" >&5 +printf %s "checking if __m128i can be used without -msse*... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include +int +main (void) +{ +__m128i testvar; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + { 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; } if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y} then : @@ -32112,26 +32133,26 @@ printf "%s\n" "$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2 if test "x$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" = xyes then : - LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" + LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" printf "%s\n" "#define HACL_CAN_COMPILE_SIMD128 1" >>confdefs.h - # macOS universal2 builds *support* the -msse etc flags because they're - # available on x86_64. However, performance of the HACL SIMD128 implementation - # isn't great, so it's disabled on ARM64. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD128 implementation" >&5 + # macOS universal2 builds *support* the -msse etc flags because they're + # available on x86_64. However, performance of the HACL SIMD128 implementation + # isn't great, so it's disabled on ARM64. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD128 implementation" >&5 printf %s "checking for HACL* SIMD128 implementation... " >&6; } - if test "$UNIVERSAL_ARCHS" == "universal2"; then - LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 + if test "$UNIVERSAL_ARCHS" == "universal2"; then + LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 printf "%s\n" "universal2" >&6; } - else - LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 + else + LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 printf "%s\n" "standard" >&6; } - fi + fi else case e in #( @@ -32139,6 +32160,13 @@ else case e in #( esac fi + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi @@ -32151,7 +32179,26 @@ fi # (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" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 + # Some versions of immintrin.h may not provide the __m256i type if no -mavx* + # option is used. See GH issue #130213. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m256i can be used without -mavx2" >&5 +printf %s "checking if __m256i can be used without -mavx2... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +__m256i testvar; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 printf %s "checking whether C compiler accepts -mavx2... " >&6; } if test ${ax_cv_check_cflags__Werror__mavx2+y} then : @@ -32187,32 +32234,39 @@ printf "%s\n" "$ax_cv_check_cflags__Werror__mavx2" >&6; } if test "x$ax_cv_check_cflags__Werror__mavx2" = xyes then : - LIBHACL_SIMD256_FLAGS="-mavx2" + LIBHACL_SIMD256_FLAGS="-mavx2" printf "%s\n" "#define HACL_CAN_COMPILE_SIMD256 1" >>confdefs.h - # macOS universal2 builds *support* the -mavx2 compiler flag because it's - # available on x86_64; but the HACL SIMD256 build then fails because the - # implementation requires symbols that aren't available on ARM64. Use a - # wrapped implementation if we're building for universal2. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD256 implementation" >&5 + # macOS universal2 builds *support* the -mavx2 compiler flag because it's + # available on x86_64; but the HACL SIMD256 build then fails because the + # implementation requires symbols that aren't available on ARM64. Use a + # wrapped implementation if we're building for universal2. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD256 implementation" >&5 printf %s "checking for HACL* SIMD256 implementation... " >&6; } - if test "$UNIVERSAL_ARCHS" == "universal2"; then - LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 + if test "$UNIVERSAL_ARCHS" == "universal2"; then + LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 printf "%s\n" "universal2" >&6; } - else - LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 + else + LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 printf "%s\n" "standard" >&6; } - fi + fi else case e in #( e) : ;; esac fi + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi diff --git a/configure.ac b/configure.ac index 234ae90616af62..6bfa1470bcc9c9 100644 --- a/configure.ac +++ b/configure.ac @@ -7847,24 +7847,34 @@ AC_SUBST([LIBHACL_CFLAGS]) # The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || 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"] - - AC_DEFINE([HACL_CAN_COMPILE_SIMD128], [1], [HACL* library can compile SIMD128 implementations]) - - # macOS universal2 builds *support* the -msse etc flags because they're - # available on x86_64. However, performance of the HACL SIMD128 implementation - # isn't great, so it's disabled on ARM64. - AC_MSG_CHECKING([for HACL* SIMD128 implementation]) - if test "$UNIVERSAL_ARCHS" == "universal2"; then - [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"] - AC_MSG_RESULT([universal2]) - else - [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"] - AC_MSG_RESULT([standard]) - fi + # Older versions of the mmintrin headers shipped with clang may error if they are + # included without using the corresponding -msse* option. See GH issue #130213. + AC_MSG_CHECKING([if __m128i can be used without -msse*]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include + #include + #include ], + [__m128i testvar;])], + [AC_MSG_RESULT([yes]) + AX_CHECK_COMPILE_FLAG([-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]) + + # macOS universal2 builds *support* the -msse etc flags because they're + # available on x86_64. However, performance of the HACL SIMD128 implementation + # isn't great, so it's disabled on ARM64. + AC_MSG_CHECKING([for HACL* SIMD128 implementation]) + if test "$UNIVERSAL_ARCHS" == "universal2"; then + [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"] + AC_MSG_RESULT([universal2]) + else + [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"] + AC_MSG_RESULT([standard]) + fi - ], [], [-Werror]) + ], [], [-Werror]) + ], [AC_MSG_RESULT([no])]) fi AC_SUBST([LIBHACL_SIMD128_FLAGS]) AC_SUBST([LIBHACL_SIMD128_OBJS]) @@ -7877,23 +7887,31 @@ AC_SUBST([LIBHACL_SIMD128_OBJS]) # (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" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - AX_CHECK_COMPILE_FLAG([-mavx2],[ - [LIBHACL_SIMD256_FLAGS="-mavx2"] - AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) - - # macOS universal2 builds *support* the -mavx2 compiler flag because it's - # available on x86_64; but the HACL SIMD256 build then fails because the - # implementation requires symbols that aren't available on ARM64. Use a - # wrapped implementation if we're building for universal2. - AC_MSG_CHECKING([for HACL* SIMD256 implementation]) - if test "$UNIVERSAL_ARCHS" == "universal2"; then - [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"] - AC_MSG_RESULT([universal2]) - else - [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] - AC_MSG_RESULT([standard]) - fi - ], [], [-Werror]) + # Some versions of immintrin.h may not provide the __m256i type if no -mavx* + # option is used. See GH issue #130213. + AC_MSG_CHECKING([if __m256i can be used without -mavx2]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include ], + [__m256i testvar;])], + [AC_MSG_RESULT([yes]) + AX_CHECK_COMPILE_FLAG([-mavx2],[ + [LIBHACL_SIMD256_FLAGS="-mavx2"] + AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) + + # macOS universal2 builds *support* the -mavx2 compiler flag because it's + # available on x86_64; but the HACL SIMD256 build then fails because the + # implementation requires symbols that aren't available on ARM64. Use a + # wrapped implementation if we're building for universal2. + AC_MSG_CHECKING([for HACL* SIMD256 implementation]) + if test "$UNIVERSAL_ARCHS" == "universal2"; then + [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"] + AC_MSG_RESULT([universal2]) + else + [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] + AC_MSG_RESULT([standard]) + fi + ], [], [-Werror]) + ], [AC_MSG_RESULT([no])]) fi AC_SUBST([LIBHACL_SIMD256_FLAGS]) AC_SUBST([LIBHACL_SIMD256_OBJS]) From 2897e64420d8e2e968bdc808c7214e175f89ba19 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 20 Feb 2025 03:38:52 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2025-02-20-03-38-46.gh-issue-130213.MO0ZQD.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2025-02-20-03-38-46.gh-issue-130213.MO0ZQD.rst diff --git a/Misc/NEWS.d/next/Build/2025-02-20-03-38-46.gh-issue-130213.MO0ZQD.rst b/Misc/NEWS.d/next/Build/2025-02-20-03-38-46.gh-issue-130213.MO0ZQD.rst new file mode 100644 index 00000000000000..7de83eee63d50f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-02-20-03-38-46.gh-issue-130213.MO0ZQD.rst @@ -0,0 +1 @@ +Disabled use of Intel SIMD instructions for libhacl when it would cause the build to fail, such as with some older clang versions. From 9f6d5a452baf0b20cb1a7097f5fce4d5c43431c3 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Sun, 23 Feb 2025 12:45:42 +1100 Subject: [PATCH 3/4] Address review comments Check for SIMD -m flags before checking for header issues. Clarify comment. --- configure | 105 ++++++++++++++++++++++++++------------------------- configure.ac | 47 ++++++++++++----------- 2 files changed, 77 insertions(+), 75 deletions(-) diff --git a/configure b/configure index 7d387935e8fd6e..520b09c665401d 100755 --- a/configure +++ b/configure @@ -32078,26 +32078,7 @@ esac if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then # Older versions of the mmintrin headers shipped with clang may error if they are # included without using the corresponding -msse* option. See GH issue #130213. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m128i can be used without -msse*" >&5 -printf %s "checking if __m128i can be used without -msse*... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - #include -int -main (void) -{ -__m128i testvar; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2" >&5 + { 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; } if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y} then : @@ -32133,7 +32114,26 @@ printf "%s\n" "$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2 if test "x$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" = xyes then : - LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" + LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m128i can be used without -msse*" >&5 +printf %s "checking if __m128i can be used without -msse*... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include +int +main (void) +{ +__m128i testvar; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } printf "%s\n" "#define HACL_CAN_COMPILE_SIMD128 1" >>confdefs.h @@ -32156,17 +32156,17 @@ printf "%s\n" "standard" >&6; } else case e in #( - e) : ;; + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; esac fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; + e) : ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + fi @@ -32179,26 +32179,10 @@ fi # (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" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - # Some versions of immintrin.h may not provide the __m256i type if no -mavx* - # option is used. See GH issue #130213. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m256i can be used without -mavx2" >&5 -printf %s "checking if __m256i can be used without -mavx2... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -__m256i testvar; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 + # Some versions of immintrin.h require -mavx* to provide the __m256i type + # but blake2module.c must not be compiled with -mavx2 and may include + # libintvector.h which contains __m256i. See GH issue #130213. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 printf %s "checking whether C compiler accepts -mavx2... " >&6; } if test ${ax_cv_check_cflags__Werror__mavx2+y} then : @@ -32234,7 +32218,24 @@ printf "%s\n" "$ax_cv_check_cflags__Werror__mavx2" >&6; } if test "x$ax_cv_check_cflags__Werror__mavx2" = xyes then : - LIBHACL_SIMD256_FLAGS="-mavx2" + LIBHACL_SIMD256_FLAGS="-mavx2" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __m256i can be used without -mavx2" >&5 +printf %s "checking if __m256i can be used without -mavx2... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +__m256i testvar; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } printf "%s\n" "#define HACL_CAN_COMPILE_SIMD256 1" >>confdefs.h @@ -32256,17 +32257,17 @@ printf "%s\n" "standard" >&6; } fi else case e in #( - e) : ;; + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; esac fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; + e) : ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + fi diff --git a/configure.ac b/configure.ac index 6bfa1470bcc9c9..b73b910b825586 100644 --- a/configure.ac +++ b/configure.ac @@ -7849,15 +7849,15 @@ if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || tes dnl This can be extended here to detect e.g. Power8, which HACL* should also support. # Older versions of the mmintrin headers shipped with clang may error if they are # included without using the corresponding -msse* option. See GH issue #130213. - AC_MSG_CHECKING([if __m128i can be used without -msse*]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([#include - #include - #include ], - [__m128i testvar;])], - [AC_MSG_RESULT([yes]) - AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[ - [LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"] + AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[ + [LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"] + AC_MSG_CHECKING([if __m128i can be used without -msse*]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include + #include + #include ], + [__m128i testvar;])], + [AC_MSG_RESULT([yes]) AC_DEFINE([HACL_CAN_COMPILE_SIMD128], [1], [HACL* library can compile SIMD128 implementations]) @@ -7873,8 +7873,8 @@ if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || tes AC_MSG_RESULT([standard]) fi - ], [], [-Werror]) - ], [AC_MSG_RESULT([no])]) + ], [AC_MSG_RESULT([no])]) + ], [], [-Werror]) fi AC_SUBST([LIBHACL_SIMD128_FLAGS]) AC_SUBST([LIBHACL_SIMD128_OBJS]) @@ -7887,16 +7887,17 @@ AC_SUBST([LIBHACL_SIMD128_OBJS]) # (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" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - # Some versions of immintrin.h may not provide the __m256i type if no -mavx* - # option is used. See GH issue #130213. - AC_MSG_CHECKING([if __m256i can be used without -mavx2]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([#include ], - [__m256i testvar;])], - [AC_MSG_RESULT([yes]) - AX_CHECK_COMPILE_FLAG([-mavx2],[ - [LIBHACL_SIMD256_FLAGS="-mavx2"] - AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) + # Some versions of immintrin.h require -mavx* to provide the __m256i type + # but blake2module.c must not be compiled with those options and may + # include libintvector.h which contains __m256i. See GH issue #130213. + AX_CHECK_COMPILE_FLAG([-mavx2],[ + [LIBHACL_SIMD256_FLAGS="-mavx2"] + AC_MSG_CHECKING([if __m256i can be used without -mavx2]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include ], + [__m256i testvar;])], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) # macOS universal2 builds *support* the -mavx2 compiler flag because it's # available on x86_64; but the HACL SIMD256 build then fails because the @@ -7910,8 +7911,8 @@ if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || tes [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] AC_MSG_RESULT([standard]) fi - ], [], [-Werror]) - ], [AC_MSG_RESULT([no])]) + ], [AC_MSG_RESULT([no])]) + ], [], [-Werror]) fi AC_SUBST([LIBHACL_SIMD256_FLAGS]) AC_SUBST([LIBHACL_SIMD256_OBJS]) From 697787f13e4d03e4aa4b6bac19f9852d2f141318 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Tue, 25 Feb 2025 03:42:15 -0500 Subject: [PATCH 4/4] Fix comments changed in configure.ac but not in configure --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 520b09c665401d..5ba42da9571d1a 100755 --- a/configure +++ b/configure @@ -32180,8 +32180,8 @@ fi # runtime CPUID check. if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then # Some versions of immintrin.h require -mavx* to provide the __m256i type - # but blake2module.c must not be compiled with -mavx2 and may include - # libintvector.h which contains __m256i. See GH issue #130213. + # but blake2module.c must not be compiled with those options and may + # include libintvector.h which contains __m256i. See GH issue #130213. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 printf %s "checking whether C compiler accepts -mavx2... " >&6; } if test ${ax_cv_check_cflags__Werror__mavx2+y}