Bug 1646594 - Enable AVX2 if applicable on x86_64 with make 4.3 r=bbeurdouche
authorDanh <congdanhqx@gmail.com>
Tue, 30 Jun 2020 10:15:54 -0700
changeset 15687 b579895aceb0d36fc586e9031d8c5d7a4111201a
parent 15686 cc43ebf5bf88355837c5fafa2f3c46e37626707a
child 15688 8fe9213d05512082e2fccb254559a9b534fd3c96
push id3785
push userjjones@mozilla.com
push dateTue, 30 Jun 2020 17:18:33 +0000
reviewersbbeurdouche
bugs1646594
Bug 1646594 - Enable AVX2 if applicable on x86_64 with make 4.3 r=bbeurdouche
coreconf/arch.mk
coreconf/config.mk
lib/freebl/Makefile
--- a/coreconf/arch.mk
+++ b/coreconf/arch.mk
@@ -111,16 +111,17 @@ ifeq (,$(filter-out Linux FreeBSD IRIX,$
 endif
 
 ifeq ($(OS_ARCH),Linux)
     OS_RELEASE := $(subst ., ,$(OS_RELEASE))
     ifneq ($(words $(OS_RELEASE)),1)
 	OS_RELEASE := $(word 1,$(OS_RELEASE)).$(word 2,$(OS_RELEASE))
     endif
     KERNEL = Linux
+    include $(CORE_DEPTH)/coreconf/Linux.mk
 endif
 
 # Since all uses of OS_ARCH that follow affect only userland, we can
 # merge other Glibc systems with Linux here.
 ifeq ($(OS_ARCH),GNU)
     OS_ARCH = Linux
     OS_RELEASE = 2.6
     KERNEL = GNU
--- a/coreconf/config.mk
+++ b/coreconf/config.mk
@@ -144,18 +144,20 @@ ifdef NSS_DISABLE_LIBPKIX
 DEFINES += -DNSS_DISABLE_LIBPKIX
 endif
 
 ifdef NSS_DISABLE_DBM
 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
 endif
 
 ifdef NSS_DISABLE_DEPRECATED_SEED
 DEFINES += -DNSS_DISABLE_DEPRECATED_SEED
 endif
--- a/lib/freebl/Makefile
+++ b/lib/freebl/Makefile
@@ -543,20 +543,22 @@ endif # USE_64
 
 ifndef HAVE_INT128_SUPPORT
     DEFINES += -DKRML_VERIFIED_UINT128
 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
-        else
-            EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c
         endif # NSS_DISABLE_AVX2
+        EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c
     endif # x86_64
 
     VERIFIED_SRCS += Hacl_Poly1305_32.c Hacl_Chacha20.c Hacl_Chacha20Poly1305_32.c
 endif # NSS_DISABLE_CHACHAPOLY
 
 ifeq (,$(filter-out x86_64 aarch64,$(CPU_ARCH)))
     # All 64-bit architectures get the 64 bit version.
     ECL_SRCS += curve25519_64.c
@@ -730,12 +732,15 @@ ifndef NSS_DISABLE_ALTIVEC
 endif
 endif
 
 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -maes
 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -maes
 $(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
 endif