summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiulio Benetti <giulio.benetti@benettiengineering.com>2020-01-27 15:44:57 +0100
committerGiulio Benetti <giulio.benetti@benettiengineering.com>2020-01-27 15:44:57 +0100
commitecea393aa412fbc1b14f2d1ad05073428a15a0ba (patch)
treeac18b4c3f50d5584e3d5503638d48421726af9a6
parent2053e955f5f5c43707d3657a0ecca95b23cde590 (diff)
downloadnss-hg-ecea393aa412fbc1b14f2d1ad05073428a15a0ba.tar.gz
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.
-rw-r--r--coreconf/config.gypi1
-rw-r--r--coreconf/config.mk5
-rw-r--r--lib/freebl/Makefile2
-rw-r--r--lib/freebl/freebl.gyp14
-rw-r--r--lib/freebl/gcm.h2
5 files changed, 21 insertions, 3 deletions
diff --git a/coreconf/config.gypi b/coreconf/config.gypi
index c07a59ab2..2a730398b 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 60a08411e..704e3fa83 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 eafa0da31..74d131e05 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 d01531ad1..73eb84202 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 aa4dee824..b2c30a731 100644
--- a/lib/freebl/gcm.h
+++ b/lib/freebl/gcm.h
@@ -30,7 +30,7 @@
#include <arm_neon.h>
#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. */