diff options
author | Danh <congdanhqx@gmail.com> | 2020-09-11 07:40:57 -0700 |
---|---|---|
committer | Danh <congdanhqx@gmail.com> | 2020-09-11 07:40:57 -0700 |
commit | 57492c44597f3b6df8ca8126383fe6361109bb74 (patch) | |
tree | 2170e0bce70e828dda45187b4bfb1ca758ddb97a | |
parent | ac7687cb4d4321247ff9032d25df145581b5be06 (diff) | |
download | nss-hg-57492c44597f3b6df8ca8126383fe6361109bb74.tar.gz |
Bug 1659727 - Move makefile avx2 detection to config.mk. r=kjacobs
Summary:
Current code base use CPU_ARCH to detect if avx2 is supported in arch.mk
However, when arch.mk included, CPU_ARCH haven't been initialised, CPU_ARCH
will be initialised by the OS specific code later on.
Move the AVX2 detection to config.mk, after all other initialisation done.
Reviewers: kjacobs
Reviewed By: kjacobs
Subscribers: kjacobs
Bug #: 1659727
Differential Revision: https://phabricator.services.mozilla.com/D88517
-rw-r--r-- | coreconf/arch.mk | 29 | ||||
-rw-r--r-- | coreconf/config.mk | 29 | ||||
-rw-r--r-- | lib/freebl/Makefile | 14 |
3 files changed, 33 insertions, 39 deletions
diff --git a/coreconf/arch.mk b/coreconf/arch.mk index cc13ced65..9f0cf4dc3 100644 --- a/coreconf/arch.mk +++ b/coreconf/arch.mk @@ -141,35 +141,6 @@ ifeq ($(OS_ARCH),OS_2) endif ####################################################################### -# Master "Core Components" macros for Hardware features # -####################################################################### - -ifndef NSS_DISABLE_AVX2 - ifneq ($(CPU_ARCH),x86_64) - # Disable AVX2 entirely on non-Intel platforms - NSS_DISABLE_AVX2 = 1 - $(warning CPU_ARCH is not x86_64, disabling -mavx2) - else - ifdef CC_IS_CLANG - # Clang reports its version as an older gcc, but it's OK - NSS_DISABLE_AVX2 = 0 - else - ifneq (,$(filter 4.8 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION)))) - NSS_DISABLE_AVX2 = 0 - endif - ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION)))) - NSS_DISABLE_AVX2 = 0 - endif - endif - ifndef NSS_DISABLE_AVX2 - $(warning Unable to find gcc 4.8 or greater, disabling -Werror) - NSS_DISABLE_AVX2 = 1 - endif - endif - export NSS_DISABLE_AVX2 -endif #ndef NSS_DISABLE_AVX2 - -####################################################################### # Master "Core Components" macros for getting the OS target # ####################################################################### diff --git a/coreconf/config.mk b/coreconf/config.mk index 5b8087f2e..6823099e7 100644 --- a/coreconf/config.mk +++ b/coreconf/config.mk @@ -129,6 +129,33 @@ include $(CORE_DEPTH)/coreconf/ruleset.mk endif ####################################################################### +# Master "Core Components" macros for Hardware features # +####################################################################### +ifndef NSS_DISABLE_AVX2 + ifneq ($(CPU_ARCH),x86_64) + # Disable AVX2 entirely on non-Intel platforms + NSS_DISABLE_AVX2 = 1 + $(warning CPU_ARCH is not x86_64, disabling -mavx2) + else + # Clang reports its version as an older gcc, but it's OK + ifndef CC_IS_CLANG + ifneq (,$(filter 0 1 2 3,$(word 1,$(GCC_VERSION)))) + NSS_DISABLE_AVX2 = 1 + endif + ifeq (4,$(word 1,$(GCC_VERSION))) + ifeq (,$(filter 8 9,$(word 2,$(GCC_VERSION)))) + NSS_DISABLE_AVX2 = 1 + endif + endif + endif + ifeq (1,$(NSS_DISABLE_AVX2)) + $(warning Unable to find gcc 4.8 or greater, disabling avx2) + export NSS_DISABLE_AVX2 + endif + endif +endif #ndef NSS_DISABLE_AVX2 + +####################################################################### # [16.0] Global environ ment defines ####################################################################### @@ -149,10 +176,8 @@ DEFINES += -DNSS_DISABLE_DBM endif ifdef NSS_DISABLE_AVX2 -ifneq ($(NSS_DISABLE_AVX2),0) DEFINES += -DNSS_DISABLE_AVX2 endif -endif ifdef NSS_DISABLE_CHACHAPOLY DEFINES += -DNSS_DISABLE_CHACHAPOLY diff --git a/lib/freebl/Makefile b/lib/freebl/Makefile index 5e8a402cb..2851474b9 100644 --- a/lib/freebl/Makefile +++ b/lib/freebl/Makefile @@ -555,12 +555,16 @@ ifneq ($(shell $(CC) -? 2>&1 >/dev/null </dev/null | sed -e 's/:.*//;1q'),lcc) HAVE_INT128_SUPPORT = 1 DEFINES += -DHAVE_INT128_SUPPORT endif - ifneq (,$(filter 4.8 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION)))) + ifneq (,$(filter 0 1 2 3,$(word 1,$(GCC_VERSION)))) NSS_DISABLE_AVX2 = 1 endif + ifeq (4,$(word 1,$(GCC_VERSION))) + ifeq (,$(filter 8 9,$(word 2,$(GCC_VERSION)))) + NSS_DISABLE_AVX2 = 1 + endif + endif ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION)))) HAVE_INT128_SUPPORT = 1 - NSS_DISABLE_AVX2 = 0 DEFINES += -DHAVE_INT128_SUPPORT endif endif @@ -574,9 +578,6 @@ endif ifndef NSS_DISABLE_CHACHAPOLY ifeq ($(CPU_ARCH),x86_64) ifndef NSS_DISABLE_AVX2 - NSS_DISABLE_AVX2 = 0 - endif - ifeq ($(NSS_DISABLE_AVX2),0) EXTRA_SRCS += Hacl_Poly1305_256.c Hacl_Chacha20_Vec256.c Hacl_Chacha20Poly1305_256.c endif # NSS_DISABLE_AVX2 EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c @@ -766,9 +767,6 @@ $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse $(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -maes -mpclmul ifndef NSS_DISABLE_AVX2 - NSS_DISABLE_AVX2 = 0 -endif -ifeq ($(NSS_DISABLE_AVX2),0) $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx2 -maes $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -maes $(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -maes -mpclmul |