On Wed, 25 Dec 2019 23:22:44 +0100
Jeremie Courreges-Anglas wrote:

> On Wed, Dec 25 2019, Charlene Wendling <[email protected]> wrote:
> > Hi, 
> >
> > As seen in the current powerpc bulk, nss is broken because we don't
> > implement getauxval(3):
> >
> >> blinit.c:360:22: error: sys/auxv.h: No such file or directory
> >
> > It has already been reported upstream [1], but `__has_include()'
> > is a GCC>=5 feature [2], and i didn't feel like imposing the use of
> > ports-gcc to other archs, so i adapted it to keep it built with
> > base-gcc.
> 
> In this file there's already fallback code in case __has_include and
> getauxval aren't available.  The result is still a bit of a mess but
> I think there's a chance to push it upstream.
> 
> Could you please give it a try?

Nice catch, it works fine once a missing semi-colon is added, thanks!

Charlène.


Index: patches/patch-nss_lib_freebl_blinit_c
===================================================================
RCS file: patches/patch-nss_lib_freebl_blinit_c
diff -N patches/patch-nss_lib_freebl_blinit_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-nss_lib_freebl_blinit_c       26 Dec 2019 18:41:48 -0000
@@ -0,0 +1,48 @@
+$OpenBSD$
+
+Work around lack of <sys/auxv.h> and getauxval().
+
+Index: nss/lib/freebl/blinit.c
+--- nss/lib/freebl/blinit.c.orig
++++ nss/lib/freebl/blinit.c
+@@ -93,7 +93,7 @@ CheckX86CPUSupport()
+ #endif /* NSS_X86_OR_X64 */
+ 
+ /* clang-format off */
+-#if defined(__aarch64__) || defined(__arm__)
++#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
+ #ifndef __has_include
+ #define __has_include(x) 0
+ #endif
+@@ -115,7 +115,7 @@ static unsigned long (*getauxval)(unsigned long) = NUL
+ #define AT_HWCAP 16
+ #endif
+ 
+-#endif /* defined(__aarch64__) || defined(__arm__) */
++#endif /* defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) */
+ /* clang-format on */
+ 
+ #if defined(__aarch64__)
+@@ -357,7 +357,9 @@ ppc_crypto_support()
+ 
+ #if defined(__powerpc__)
+ 
++#if __has_include(<sys/auxv.h>)
+ #include <sys/auxv.h>
++#endif
+ 
+ // Defines from cputable.h in Linux kernel - PPC, letting us build on older 
kernels
+ #ifndef PPC_FEATURE2_VEC_CRYPTO
+@@ -368,8 +370,11 @@ static void
+ CheckPPCSupport()
+ {
+     char *disable_hw_crypto = PR_GetEnvSecure("NSS_DISABLE_PPC_GHASH");
++    long hwcaps = 0;
+ 
+-    long hwcaps = getauxval(AT_HWCAP2);
++    if (getauxval) {
++        hwcaps = getauxval(AT_HWCAP2);
++    }
+ 
+     ppc_crypto_support_ = hwcaps & PPC_FEATURE2_VEC_CRYPTO && 
disable_hw_crypto == NULL;
+ }

Reply via email to