Closed Bug 1612177 Opened 4 years ago Closed 4 years ago

NEON support not enabled when building gcm-arm32-neon.c

Categories

(NSS :: Build, defect, P1)

3.51
ARM
FreeBSD
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mikael.urankar, Assigned: mikael.urankar)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached patch security_nss.patch (obsolete) — Splinter Review

User Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:72.0) Gecko/20100101 Firefox/72.0

Actual results:

The build fails on FreeBSD armv6:

cc -o
FreeBSD11.3_OPT.OBJ/FreeBSD_SINGLE_SHLIB/gcm-arm32-neon.o -c -std=c99
-O2 -pipe -I/usr/local/include/nspr -fstack-protector-strong
-fno-strict-aliasing -fPIC -Wall -Wno-switch -DFREEBSD -DHAVE_STRERROR
-DHAVE_BSD_FLOCK -Wall -Wshadow -Qunused-arguments
-Wno-parentheses-equality -Wno-array-bounds -Wno-unevaluated-expression
-Werror -DXP_UNIX -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT
-DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT
-DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES
-I./../dist/FreeBSD11.3_OPT.OBJ/include -I./../dist/public/
-I./../dist/private/ -fPIC -Wall -Wno-switch -DFREEBSD -DHAVE_STRERROR
-DHAVE_BSD_FLOCK -Wall -Wshadow -Qunused-arguments
-Wno-parentheses-equality -Wno-array-bounds -Wno-unevaluated-expression
-Werror -DXP_UNIX -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT
-DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT
-DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES
-I../../dist/FreeBSD11.3_OPT.OBJ/include -I../../dist/public/
-I../../dist/private/ -fPIC -Wall -Wno-switch -DFREEBSD
-DHAVE_STRERROR -DHAVE_BSD_FLOCK -Wall -Wshadow -Qunused-arguments
-Wno-parentheses-equality -Wno-array-bounds -Wno-unevaluated-expression
-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 -DFREEBL_LOWHASH
-DUSE_HW_AES -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
-DMP_USE_UINT_DIGIT -DSHA_NO_LONG_LONG -DKRML_NOUINT128
-DMP_API_COMPATIBLE -I../../../dist/FreeBSD11.3_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 -Qunused-arguments
-Wno-parentheses-equality -Wno-array-bounds -Wno-unevaluated-expression
-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 -DFREEBL_LOWHASH
-DUSE_HW_AES -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
-DMP_USE_UINT_DIGIT -DSHA_NO_LONG_LONG -DKRML_NOUINT128
-DMP_API_COMPATIBLE -I../../../dist/FreeBSD11.3_OPT.OBJ/include
-I../../../dist/public/nss -I../../../dist/private/nss -Impi -Iecl
-Iverified -mfpu=neon gcm-arm32-neon.c
In file included from gcm-arm32-neon.c:16:
/nxb-bin/usr/lib/clang/8.0.1/include/arm_neon.h:28:2: error: "NEON
support not enabled"
#error "NEON support not enabled"

cc -v
FreeBSD clang version 8.0.0 (tags/RELEASE_800/final 356365) (based on LLVM 8.0.0)
Target: armv6-unknown-freebsd11.3-gnueabihf

The attached patch fixes the build.

Attached patch nss.diffSplinter Review

Use correct patch

Attachment #9123545 - Attachment is obsolete: true
Attachment #9123546 - Flags: review?(kjacobs.bugzilla)

This isn't going to make 3.50, we'll have to take it in 3.51.

That said, does this work with gyp? Or do we need to fix the ordering for gyp builds, too?

Assignee: nobody → mikael.urankar
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P1
OS: Unspecified → FreeBSD
Hardware: Unspecified → ARM

Are there any instructions somewhere to build nss with gyp? I tried to instructions at https://wiki.mozilla.org/NSS/Build_System but it doesn't go very far:
bash build.sh -v
NSPR [1/5] configure ...
../configure --prefix=/usr/ports/security/nss/work/nss-3.49.2/dist/Debug
build.sh: line 36: ../configure: No such file or directory
Exit 127

