Skip to contentSkip to conversation

package/libnss: fix ppc 32-bit build failure

PATCH New Giulio Benetti 2 participants 11 messages Jan 2, 2020 – Feb 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

NSS assumes that Altivec is supported on powerpc64 only, but in Makefile it tries to build gcm-ppc.c(containing Altivec functions calls), even if powerpc is not 64-bits. So add a patch to add a check if architecture is a 64-bit to build gcm-ppc.

Fixes:
http://autobuild.buildroot.net/results/433/433a7db21654d67626c7a3e5f1272d6c3ce4fe6c/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

---
 ...1606689-Fix-ppc-32-bit-build-failure.patch | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch
package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +31 -0
new file mode 100644
index 0000000000..de30fa7002
@@ -0,0 +1,31 @@
+From fcac43d6a0af59926da7ad4a15a37255887cdfa2 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 2 Jan 2020 18:55:50 +0100
+Subject: [PATCH] Bug 1606689 - Fix ppc 32-bit build failure
+
+NSS assumes that only 64-bit powerpc support Altivec instructions to be
+used in gcm-ppc.c, so align Makefile condition to build gcm-ppc.c only
+if USE_64 is defined.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/lib/freebl/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..0e230d8c5 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -264,8 +264,8 @@ ifeq ($(CPU_ARCH),arm)
+     MPI_SRCS += mpi_arm.c
+ endif
+ ifeq ($(CPU_ARCH),ppc)
+-    EXTRA_SRCS += gcm-ppc.c
+ ifdef USE_64
++    EXTRA_SRCS += gcm-ppc.c
+     DEFINES += -DNSS_NO_INIT_SUPPORT
+ endif # USE_64
+ endif # ppc
+-- 
+2.20.1
+
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

Giulio,

Quoted 38 lines · Giulio Benetti

NSS assumes that Altivec is supported on powerpc64 only, but in Makefile it tries to build gcm-ppc.c(containing Altivec functions calls), even if powerpc is not 64-bits. So add a patch to add a check if architecture is a 64-bit to build gcm-ppc.

Fixes:
http://autobuild.buildroot.net/results/433/433a7db21654d67626c7a3e5f1272d6c3ce4fe6c/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

---
  ...1606689-Fix-ppc-32-bit-build-failure.patch | 31 +++++++++++++++++++
  1 file changed, 31 insertions(+)

create mode 100644 package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch

package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +15 -0
new file mode 100644
index 0000000000..de30fa7002
@@ -0,0 +1,31 @@
+From fcac43d6a0af59926da7ad4a15a37255887cdfa2 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 2 Jan 2020 18:55:50 +0100
+Subject: [PATCH] Bug 1606689 - Fix ppc 32-bit build failure
+
+NSS assumes that only 64-bit powerpc support Altivec instructions to be
+used in gcm-ppc.c, so align Makefile condition to build gcm-ppc.c only
+if USE_64 is defined.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/lib/freebl/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile

package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch line 25

Quoted 10 lines
package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +10 -0
+index 00518d7f8..0e230d8c5 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -264,8 +264,8 @@ ifeq ($(CPU_ARCH),arm)
+     MPI_SRCS += mpi_arm.c
+ endif
+ ifeq ($(CPU_ARCH),ppc)
+-    EXTRA_SRCS += gcm-ppc.c
+ ifdef USE_64
++    EXTRA_SRCS += gcm-ppc.c

Are you dropping this file for 32bit builds due to the Altivec requirements? General Altivec instructions are available on 32bit chips, such as those from Freescale/NXP. The e600 is a product that comes to mind. IMO, the Makefile should include the file if the architecture is 'ppc'. I think it makes sense that the source file should determine what it compiles down to. It's possible the hw acceleration logic for PPC changes later and this is one more file that would need to be touched.

Unfortunately, this is where it gets a bit more complicated...

The backing instruction for the vec_xl_be compiler intrinsic is lxvd2x (a VSX instruction). Technically I think this instruction was available in the Power ISA as early as 2.06, but GCC is only advertising the intrinsic as of ISA 3.0 (Power 9+).
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/PowerPC-Built-in-Functions.html#PowerPC-Built-in-Functions

I've always had issues reading the logic behind GCC's instruction generation and I don't have 8+ handy... I'm not sure if there's a guard to prevent the lxvd2x instruction from being emitted or not when resolving vec_xl_be and, say, '-maltivec -mpcu=7450' is specified. If there isn't, I'd expect either an illegal instruction exception or for the kernel to emulate it magically. If there is, I'd expect GCC to either compile a compatible instruction shim or to simply error out.

Regardless, given the way the hardware acceleration is written currently to require that compiler intrinsic, USE_PPC_CRYPTO may need to be guarded by __builtin_cpu_supports("arch_3_00")

Quoted 6 lines
package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +6 -0
+     DEFINES += -DNSS_NO_INIT_SUPPORT
+ endif # USE_64
+ endif # ppc
+--
+2.20.1
+
Signature · 4 lines
Vincent Fazio
Embedded Software Engineer - Linux
Extreme Engineering Solutions, Inc
http://www.xes-inc.com
#2 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

Hi Vincent,

Quoted 76 lines · Vincent Fazio

Giulio,

Quoted 38 lines · Giulio Benetti

