Skip to content

Commit

Permalink
AES-NI build bug fix
Browse files Browse the repository at this point in the history
Fix a check for compiler version that was alphabetical instead of
numerical, so version 10 and above were considered lower than 4.4
resulting in no AES-NI support.  Some gcc version numbers may also
contain several dots as in "16.0.0".

Add a line in --list=build-info showing whether AES-NI support was
built and/or detected.

See #4314
  • Loading branch information
magnumripper committed Nov 26, 2024
1 parent 83a58ac commit 7c8e0ba
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .ci/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ case "$CC" in
esac
;;
clang*)
apt_get_install $packages "$CC"
apt_get_install $packages "$CC" yasm
;;
*)
apt_get_install $packages
Expand Down
16 changes: 15 additions & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ LDFLAGS = -g @LDFLAGS@ $(LIBS) @HAVE_MPI@
OPT_NORMAL = @OPT_NORMAL_FLAGS@
OPT_INLINE = @OPT_INLINE_FLAGS@
#
AES_OK := $(shell expr `$(CC) -dumpversion | cut -d '.' -f 1` \>= 4)
YASM = @YASM@
USE_AESNI = @AESNI_OS@
AESNI_ARCH=@AESNI_ARCH@

ifeq "$(AES_OK)" "1"
ifneq "$(YASM)" ""
ifdef USE_AESNI
ifdef AESNI_ARCH
AESNI_DEC = -DAESNI_IN_USE
endif
endif
endif
endif

PLUGFORMATS_OBJS = @PLUGFORMATS_OBJS@

Expand Down Expand Up @@ -746,7 +760,7 @@ unrarppm.o: unrarppm.c arch.h aes.h autoconfig.h aes/aes_func.h unrar.h unrarhlp
$(CC) -DAC_BUILT $(CFLAGS) $< -o $@

.c.o:
$(CC) $(CFLAGS) $(OPT_NORMAL) $< -o $@
$(CC) $(CFLAGS) $(OPT_NORMAL) $(AESNI_DEC) $< -o $@

.S.o:
$(AS) $(ASFLAGS) $*.S
Expand Down
2 changes: 1 addition & 1 deletion src/aes/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ YASM = @YASM@
AR = @AR@
FIND = @FIND@
RM = /bin/rm -f
GCCV44 := $(shell expr `$(CC) -dumpversion` \>= 4.4)
GCCV44 := $(shell expr `$(CC) -dumpversion | cut -d '.' -f 1` \>= 4)
USE_AESNI = @AESNI_OS@

AESIN = aes.o openssl/ossl_aes.o
Expand Down
2 changes: 1 addition & 1 deletion src/aes/Makefile.legacy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RM = rm -f
GCCV44 := $(shell expr `$(CC) -dumpversion 2>/dev/null` \>= 4.4 2>/dev/null)
GCCV44 := $(shell expr `$(CC) -dumpversion 2>/dev/null | cut -d '.' -f 1` \>= 4)
YASM := $(shell yasm -f $(YASM_FORMAT) 2>&1 | grep "No input files")
UNAME := $(shell $(CC) -dumpmachine 2>/dev/null)

Expand Down
15 changes: 15 additions & 0 deletions src/listconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
#include "version.h"
#include "listconf.h" /* must be included after version.h and misc.h */

#ifdef AESNI_IN_USE
#include "aes.h"
#endif

#ifdef NO_JOHN_BLD
#define JOHN_BLD "unk-build-type"
#else
Expand Down Expand Up @@ -349,6 +353,17 @@ static void listconf_list_build_info(void)
printf("Terminal locale string: %s\n", john_terminal_locale);
printf("Parsed terminal locale: %s\n", cp_id2name(options.terminal_enc));

#ifdef AESNI_IN_USE
if (using_aes_asm())
printf("AES-NI: available\n");
else
printf("AES-NI: not supported by CPU\n");
#elif defined(__i386__) || defined(__x86_64__)
printf("AES-NI: not built\n");
#else
printf("AES-NI: not applicable\n");
#endif

#ifdef __CYGWIN__
{
struct utsname buffer;
Expand Down

0 comments on commit 7c8e0ba

Please sign in to comment.