Skip to content

Commit

Permalink
Autoconf: Add -maes -mpclmul if supported by compiler
Browse files Browse the repository at this point in the history
This is for x86 AES-NI, intrinsics version.

Closes #5593
  • Loading branch information
magnumripper committed Dec 3, 2024
1 parent f88688e commit d377609
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 7 additions & 0 deletions src/m4/jtr_x86_logic.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d377609

Please sign in to comment.