NSS assumes that Altivec is supported on powerpc64 only, but in Makefile it tries to build gcm-ppc.c(containing Altivec functions calls), even if powerpc is not 64-bits. So add a patch to add a check if architecture is a 64-bit to build gcm-ppc.

Fixes:
http://autobuild.buildroot.net/results/433/433a7db21654d67626c7a3e5f1272d6c3ce4fe6c/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

---
   ...1606689-Fix-ppc-32-bit-build-failure.patch | 31 +++++++++++++++++++
   1 file changed, 31 insertions(+)

create mode 100644 package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch

package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +15 -0
new file mode 100644
index 0000000000..de30fa7002
@@ -0,0 +1,31 @@
+From fcac43d6a0af59926da7ad4a15a37255887cdfa2 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 2 Jan 2020 18:55:50 +0100
+Subject: [PATCH] Bug 1606689 - Fix ppc 32-bit build failure
+
+NSS assumes that only 64-bit powerpc support Altivec instructions to be
+used in gcm-ppc.c, so align Makefile condition to build gcm-ppc.c only
+if USE_64 is defined.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/lib/freebl/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile

package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch line 25

Quoted 10 lines
package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +10 -0
+index 00518d7f8..0e230d8c5 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -264,8 +264,8 @@ ifeq ($(CPU_ARCH),arm)
+     MPI_SRCS += mpi_arm.c
+ endif
+ ifeq ($(CPU_ARCH),ppc)
+-    EXTRA_SRCS += gcm-ppc.c
+ ifdef USE_64
++    EXTRA_SRCS += gcm-ppc.c

Are you dropping this file for 32bit builds due to the Altivec requirements? General Altivec instructions are available on 32bit chips, such as those from Freescale/NXP. The e600 is a product that comes to mind. IMO, the Makefile should include the file if the architecture is 'ppc'. I think it makes sense that the source file should determine what it compiles down to. It's possible the hw acceleration logic for PPC changes later and this is one more file that would need to be touched.

Unfortunately, this is where it gets a bit more complicated...

The backing instruction for the vec_xl_be compiler intrinsic is lxvd2x (a VSX instruction). Technically I think this instruction was available in the Power ISA as early as 2.06, but GCC is only advertising the intrinsic as of ISA 3.0 (Power 9+).
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/PowerPC-Built-in-Functions.html#PowerPC-Built-in-Functions

I've always had issues reading the logic behind GCC's instruction generation and I don't have 8+ handy... I'm not sure if there's a guard to prevent the lxvd2x instruction from being emitted or not when resolving vec_xl_be and, say, '-maltivec -mpcu=7450' is specified. If there isn't, I'd expect either an illegal instruction exception or for the kernel to emulate it magically. If there is, I'd expect GCC to either compile a compatible instruction shim or to simply error out.

Quoted 3 lines

Regardless, given the way the hardware acceleration is written currently to require that compiler intrinsic, USE_PPC_CRYPTO may need to be guarded by __builtin_cpu_supports("arch_3_00")

They are all good suggestions but I think they are more NSS related than Buildroot related. What I'm trying to do here is to avoid build failure in Buildroot and as much as possible to try to contribute upstream. As you've mentioned above 32-bit supports Altivec, but the problem at the moment is that USE_PPC_CRYPTO is defined in gcm.h only if __powerpc64__ is defined, this means that they only tested it for that architecture(ppc64 and ppc64le). So at the moment I'd prefer keep 32-bit Altivec supported devices without gcm altivec acceleration. But if you have a patch that takes into account 32-bits Altivec too, please upload it here:

https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

so we fix this problem once!

Maybe we can live chat on BR IRC if you join it.

Thanks for reviewing so in depth.
Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 7 lines
Quoted 6 lines
package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +6 -0
+     DEFINES += -DNSS_NO_INIT_SUPPORT
+ endif # USE_64
+ endif # ppc
+--
+2.20.1
+
#3 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

Giulio,

Quoted 34 lines · Giulio Benetti

Hi Vincent,

Quoted 27 lines · Vincent Fazio

Giulio,

Are you dropping this file for 32bit builds due to the Altivec requirements? General Altivec instructions are available on 32bit chips, such as those from Freescale/NXP. The e600 is a product that comes to mind. IMO, the Makefile should include the file if the architecture is 'ppc'. I think it makes sense that the source file should determine what it compiles down to. It's possible the hw acceleration logic for PPC changes later and this is one more file that would need to be touched.

Unfortunately, this is where it gets a bit more complicated...

The backing instruction for the vec_xl_be compiler intrinsic is lxvd2x (a VSX instruction). Technically I think this instruction was available in the Power ISA as early as 2.06, but GCC is only advertising the intrinsic as of ISA 3.0 (Power 9+).
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/PowerPC-Built-in-Functions.html#PowerPC-Built-in-Functions

I've always had issues reading the logic behind GCC's instruction generation and I don't have 8+ handy... I'm not sure if there's a guard to prevent the lxvd2x instruction from being emitted or not when resolving vec_xl_be and, say, '-maltivec -mpcu=7450' is specified. If there isn't, I'd expect either an illegal instruction exception or for the kernel to emulate it magically. If there is, I'd expect GCC to either compile a compatible instruction shim or to simply error out.

Quoted 3 lines

Regardless, given the way the hardware acceleration is written currently to require that compiler intrinsic, USE_PPC_CRYPTO may need to be guarded by __builtin_cpu_supports("arch_3_00")

Quoted 11 lines

