From 718a32c6141df0dc4207d0e348a5d7e334961bef Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Mon, 27 Jan 2020 15:44:57 +0100 Subject: [PATCH] Bug 1608151 - Introduce NSS_DISABLE_ALTIVEC and disable_altivec r=jcj At the moment NSS assumes that every PowerPC64 architecture supports Altivec but it's not true and this leads to build failure. So add NSS_DISABLE_ALTIVEC environment variable(and disable_altivec for gyp) to disable Altivec extension on PowerPC build that don't support Altivec. --HG-- extra : amend_source : 2624c36199d90433e32e5fb8ddf002cd65be4f6e --- coreconf/config.gypi | 1 + coreconf/config.mk | 5 +++++ lib/freebl/Makefile | 2 ++ lib/freebl/freebl.gyp | 14 ++++++++++++-- lib/freebl/gcm.h | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/coreconf/config.gypi b/coreconf/config.gypi index c07a59ab2e..2a730398bc 100644 --- a/coreconf/config.gypi +++ b/coreconf/config.gypi @@ -102,6 +102,7 @@ 'disable_dbm%': 1, 'disable_libpkix%': 1, 'disable_werror%': 0, + 'disable_altivec%': 0, 'mozilla_client%': 0, 'comm_client%': 0, 'moz_fold_libs%': 0, diff --git a/coreconf/config.mk b/coreconf/config.mk index 60a08411e8..704e3fa830 100644 --- a/coreconf/config.mk +++ b/coreconf/config.mk @@ -196,6 +196,11 @@ DEFINES += -DPKIX_OBJECT_LEAK_TEST endif endif +# Avoid building with PowerPC's Altivec acceleration +ifdef NSS_DISABLE_ALTIVEC +DEFINES += -DNSS_DISABLE_ALTIVEC +endif + # This allows all library and tools code to use the util function # implementations directly from libnssutil3, rather than the wrappers # in libnss3 which are present for binary compatibility only diff --git a/lib/freebl/Makefile b/lib/freebl/Makefile index eafa0da317..74d131e052 100644 --- a/lib/freebl/Makefile +++ b/lib/freebl/Makefile @@ -778,10 +778,12 @@ $(OBJDIR)/$(PROG_PREFIX)gcm-aarch64$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypt endif ifeq ($(CPU_ARCH),ppc) +ifndef NSS_DISABLE_ALTIVEC $(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx $(OBJDIR)/$(PROG_PREFIX)gcm$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx $(OBJDIR)/$(PROG_PREFIX)rijndael$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx endif +endif $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4 -mavx -maes $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4 -mavx -maes diff --git a/lib/freebl/freebl.gyp b/lib/freebl/freebl.gyp index d01531ad19..73eb842024 100644 --- a/lib/freebl/freebl.gyp +++ b/lib/freebl/freebl.gyp @@ -274,11 +274,16 @@ 'gcm-aes-aarch64_c_lib', ], }], - [ 'target_arch=="ppc64le"', { + [ 'disable_altivec==0 and (target_arch=="ppc64" or target_arch=="ppc64le")', { 'dependencies': [ 'gcm-aes-ppc_c_lib', ], }], + [ 'disable_altivec==1 and (target_arch=="ppc64" or target_arch=="ppc64le")', { + 'defines!': [ + 'NSS_DISABLE_ALTIVEC', + ], + }], [ 'OS=="linux"', { 'defines!': [ 'FREEBL_NO_DEPEND', @@ -330,11 +335,16 @@ 'gcm-aes-aarch64_c_lib', ], }], - [ 'target_arch=="ppc64" or target_arch=="ppc64le"', { + [ 'disable_altivec==0 and (target_arch=="ppc64" or target_arch=="ppc64le")', { 'dependencies': [ 'gcm-aes-ppc_c_lib', ], }], + [ 'disable_altivec==1 and (target_arch=="ppc64" or target_arch=="ppc64le")', { + 'defines!': [ + 'NSS_DISABLE_ALTIVEC', + ], + }], [ 'OS!="linux"', { 'conditions': [ [ 'moz_fold_libs==0', { diff --git a/lib/freebl/gcm.h b/lib/freebl/gcm.h index aa4dee8241..b2c30a7315 100644 --- a/lib/freebl/gcm.h +++ b/lib/freebl/gcm.h @@ -30,7 +30,7 @@ #include #endif -#ifdef __powerpc64__ +#if defined(__powerpc64__) && !defined(NSS_DISABLE_ALTIVEC) #include "altivec-types.h" /* The ghash freebl test tries to use this in C++, and gcc defines conflict. */