Skip to content

Commit

Permalink
Bug 1659256, add gcc version check on AArch64 optimization, r=rrelyea
Browse files Browse the repository at this point in the history
Summary: As described in https://access.redhat.com/solutions/19458,
gcc version in RHEL-7 is still 4.8.x and cannot compile the newly
added aes-armv8.c. There is a version check already for 32-bit arm,
but not for AArch64. This also removes NS_USE_GCC check added in bug
1652032 in favor of the automatic detection using CC_IS_* macros.

Reviewers: rrelyea

Reviewed By: rrelyea

Subscribers: jmux, kjacobs

Bug #: 1659256

Differential Revision: https://phabricator.services.mozilla.com/D87174

--HG--
extra : rebase_source : 4c849010cabfcd483a72dc470b70e299760785a9
extra : amend_source : 366959f3de60bfe766968fd2788cfaf8d73e3c56
  • Loading branch information
ueno committed Sep 9, 2020
1 parent ed9b04d commit 7290f54
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions lib/freebl/Makefile
Expand Up @@ -119,11 +119,24 @@ else
DEFINES += -DNSS_X86
endif
endif
ifdef NS_USE_GCC
ifeq ($(CPU_ARCH),aarch64)
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
endif
ifdef CC_IS_CLANG
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
else ifeq (1,$(CC_IS_GCC))
# GCC versions older than 4.9 don't support ARM AES. The check
# is done in two parts, first allows "major.minor" == "4.9",
# and then rejects any major versions prior to 5. Note that
# there has been no GCC 4.10, as it was renamed to GCC 5.
ifneq (,$(filter 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
endif
ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
endif
endif
endif
ifeq ($(CPU_ARCH),arm)
ifndef NSS_DISABLE_ARM32_NEON
Expand All @@ -133,7 +146,10 @@ endif
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c sha1-armv8.c sha256-armv8.c
else ifeq (1,$(CC_IS_GCC))
# Old compiler doesn't support ARM AES.
# GCC versions older than 4.9 don't support ARM AES. The check
# is done in two parts, first allows "major.minor" == "4.9",
# and then rejects any major versions prior to 5. Note that
# there has been no GCC 4.10, as it was renamed to GCC 5.
ifneq (,$(filter 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
EXTRA_SRCS += aes-armv8.c sha1-armv8.c sha256-armv8.c
Expand Down Expand Up @@ -728,14 +744,12 @@ $(OBJDIR)/$(PROG_PREFIX)gcm-arm32-neon$(OBJ_SUFFIX): CFLAGS += -mfpu=neon$(if $(
endif
endif

ifdef NS_USE_GCC
ifeq ($(CPU_ARCH),aarch64)
$(OBJDIR)/$(PROG_PREFIX)aes-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
$(OBJDIR)/$(PROG_PREFIX)gcm-aarch64$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
$(OBJDIR)/$(PROG_PREFIX)sha1-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
$(OBJDIR)/$(PROG_PREFIX)sha256-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
endif
endif

ifeq ($(CPU_ARCH),ppc)
ifndef NSS_DISABLE_ALTIVEC
Expand Down

0 comments on commit 7290f54

Please sign in to comment.