Do you have nspr source code at the same level as nss? You might need to get the "NSS with NSPR" archive, or perhaps try the clone instructions at https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Building.

Apologies for the review delay - I'm looking into this now.

Edit: For the gyp build, you'll also need to install ninja-build and gyp.

Mikael, try building outside of ports e.g.,

$ pkg install git-cinnabar py27-gyp gmake ninja bash python
$ git clone hg::https://hg.mozilla.org/projects/nspr
$ git clone hg::https://hg.mozilla.org/projects/nss
$ cd nss
$ ./build.sh -v
FAILED: obj/lib/freebl/gcm-aes-arm32-neon_c_lib.gcm-arm32-neon.o
cc -MMD -MF obj/lib/freebl/gcm-aes-arm32-neon_c_lib.gcm-arm32-neon.o.d '-DSHLIB_SUFFIX="so"' '-DSHLIB_PREFIX="lib"' '-DSHLIB_VERSION="3"' '-DSOFTOKEN_SHLIB_VERSION="3"' -DRIJNDAEL_INCLUDE_TABLES -DMP_API_COMPATIBLE -DKRML_VERIFIED_UINT128 -DNSS_FIPS_DISABLED -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -DFREEBSD -DHAVE_BSD_FLOCK -DHAVE_STRERROR -DXP_UNIX -D_REENTRANT -DNSS_DISABLE_DBM -DNSS_DISABLE_LIBPKIX -DDEBUG -I../../lib/freebl/mpi -I../../lib/freebl/ecl -I../../lib/freebl/verified -I../../lib/freebl/verified/kremlin/include -I../../lib/freebl/verified/kremlin/kremlib/dist/minimal -I/tmp/dist/Debug/include/nspr -I/tmp/dist/private/nss -I/tmp/dist/public/nss -mfpu=neon -fPIC -pipe -ffunction-sections -fdata-sections -Werror -Wall -Wno-array-bounds -Wno-unevaluated-expression -Wno-parentheses-equality -Qunused-arguments -Wshadow -O0 -g -gdwarf-2 -std=c99  -c ../../lib/freebl/gcm-arm32-neon.c -o obj/lib/freebl/gcm-aes-arm32-neon_c_lib.gcm-arm32-neon.o
In file included from ../../lib/freebl/gcm-arm32-neon.c:16:
/nxb-bin/usr/lib/clang/8.0.1/include/arm_neon.h:28:2: error: "NEON support not enabled"
#error "NEON support not enabled"
 ^
1 error generated.
Comment on attachment 9123546 [details] [diff] [review]
nss.diff

This seems to be the same approach as used in [1], [2], with the notable exception of using `-march=armv7` instead of `-march=armv7-a`, but those are likely equivalent for these purposes. The Gyp change would go around ~[3], if you can verify and add that to the patch. Unfortunately I don't have any armv6 machine to test on. 

Requesting changes for the gyp addition only. Also, I assume you'd like your name on the patch? Let me know if not. 

Thanks!

[1] https://lore.kernel.org/lkml/20181215212304.19390-1-natechancellor@gmail.com/
[2] https://patchwork.kernel.org/patch/8352311/
[3] https://searchfox.org/mozilla-central/source/security/nss/lib/freebl/freebl.gyp#161
Flags: needinfo?(mikael.urankar)
Attachment #9123546 - Flags: review?(kjacobs.bugzilla) → review-
Attached patch nss.diffSplinter Review

nss builds fine with gyp on FreeBSD/armv6 with the attached patch.
I'm not opposed to have my name in the patch.

Thanks everyone!

Flags: needinfo?(mikael.urankar)
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Version: 3.49 → 3.51

IMHO forcing to build with -march=armv7 doesn't mean it will work correctly on armv6 or in general on any arm32.
Here the problem is that NEON extension is not supported and I've provided this patch:
https://bugzilla.mozilla.org/show_bug.cgi?id=1620799
to disable NEON extension on gcm-arm32.
So I've sent a patch to remove -march=armv7 instead:
https://bugzilla.mozilla.org/show_bug.cgi?id=1624864

Regressions: 1624864
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: