From d37760972fb9da55dfcff2a0740b5af5a30f39e1 Mon Sep 17 00:00:00 2001 From: magnum Date: Mon, 2 Dec 2024 01:45:39 +0100 Subject: [PATCH] Autoconf: Add -maes -mpclmul if supported by compiler This is for x86 AES-NI, intrinsics version. Closes #5593 --- src/configure | 54 +++++++++++++++++++++++++++++++++++++++++ src/m4/jtr_x86_logic.m4 | 7 ++++++ 2 files changed, 61 insertions(+) diff --git a/src/configure b/src/configure index 7eaa65bf551..fde3c7f57b7 100755 --- a/src/configure +++ b/src/configure @@ -11790,6 +11790,60 @@ if test $simd != yes; then fi fi +if test "x$simd" != xno; then + CFLAGS_EX="" + if test 1 -gt 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -maes -mpclmul" >&5 +$as_echo_n "checking if $CC supports -maes -mpclmul... " >&6; } +fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_saved_cflags="$CFLAGS" + CFLAGS="-Werror -maes -mpclmul" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if test "1" -gt 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi + CFLAGS_EX="$CFLAGS_EX -maes -mpclmul" + +else + if test 1 -gt 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test "1" = 2; then : + as_fn_error $? "Not supported by compiler" "$LINENO" 5 +fi + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$ac_saved_cflags" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + CPU_BEST_FLAGS="$CPU_BEST_FLAGS $CFLAGS_EX" +fi + CC="$CC_BACKUP" CFLAGS="$CFLAGS_BACKUP" diff --git a/src/m4/jtr_x86_logic.m4 b/src/m4/jtr_x86_logic.m4 index 49271586e49..9bfdf8bdaf7 100644 --- a/src/m4/jtr_x86_logic.m4 +++ b/src/m4/jtr_x86_logic.m4 @@ -491,6 +491,13 @@ if test $simd != yes; then fi fi +if test "x$simd" != xno; then + CFLAGS_EX="" + dnl Add -maes -mpclmul if supported + JTR_FLAG_CHECK([-maes -mpclmul], 1) + CPU_BEST_FLAGS="$CPU_BEST_FLAGS $CFLAGS_EX" +fi + CC="$CC_BACKUP" CFLAGS="$CFLAGS_BACKUP"