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. */