Fix build on FreeBSD/powerpc*
Categories
(NSS :: Build, defect)
Tracking
(Not tracked)
People
(Reporter: pkubaj, Unassigned, NeedInfo)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file, 1 obsolete file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Steps to reproduce:
On FreeBSD/powerpc64 box:
- portsnap fetch extract
- make -C /usr/ports/security/nss install clean
Actual results:
blinit.c:417:27: error: use of undeclared identifier 'hwcaps'
ppc_crypto_support_ = hwcaps & PPC_FEATURE2_VEC_CRYPTO && disable_hw_crypto == NULL;
^
1 error generated.
Expected results:
NSS should install.
Reporter | ||
Comment 1•5 years ago
|
||
I copied from a wrong window, the actual error is:
blinit.c:410:19: error: implicit declaration of function 'getauxval' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
long hwcaps = getauxval(AT_HWCAP2);
^
Updated•5 years ago
|
Updated•5 years ago
|
Comment 2•5 years ago
•
|
||
Reporter | ||
Comment 4•5 years ago
|
||
FreeBSD has elf_aux_info instead of getauxval, but only since FreeBSD 12. Previous versions (11 is still supported) don't have any equivalent and users need to query sysctl manually.
Comment hidden (obsolete) |
Comment hidden (obsolete) |
Comment hidden (obsolete) |
Comment hidden (obsolete) |
Updated•5 years ago
|
Comment on attachment 9115139 [details]
Fix build on FreeBSD/powerpc platforms.
ifeq ($(CPU_ARCH),ppc) -$(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec +$(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
gcm.c and rijndael.c dispatch into SIMD only when CPU supports it. Building them with -maltivec
may lead to a crash on older CPUs. There's probably a better way...
Can you show more context of the error e.g., command line used to build gcm-ppc.c that failed? I can't reproduce when using #include
e.g.,
$ ssh ref12-ppc64.freebsd.org
$ cat a.c
#include "altivec-types.h"
vec_u64 foo(void) { }
$ gcc8 -maltivec -c a.c
$ echo $?
0
$ gcc8 -maltivec -c altivec-types.h
altivec-types.h:19:1: error: use of 'long long' in AltiVec types is invalid without '-mvsx'
typedef __vector unsigned long long vec_u64;
^~~~~~~
altivec-types.h:20:1: error: use of 'long long' in AltiVec types is invalid without '-mvsx'
typedef __vector signed long long vec_s64;
^~~~~~~
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 10•5 years ago
|
||
Error for gcm.c:
gcc9 -o FreeBSD12.1_OPT.OBJ/FreeBSD_SINGLE_SHLIB/gcm.o -c -std=c99 -O2 -pipe -I/usr/local/include/nspr -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc9 -fno-strict-aliasing
-fPIC -Wall -Wno-switch -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK -Wall -Wshadow -Werror -DXP_UNIX -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIR
ECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -I./../dist/FreeBSD12.1_OPT.OBJ/include -I./../dist/public/ -I./../dist/private/ -fPIC -Wall -Wno-switch -DFR
EEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK -Wall -Wshadow -Werror -DXP_UNIX -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -D
SSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -I../../dist/FreeBSD12.1_OPT.OBJ/include -I../../dist/public/ -I../../dist/private/ -fPIC -Wall -Wno-switch -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK -Wall -Wshadow -Werror -DXP_UNIX -DSHLIB_SUFFIX="so" -DSHLIB_PREFIX="lib" -DSHLIB_VERSION="3" -DSOFTOKEN_SHLIB_VERSION="3" -DRIJNDAEL_INCLUDE_TABLES -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -DNSS_USE_64 -DFREEBL_LOWHASH -DNSS_NO_INIT_SUPPORT -DHAVE_INT128_SUPPORT -DMP_API_COMPATIBLE -I../../../dist/FreeBSD12.1_OPT.OBJ/include -I../../../dist/public/nss -I../../../dist/private/nss -Impi -Iecl -Iverified -fPIC
-Wall -Wno-switch -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK -Wall -Wshadow -Werror -DXP_UNIX -DSHLIB_SUFFIX="so" -DSHLIB_PREFIX="lib" -DSHLIB_VERSION="3" -DSOFTOKEN_SHLIB_VERSION="3" -DRIJNDAEL_INCLUDE_TABLES -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -DNSS_USE_64 -DFREEBL_LOWHASH -DNSS_NO_INIT_SUPPORT -DHAVE_INT128_SUPPORT -DMP_API_COMPATIBLE -I../../../dist/FreeBSD12.1_OPT.OBJ/include -I../../../dist/public/nss -I../../../dist/private/nss -Impi -Iecl -Iverified gcm.c
In file included from altivec-types.h:11,
from gcm.h:34,
from gcm.c:12:
/usr/local/lib/gcc9/gcc/powerpc64-portbld-freebsd12.1/9.2.0/include/altivec.h:34:2: error: #error Use the "-maltivec" flag to enable PowerPC AltiVec support
34 | #error Use the "-maltivec" flag to enable PowerPC AltiVec support
| ^~~~~
In file included from gcm.h:34,
from gcm.c:12:
altivec-types.h:19:1: error: use of 'long long' in AltiVec types is invalid without '-mvsx'
19 | typedef __vector unsigned long long vec_u64;
| ^~~~~~~
altivec-types.h:20:1: error: use of 'long long' in AltiVec types is invalid without '-mvsx'
20 | typedef __vector signed long long vec_s64;
| ^~~~~~~
Note that it's actually a bit inaccurate, adding -mvsx alone is actually enough (VSX probably implies AltiVec).
Comment 11•5 years ago
|
||
Piotr, can you try enabling #define USE_PPC_CRYPTO
from lib/freebl/gcm.h on big-endian then test build and runtime on FreeBSD powerpc64? -mcrypto -maltivec
only need to be passed if USE_PPC_CRYPTO
is set.
Comment 13•5 years ago
|
||
I've posted a couple of questions in the Phabricator review, but I do want to get this PPC fix into tree.
Comment 14•5 years ago
|
||
(In reply to Piotr Kubaj from comment #10)
In file included from altivec-types.h:11,
from gcm.h:34,
from gcm.c:12:
/usr/local/lib/gcc9/gcc/powerpc64-portbld-freebsd12.1/9.2.0/include/altivec.h:34:2: error: #error Use the "-maltivec" flag to enable PowerPC AltiVec support
Try pragma target
(a la sse2
in the same file) then revert lib/freebl/Makefile changes.
#pragma GCC push_options
#pragma GCC target("altivec")
#include "altivec-types.h"
#pragma GCC pop_options
Clang has attribute
pragma but it doesn't seem to work with headers. Maybe Clang should port https://github.com/llvm/llvm-project/commit/9fc7fb274e53 to <altivec.h>
instead.
Comment 15•5 years ago
|
||
Just to reiterate, I'm happy to accept a patch, via any means!
Comment 16•5 years ago
|
||
Comment 17•5 years ago
|
||
Description
•