They are all good suggestions but I think they are more NSS related than Buildroot related. What I'm trying to do here is to avoid build failure in Buildroot and as much as possible to try to contribute upstream. As you've mentioned above 32-bit supports Altivec, but the problem at the moment is that USE_PPC_CRYPTO is defined in gcm.h only if __powerpc64__ is defined, this means that they only tested it for that architecture(ppc64 and ppc64le). So at the moment I'd prefer keep 32-bit Altivec supported devices without gcm altivec acceleration. But if you have a patch that takes into account 32-bits Altivec too, please upload it here:

For Buildroot, we can likely key off ifneq($(BR2_POWERPC_CPU_HAS_ALTIVEC),y) and sed delete the '-mcrypto -maltivec' flags from lib/freebl/Makefile... The -mcrypto enables -mvsx and causes gcc to emit instructions the target CPU may not support, that's why it should be removed. Luckily, we can make some assumptions that if ALTIVEC isn't supported, VSX and Crypto functions arent either since they're introduced in the same or later ISA revisions.

Quoted 3 lines

https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

so we fix this problem once!

I'm not sure this can be done "cleanly" given how this is currently structured. I've added a comment in the bug. Not all 64bit PPC processors have Altivec (e5500 does not). Plus this goes a bit beyond that since the functions they're using require at least Power ISA 3.0. The source package should probably inherit CFLAGS instead of assuming it can define it given the complexities of PPC cpu tuning.

Quoted 2 lines

Maybe we can live chat on BR IRC if you join it.

I'm idling there today

Quoted 4 lines

Thanks for reviewing so in depth.
Best regards

Signature · 4 lines
Vincent Fazio
Embedded Software Engineer - Linux
Extreme Engineering Solutions, Inc
http://www.xes-inc.com
#4 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

Vincent, Thomas, Yann, All,

Quoted 48 lines · Vincent Fazio

Giulio,

Quoted 34 lines · Giulio Benetti

Hi Vincent,

Quoted 27 lines · Vincent Fazio

Giulio,

Are you dropping this file for 32bit builds due to the Altivec requirements? General Altivec instructions are available on 32bit chips, such as those from Freescale/NXP. The e600 is a product that comes to mind. IMO, the Makefile should include the file if the architecture is 'ppc'. I think it makes sense that the source file should determine what it compiles down to. It's possible the hw acceleration logic for PPC changes later and this is one more file that would need to be touched.

Unfortunately, this is where it gets a bit more complicated...

The backing instruction for the vec_xl_be compiler intrinsic is lxvd2x (a VSX instruction). Technically I think this instruction was available in the Power ISA as early as 2.06, but GCC is only advertising the intrinsic as of ISA 3.0 (Power 9+).
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/PowerPC-Built-in-Functions.html#PowerPC-Built-in-Functions

I've always had issues reading the logic behind GCC's instruction generation and I don't have 8+ handy... I'm not sure if there's a guard to prevent the lxvd2x instruction from being emitted or not when resolving vec_xl_be and, say, '-maltivec -mpcu=7450' is specified. If there isn't, I'd expect either an illegal instruction exception or for the kernel to emulate it magically. If there is, I'd expect GCC to either compile a compatible instruction shim or to simply error out.

Quoted 3 lines

Regardless, given the way the hardware acceleration is written currently to require that compiler intrinsic, USE_PPC_CRYPTO may need to be guarded by __builtin_cpu_supports("arch_3_00")

Quoted 11 lines

They are all good suggestions but I think they are more NSS related than Buildroot related. What I'm trying to do here is to avoid build failure in Buildroot and as much as possible to try to contribute upstream. As you've mentioned above 32-bit supports Altivec, but the problem at the moment is that USE_PPC_CRYPTO is defined in gcm.h only if __powerpc64__ is defined, this means that they only tested it for that architecture(ppc64 and ppc64le). So at the moment I'd prefer keep 32-bit Altivec supported devices without gcm altivec acceleration. But if you have a patch that takes into account 32-bits Altivec too, please upload it here:

Quoted 2 lines

For Buildroot, we can likely key off
ifneq($(BR2_POWERPC_CPU_HAS_ALTIVEC),y)

Yes, this is a good idea.

Quoted 2 lines

and sed delete the '-mcrypto
-maltivec' flags from lib/freebl/Makefile...

It's better to avoid this kind of blind hack. I'd prefer to introduce a patch in NSS which adds a NSS_ALTIVEC_DISABLE to avoid building gcm-ppc.c. So combined with your suggestion above we can do something like:

ifeq($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
NSS_ALTIVEC_DISABLE=1
endif

The -mcrypto enables -mvsx

Quoted 4 lines

and causes gcc to emit instructions the target CPU may not support, that's why it should be removed. Luckily, we can make some assumptions that if ALTIVEC isn't supported, VSX and Crypto functions arent either since they're introduced in the same or later ISA revisions.

So let's assume this.

Quoted 6 lines
Quoted 3 lines

https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

so we fix this problem once!

I'm not sure this can be done "cleanly" given how this is currently structured. I've added a comment in the bug. Not all 64bit PPC processors have Altivec (e5500 does not).

Yes, I see now.

Quoted 4 lines

Plus this goes a bit beyond
that since the functions they're using require at least Power ISA 3.0. The source package should probably inherit CFLAGS instead of assuming it can define it given the complexities of PPC cpu tuning.

From NSS point of view this would be fixed by introducing
NSS_ALTIVEC_DISABLE, but from Buildroot point of view this should be done by adding a new variable like BR2_POWERPC_AT_LEAST_ISA_X_X

But I don't know if it's worth the effort.

What about above?

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 8 lines
Quoted 2 lines

Maybe we can live chat on BR IRC if you join it.

I'm idling there today

Quoted 4 lines

Thanks for reviewing so in depth.
Best regards

#5 lore raw

PATCH 1/1 package/libnss: fix powerpc altivec build failure

NSS doesn't provide a way to understand if PowerPC compiler supports Altivec, and it would also be difficult to do with a simple Makefile. So add patch to disable Altivec extension with variable NSS_DISABLE_ALTIVEC, then pass NSS_DISABLE_ALTIVEC=1 if BR2_POWERPC_CPU_HAS_ALTIVEC is not 'y'.

Fixes:
http://autobuild.buildroot.net/results/957/957cec911bcd68a18418ad02f13e7e3001521c59/
http://autobuild.buildroot.net/results/6a1/6a1578619a477e1605fe152070f004b662f1d839/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1608151

---
 ...1608151-Introduce-NSS_ENABLE_ALTIVEC.patch | 95 +++++++++++++++++++
 package/libnss/libnss.mk                      |  5 +
 2 files changed, 100 insertions(+)
 create mode 100644 package/libnss/0002-Bug-1608151-Introduce-NSS_ENABLE_ALTIVEC.patch
package/libnss/0002-Bug-1608151-Introduce-NSS_ENABLE_ALTIVEC.patch new file +95 -0
new file mode 100644
index 0000000000..e492a63d6e
@@ -0,0 +1,95 @@
+From 7ce53f890e26630d2d9677ab579281b3708c2605 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Tue, 14 Jan 2020 18:55:53 +0100
+Subject: [PATCH] Bug 1608151 - Introduce NSS_ENABLE_ALTIVEC
+
+Add NSS_ENABLE_ALTIVEC environment variable to enable/disable Altivec
+extension on PowerPC build. At the time NSS assumes that every PowerPC64
+architecture supports Altivec but it's not true and this leads to build
+failure.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/coreconf/config.gypi  | 1 +
+ nss/coreconf/config.mk    | 5 +++++
+ nss/lib/freebl/Makefile   | 2 ++
+ nss/lib/freebl/freebl.gyp | 2 +-
+ nss/lib/freebl/gcm.h      | 2 ++
+ 5 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/nss/coreconf/config.gypi b/nss/coreconf/config.gypi
+index 2e6cc390e..fc113a6fc 100644
+--- a/nss/coreconf/config.gypi
++++ b/nss/coreconf/config.gypi
+@@ -102,6 +102,7 @@
+     'disable_dbm%': 1,
+     'disable_libpkix%': 1,
+     'disable_werror%': 0,
++    'disable_altivec': 1,
+     'mozilla_client%': 0,
+     'comm_client%': 0,
+     'moz_fold_libs%': 0,
+diff --git a/nss/coreconf/config.mk b/nss/coreconf/config.mk
+index 60a08411e..704e3fa83 100644
+--- a/nss/coreconf/config.mk
++++ b/nss/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/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..fc3e2099e 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -790,5 +790,7 @@ $(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
+ endif
++endif
+diff --git a/nss/lib/freebl/freebl.gyp b/nss/lib/freebl/freebl.gyp
+index 5d247742d..f968c408a 100644
+--- a/nss/lib/freebl/freebl.gyp
++++ b/nss/lib/freebl/freebl.gyp
+@@ -238,7 +238,7 @@
+             'gcm-aes-aarch64_c_lib',
+           ],
+         }],
+-        [ 'target_arch=="ppc64le"', {
++        [ 'disable_altivec==0 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
+           'dependencies': [
+             'gcm-aes-ppc_c_lib',
+           ],
+diff --git a/nss/lib/freebl/gcm.h b/nss/lib/freebl/gcm.h
+index aa4dee824..64aac56b2 100644
+--- a/nss/lib/freebl/gcm.h
++++ b/nss/lib/freebl/gcm.h
+@@ -30,6 +30,7 @@
+ #include <arm_neon.h>
+ #endif
+ 
++#ifndef NSS_DISABLE_ALTIVEC
+ #ifdef __powerpc64__
+ #include "altivec-types.h"
+ 
+@@ -39,6 +40,7 @@
+ #undef vector
+ #undef bool
+ #endif
++#endif
+ 
+ /*
+  * PPC CRYPTO requires at least gcc 8 or clang. The LE check is purely
+-- 
+2.20.1
+
package/libnss/libnss.mk +5 -0
index d7d3cda86b..b9dab44c11 100644
@@ -50,6 +50,11 @@ LIBNSS_BUILD_VARS = \
 	OS_TEST=$(BR2_PACKAGE_LIBNSS_ARCH) \
 	NSS_ENABLE_WERROR=0
 
+ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
+# Disable Altivec if not supported
+LIBNSS_BUILD_VARS += NSS_DISABLE_ALTIVEC=1
+endif
+
 ifeq ($(BR2_ARCH_IS_64),y)
 # MIPS64 n32 is treated as a 32-bit architecture by libnss.
 # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1010730
Signature · 1 line
2.20.1
#6 lore raw

PATCH 1/1 package/libnss: fix powerpc altivec build failure

Patch must be called: NSS_DISABLE_ALTIVEC, not ENABLE. Going to re-send corrected.

Sorry for the noise.

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 138 lines · Giulio Benetti

NSS doesn't provide a way to understand if PowerPC compiler supports Altivec, and it would also be difficult to do with a simple Makefile. So add patch to disable Altivec extension with variable NSS_DISABLE_ALTIVEC, then pass NSS_DISABLE_ALTIVEC=1 if BR2_POWERPC_CPU_HAS_ALTIVEC is not 'y'.

Fixes:
http://autobuild.buildroot.net/results/957/957cec911bcd68a18418ad02f13e7e3001521c59/
http://autobuild.buildroot.net/results/6a1/6a1578619a477e1605fe152070f004b662f1d839/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1608151

---
  ...1608151-Introduce-NSS_ENABLE_ALTIVEC.patch | 95 +++++++++++++++++++
  package/libnss/libnss.mk                      |  5 +
  2 files changed, 100 insertions(+)

create mode 100644 package/libnss/0002-Bug-1608151-Introduce-NSS_ENABLE_ALTIVEC.patch

package/libnss/0002-Bug-1608151-Introduce-NSS_ENABLE_ALTIVEC.patch new file +95 -0
new file mode 100644
index 0000000000..e492a63d6e
@@ -0,0 +1,95 @@
+From 7ce53f890e26630d2d9677ab579281b3708c2605 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Tue, 14 Jan 2020 18:55:53 +0100
+Subject: [PATCH] Bug 1608151 - Introduce NSS_ENABLE_ALTIVEC
+
+Add NSS_ENABLE_ALTIVEC environment variable to enable/disable Altivec
+extension on PowerPC build. At the time NSS assumes that every PowerPC64
+architecture supports Altivec but it's not true and this leads to build
+failure.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/coreconf/config.gypi  | 1 +
+ nss/coreconf/config.mk    | 5 +++++
+ nss/lib/freebl/Makefile   | 2 ++
+ nss/lib/freebl/freebl.gyp | 2 +-
+ nss/lib/freebl/gcm.h      | 2 ++
+ 5 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/nss/coreconf/config.gypi b/nss/coreconf/config.gypi
+index 2e6cc390e..fc113a6fc 100644
+--- a/nss/coreconf/config.gypi
++++ b/nss/coreconf/config.gypi
+@@ -102,6 +102,7 @@
+     'disable_dbm%': 1,
+     'disable_libpkix%': 1,
+     'disable_werror%': 0,
++    'disable_altivec': 1,
+     'mozilla_client%': 0,
+     'comm_client%': 0,
+     'moz_fold_libs%': 0,
+diff --git a/nss/coreconf/config.mk b/nss/coreconf/config.mk
+index 60a08411e..704e3fa83 100644
+--- a/nss/coreconf/config.mk
++++ b/nss/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/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..fc3e2099e 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -790,5 +790,7 @@ $(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
+ endif
++endif
+diff --git a/nss/lib/freebl/freebl.gyp b/nss/lib/freebl/freebl.gyp
+index 5d247742d..f968c408a 100644
+--- a/nss/lib/freebl/freebl.gyp
++++ b/nss/lib/freebl/freebl.gyp
+@@ -238,7 +238,7 @@
+             'gcm-aes-aarch64_c_lib',
+           ],
+         }],
+-        [ 'target_arch=="ppc64le"', {
++        [ 'disable_altivec==0 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
+           'dependencies': [
+             'gcm-aes-ppc_c_lib',
+           ],
+diff --git a/nss/lib/freebl/gcm.h b/nss/lib/freebl/gcm.h
+index aa4dee824..64aac56b2 100644
+--- a/nss/lib/freebl/gcm.h
++++ b/nss/lib/freebl/gcm.h
+@@ -30,6 +30,7 @@
+ #include <arm_neon.h>
+ #endif
+
++#ifndef NSS_DISABLE_ALTIVEC
+ #ifdef __powerpc64__
+ #include "altivec-types.h"
+
+@@ -39,6 +40,7 @@
+ #undef vector
+ #undef bool
+ #endif
++#endif
+
+ /*
+  * PPC CRYPTO requires at least gcc 8 or clang. The LE check is purely
+--
+2.20.1
+
package/libnss/libnss.mk +5 -0
index d7d3cda86b..b9dab44c11 100644
@@ -50,6 +50,11 @@ LIBNSS_BUILD_VARS = \
  	OS_TEST=$(BR2_PACKAGE_LIBNSS_ARCH) \
  	NSS_ENABLE_WERROR=0
 
+ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
+# Disable Altivec if not supported
+LIBNSS_BUILD_VARS += NSS_DISABLE_ALTIVEC=1
+endif
+
  ifeq ($(BR2_ARCH_IS_64),y)
  # MIPS64 n32 is treated as a 32-bit architecture by libnss.
  # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1010730
#7 lore raw

PATCH v2 1/1 package/libnss: fix powerpc altivec build failure

NSS doesn't provide a way to understand if PowerPC compiler supports Altivec, and it would also be difficult to do with a simple Makefile. So add patch to disable Altivec extension with variable NSS_DISABLE_ALTIVEC, then pass NSS_DISABLE_ALTIVEC=1 if BR2_POWERPC_CPU_HAS_ALTIVEC is not 'y'.

---
V1 -> V2:
* changed patch name and commit log with DISABLE instead of ENABLE

---
 ...608151-Introduce-NSS_DISABLE_ALTIVEC.patch | 95 +++++++++++++++++++
 package/libnss/libnss.mk                      |  5 +
 2 files changed, 100 insertions(+)
 create mode 100644 package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch
package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch new file +95 -0
new file mode 100644
index 0000000000..0931f4b961
@@ -0,0 +1,95 @@
+From 7ce53f890e26630d2d9677ab579281b3708c2605 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Tue, 14 Jan 2020 18:55:53 +0100
+Subject: [PATCH] Bug 1608151 - Introduce NSS_DISABLE_ALTIVEC
+
+Add NSS_DISABLE_ALTIVEC environment variable to disable Altivec
+extension on PowerPC build. At the time NSS assumes that every PowerPC64
+architecture supports Altivec but it's not true and this leads to build
+failure.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/coreconf/config.gypi  | 1 +
+ nss/coreconf/config.mk    | 5 +++++
+ nss/lib/freebl/Makefile   | 2 ++
+ nss/lib/freebl/freebl.gyp | 2 +-
+ nss/lib/freebl/gcm.h      | 2 ++
+ 5 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/nss/coreconf/config.gypi b/nss/coreconf/config.gypi
+index 2e6cc390e..fc113a6fc 100644
+--- a/nss/coreconf/config.gypi
++++ b/nss/coreconf/config.gypi
+@@ -102,6 +102,7 @@
+     'disable_dbm%': 1,
+     'disable_libpkix%': 1,
+     'disable_werror%': 0,
++    'disable_altivec': 1,
+     'mozilla_client%': 0,
+     'comm_client%': 0,
+     'moz_fold_libs%': 0,
+diff --git a/nss/coreconf/config.mk b/nss/coreconf/config.mk
+index 60a08411e..704e3fa83 100644
+--- a/nss/coreconf/config.mk
++++ b/nss/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/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..fc3e2099e 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -790,5 +790,7 @@ $(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
+ endif
++endif
+diff --git a/nss/lib/freebl/freebl.gyp b/nss/lib/freebl/freebl.gyp
+index 5d247742d..f968c408a 100644
+--- a/nss/lib/freebl/freebl.gyp
++++ b/nss/lib/freebl/freebl.gyp
+@@ -238,7 +238,7 @@
+             'gcm-aes-aarch64_c_lib',
+           ],
+         }],
+-        [ 'target_arch=="ppc64le"', {
++        [ 'disable_altivec==0 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
+           'dependencies': [
+             'gcm-aes-ppc_c_lib',
+           ],
+diff --git a/nss/lib/freebl/gcm.h b/nss/lib/freebl/gcm.h
+index aa4dee824..64aac56b2 100644
+--- a/nss/lib/freebl/gcm.h
++++ b/nss/lib/freebl/gcm.h
+@@ -30,6 +30,7 @@
+ #include <arm_neon.h>
+ #endif
+ 
++#ifndef NSS_DISABLE_ALTIVEC
+ #ifdef __powerpc64__
+ #include "altivec-types.h"
+ 
+@@ -39,6 +40,7 @@
+ #undef vector
+ #undef bool
+ #endif
++#endif
+ 
+ /*
+  * PPC CRYPTO requires at least gcc 8 or clang. The LE check is purely
+-- 
+2.20.1
+
package/libnss/libnss.mk +5 -0
index d7d3cda86b..b9dab44c11 100644
@@ -50,6 +50,11 @@ LIBNSS_BUILD_VARS = \
 	OS_TEST=$(BR2_PACKAGE_LIBNSS_ARCH) \
 	NSS_ENABLE_WERROR=0
 
+ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
+# Disable Altivec if not supported
+LIBNSS_BUILD_VARS += NSS_DISABLE_ALTIVEC=1
+endif
+
 ifeq ($(BR2_ARCH_IS_64),y)
 # MIPS64 n32 is treated as a 32-bit architecture by libnss.
 # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1010730
Signature · 1 line
2.20.1
#8 lore raw

PATCH v2 1/1 package/libnss: fix powerpc altivec build failure

Quoted 5 lines · Giulio Benetti

NSS doesn't provide a way to understand if PowerPC compiler supports Altivec, and it would also be difficult to do with a simple Makefile. So add patch to disable Altivec extension with variable NSS_DISABLE_ALTIVEC, then pass NSS_DISABLE_ALTIVEC=1 if BR2_POWERPC_CPU_HAS_ALTIVEC is not 'y'.

Fixes:
http://autobuild.buildroot.net/results/957/957cec911bcd68a18418ad02f13e7e3001521c59/
http://autobuild.buildroot.net/results/6a1/6a1578619a477e1605fe152070f004b662f1d839/

Quoted 128 lines

---
V1 -> V2:
* changed patch name and commit log with DISABLE instead of ENABLE

---
  ...608151-Introduce-NSS_DISABLE_ALTIVEC.patch | 95 +++++++++++++++++++
  package/libnss/libnss.mk                      |  5 +
  2 files changed, 100 insertions(+)

create mode 100644 package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch

package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch new file +95 -0
new file mode 100644
index 0000000000..0931f4b961
@@ -0,0 +1,95 @@
+From 7ce53f890e26630d2d9677ab579281b3708c2605 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Tue, 14 Jan 2020 18:55:53 +0100
+Subject: [PATCH] Bug 1608151 - Introduce NSS_DISABLE_ALTIVEC
+
+Add NSS_DISABLE_ALTIVEC environment variable to disable Altivec
+extension on PowerPC build. At the time NSS assumes that every PowerPC64
+architecture supports Altivec but it's not true and this leads to build
+failure.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/coreconf/config.gypi  | 1 +
+ nss/coreconf/config.mk    | 5 +++++
+ nss/lib/freebl/Makefile   | 2 ++
+ nss/lib/freebl/freebl.gyp | 2 +-
+ nss/lib/freebl/gcm.h      | 2 ++
+ 5 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/nss/coreconf/config.gypi b/nss/coreconf/config.gypi
+index 2e6cc390e..fc113a6fc 100644
+--- a/nss/coreconf/config.gypi
++++ b/nss/coreconf/config.gypi
+@@ -102,6 +102,7 @@
+     'disable_dbm%': 1,
+     'disable_libpkix%': 1,
+     'disable_werror%': 0,
++    'disable_altivec': 1,
+     'mozilla_client%': 0,
+     'comm_client%': 0,
+     'moz_fold_libs%': 0,
+diff --git a/nss/coreconf/config.mk b/nss/coreconf/config.mk
+index 60a08411e..704e3fa83 100644
+--- a/nss/coreconf/config.mk
++++ b/nss/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/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..fc3e2099e 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -790,5 +790,7 @@ $(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
+ endif
++endif
+diff --git a/nss/lib/freebl/freebl.gyp b/nss/lib/freebl/freebl.gyp
+index 5d247742d..f968c408a 100644
+--- a/nss/lib/freebl/freebl.gyp
++++ b/nss/lib/freebl/freebl.gyp
+@@ -238,7 +238,7 @@
+             'gcm-aes-aarch64_c_lib',
+           ],
+         }],
+-        [ 'target_arch=="ppc64le"', {
++        [ 'disable_altivec==0 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
+           'dependencies': [
+             'gcm-aes-ppc_c_lib',
+           ],
+diff --git a/nss/lib/freebl/gcm.h b/nss/lib/freebl/gcm.h
+index aa4dee824..64aac56b2 100644
+--- a/nss/lib/freebl/gcm.h
++++ b/nss/lib/freebl/gcm.h
+@@ -30,6 +30,7 @@
+ #include <arm_neon.h>
+ #endif
+
++#ifndef NSS_DISABLE_ALTIVEC
+ #ifdef __powerpc64__
+ #include "altivec-types.h"
+
+@@ -39,6 +40,7 @@
+ #undef vector
+ #undef bool
+ #endif
++#endif
+
+ /*
+  * PPC CRYPTO requires at least gcc 8 or clang. The LE check is purely
+--
+2.20.1
+
package/libnss/libnss.mk +5 -0
index d7d3cda86b..b9dab44c11 100644
@@ -50,6 +50,11 @@ LIBNSS_BUILD_VARS = \
  	OS_TEST=$(BR2_PACKAGE_LIBNSS_ARCH) \
  	NSS_ENABLE_WERROR=0
 
+ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
+# Disable Altivec if not supported
+LIBNSS_BUILD_VARS += NSS_DISABLE_ALTIVEC=1
+endif
+
  ifeq ($(BR2_ARCH_IS_64),y)
  # MIPS64 n32 is treated as a 32-bit architecture by libnss.
  # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1010730
Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
#9 lore raw

PATCH v2 1/1 package/libnss: fix powerpc altivec build failure

Hi All,

The patch contained in this patch has been upstreamed:
https://hg.mozilla.org/projects/nss/rev/f2d9478178505d24da34f2e694bdd05e0e6395c6

Kind regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 140 lines · Giulio Benetti
Quoted 5 lines · Giulio Benetti

NSS doesn't provide a way to understand if PowerPC compiler supports Altivec, and it would also be difficult to do with a simple Makefile. So add patch to disable Altivec extension with variable NSS_DISABLE_ALTIVEC, then pass NSS_DISABLE_ALTIVEC=1 if BR2_POWERPC_CPU_HAS_ALTIVEC is not 'y'.

Fixes:
http://autobuild.buildroot.net/results/957/957cec911bcd68a18418ad02f13e7e3001521c59/
http://autobuild.buildroot.net/results/6a1/6a1578619a477e1605fe152070f004b662f1d839/

Quoted 128 lines

---
V1 -> V2:
* changed patch name and commit log with DISABLE instead of ENABLE

---
   ...608151-Introduce-NSS_DISABLE_ALTIVEC.patch | 95 +++++++++++++++++++
   package/libnss/libnss.mk                      |  5 +
   2 files changed, 100 insertions(+)

create mode 100644 package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch

package/libnss/0002-Bug-1608151-Introduce-NSS_DISABLE_ALTIVEC.patch new file +95 -0
new file mode 100644
index 0000000000..0931f4b961
@@ -0,0 +1,95 @@
+From 7ce53f890e26630d2d9677ab579281b3708c2605 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Tue, 14 Jan 2020 18:55:53 +0100
+Subject: [PATCH] Bug 1608151 - Introduce NSS_DISABLE_ALTIVEC
+
+Add NSS_DISABLE_ALTIVEC environment variable to disable Altivec
+extension on PowerPC build. At the time NSS assumes that every PowerPC64
+architecture supports Altivec but it's not true and this leads to build
+failure.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/coreconf/config.gypi  | 1 +
+ nss/coreconf/config.mk    | 5 +++++
+ nss/lib/freebl/Makefile   | 2 ++
+ nss/lib/freebl/freebl.gyp | 2 +-
+ nss/lib/freebl/gcm.h      | 2 ++
+ 5 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/nss/coreconf/config.gypi b/nss/coreconf/config.gypi
+index 2e6cc390e..fc113a6fc 100644
+--- a/nss/coreconf/config.gypi
++++ b/nss/coreconf/config.gypi
+@@ -102,6 +102,7 @@
+     'disable_dbm%': 1,
+     'disable_libpkix%': 1,
+     'disable_werror%': 0,
++    'disable_altivec': 1,
+     'mozilla_client%': 0,
+     'comm_client%': 0,
+     'moz_fold_libs%': 0,
+diff --git a/nss/coreconf/config.mk b/nss/coreconf/config.mk
+index 60a08411e..704e3fa83 100644
+--- a/nss/coreconf/config.mk
++++ b/nss/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/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..fc3e2099e 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -790,5 +790,7 @@ $(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
+ endif
++endif
+diff --git a/nss/lib/freebl/freebl.gyp b/nss/lib/freebl/freebl.gyp
+index 5d247742d..f968c408a 100644
+--- a/nss/lib/freebl/freebl.gyp
++++ b/nss/lib/freebl/freebl.gyp
+@@ -238,7 +238,7 @@
+             'gcm-aes-aarch64_c_lib',
+           ],
+         }],
+-        [ 'target_arch=="ppc64le"', {
++        [ 'disable_altivec==0 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
+           'dependencies': [
+             'gcm-aes-ppc_c_lib',
+           ],
+diff --git a/nss/lib/freebl/gcm.h b/nss/lib/freebl/gcm.h
+index aa4dee824..64aac56b2 100644
+--- a/nss/lib/freebl/gcm.h
++++ b/nss/lib/freebl/gcm.h
+@@ -30,6 +30,7 @@
+ #include <arm_neon.h>
+ #endif
+
++#ifndef NSS_DISABLE_ALTIVEC
+ #ifdef __powerpc64__
+ #include "altivec-types.h"
+
+@@ -39,6 +40,7 @@
+ #undef vector
+ #undef bool
+ #endif
++#endif
+
+ /*
+  * PPC CRYPTO requires at least gcc 8 or clang. The LE check is purely
+--
+2.20.1
+
package/libnss/libnss.mk +5 -0
index d7d3cda86b..b9dab44c11 100644
@@ -50,6 +50,11 @@ LIBNSS_BUILD_VARS = \
   	OS_TEST=$(BR2_PACKAGE_LIBNSS_ARCH) \
   	NSS_ENABLE_WERROR=0
 
+ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),)
+# Disable Altivec if not supported
+LIBNSS_BUILD_VARS += NSS_DISABLE_ALTIVEC=1
+endif
+
   ifeq ($(BR2_ARCH_IS_64),y)
   # MIPS64 n32 is treated as a 32-bit architecture by libnss.
   # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1010730
#10 lore raw

PATCH 1/1 package/libnss: fix ppc 32-bit build failure

In reply to Giulio Benetti

This patch is wrong. I reject it and going to send another one both upstream and to Buildroot ML.

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 55 lines · Giulio Benetti

NSS assumes that Altivec is supported on powerpc64 only, but in Makefile it tries to build gcm-ppc.c(containing Altivec functions calls), even if powerpc is not 64-bits. So add a patch to add a check if architecture is a 64-bit to build gcm-ppc.

Fixes:
http://autobuild.buildroot.net/results/433/433a7db21654d67626c7a3e5f1272d6c3ce4fe6c/

---
Pending upstream:
https://bugzilla.mozilla.org/show_bug.cgi?id=1606689

---
  ...1606689-Fix-ppc-32-bit-build-failure.patch | 31 +++++++++++++++++++
  1 file changed, 31 insertions(+)

create mode 100644 package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch

package/libnss/0006-Bug-1606689-Fix-ppc-32-bit-build-failure.patch new file +31 -0
new file mode 100644
index 0000000000..de30fa7002
@@ -0,0 +1,31 @@
+From fcac43d6a0af59926da7ad4a15a37255887cdfa2 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 2 Jan 2020 18:55:50 +0100
+Subject: [PATCH] Bug 1606689 - Fix ppc 32-bit build failure
+
+NSS assumes that only 64-bit powerpc support Altivec instructions to be
+used in gcm-ppc.c, so align Makefile condition to build gcm-ppc.c only
+if USE_64 is defined.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ nss/lib/freebl/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nss/lib/freebl/Makefile b/nss/lib/freebl/Makefile
+index 00518d7f8..0e230d8c5 100644
+--- a/nss/lib/freebl/Makefile
++++ b/nss/lib/freebl/Makefile
+@@ -264,8 +264,8 @@ ifeq ($(CPU_ARCH),arm)
+     MPI_SRCS += mpi_arm.c
+ endif
+ ifeq ($(CPU_ARCH),ppc)
+-    EXTRA_SRCS += gcm-ppc.c
+ ifdef USE_64
++    EXTRA_SRCS += gcm-ppc.c
+     DEFINES += -DNSS_NO_INIT_SUPPORT
+ endif # USE_64
+ endif # ppc
+--
+2.20.1
+