Closed Bug 1387779 Opened 3 years ago Closed 3 years ago

lib/freebl/gcm.c:314:13: error: '__builtin_ia32_pclmulqdq128' needs target feature pclmul

Categories

(NSS :: Libraries, defect)

Unspecified
FreeBSD
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jbeich, Assigned: franziskus)

References

Details

Attachments

(1 file)

$ c++ -v
FreeBSD clang version 5.0.0 (branches/release_50 309439) (based on LLVM 5.0.0svn)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

$ ./build.sh -c
NSPR [1/3] configure ...
NSPR [2/3] make ...
NSPR [3/3] install ...
ninja: Entering directory `/tmp/nss/out/Debug'
[439/1034] CC obj/lib/freebl/freebl3.gcm.o
FAILED: obj/lib/freebl/freebl3.gcm.o
cc -MMD -MF obj/lib/freebl/freebl3.gcm.o.d '-DSHLIB_SUFFIX="so"' '-DSHLIB_PREFIX="lib"' '-DSHLIB_VERSION="3"' '-DSOFTOKEN_SHLIB_VERSION="3"' -DRIJNDAEL_INCLUDE_TABLES -DMP_API_COMPATIBLE -DHAVE_INT128_SUPPORT -DNSS_X86_OR_X64 -DNSS_X64 -DNSS_USE_64 -DSEED_ONLY_DEV_URANDOM -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_LIBPKIX -DDEBUG -I../../lib/freebl/mpi -I../../lib/freebl/ecl -I/tmp/dist/Debug/include/nspr -I/tmp/dist/private/nss -I/tmp/dist/public/nss -fPIC -pipe -ffunction-sections -fdata-sections -m64 -Werror -Wall -Wno-array-bounds -Wno-unevaluated-expression -Wno-parentheses-equality -Qunused-arguments -O0 -g -gdwarf-2   -c ../../lib/freebl/gcm.c -o obj/lib/freebl/freebl3.gcm.o
../../lib/freebl/gcm.c:314:13: error: '__builtin_ia32_pclmulqdq128' needs target feature pclmul
        C = _mm_clmulepi64_si128(Ci, ghash->h, 0x00);
            ^
/usr/lib/clang/5.0.0/include/__wmmintrin_pclmul.h:54:13: note: expanded from macro '_mm_clmulepi64_si128'
  ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
            ^
../../lib/freebl/gcm.c:315:13: error: '__builtin_ia32_pclmulqdq128' needs target feature pclmul
        D = _mm_clmulepi64_si128(Ci, ghash->h, 0x11);
            ^
/usr/lib/clang/5.0.0/include/__wmmintrin_pclmul.h:54:13: note: expanded from macro '_mm_clmulepi64_si128'
  ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
            ^
../../lib/freebl/gcm.c:316:13: error: '__builtin_ia32_pclmulqdq128' needs target feature pclmul
        E = _mm_clmulepi64_si128(Ci, ghash->h, 0x01);
            ^
/usr/lib/clang/5.0.0/include/__wmmintrin_pclmul.h:54:13: note: expanded from macro '_mm_clmulepi64_si128'
  ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
            ^
../../lib/freebl/gcm.c:317:13: error: '__builtin_ia32_pclmulqdq128' needs target feature pclmul
        F = _mm_clmulepi64_si128(Ci, ghash->h, 0x10);
            ^
/usr/lib/clang/5.0.0/include/__wmmintrin_pclmul.h:54:13: note: expanded from macro '_mm_clmulepi64_si128'
  ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
            ^
4 errors generated.
[448/1034] CXX obj/gtests/freebl_gtest/prng_gtest.prng_kat_unittest.o
ninja: build stopped: subcommand failed.
lib/freebl/freebl.gyp is weird. It always passes -mpclmul -maes on x86* when building as part of Firefox but limits to Tier1 platforms when building standalone.

Why?
Flags: needinfo?(franziskuskiefer)
Firefox does clang-cl builds on Windows, which require these build flags. We don't do that for NSS yet. Hence we only need it on the other platforms and avoid warnings in MSVC. But I'm happy to add the flags for BSD.
Flags: needinfo?(franziskuskiefer)
Does this fix the issue?
Assignee: nobody → franziskuskiefer
Status: NEW → ASSIGNED
Attachment #8894443 - Flags: review?(ttaubert)
Attachment #8894443 - Flags: feedback?(jbeich)
Comment on attachment 8894443 [details] [diff] [review]
bsd-ni-build.patch

Thanks. It fixes my build.
Attachment #8894443 - Flags: feedback?(jbeich) → feedback+
Attachment #8894443 - Flags: review?(ttaubert) → review+
https://hg.mozilla.org/projects/nss/rev/7501558bfc1a0838ebe25ca21fbc188197c4dee5
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.33
Comment on attachment 8894443 [details] [diff] [review]
bsd-ni-build.patch

Review of attachment 8894443 [details] [diff] [review]:
-----------------------------------------------------------------

Just curious: what's the difference between cflags_mozilla and cflags?

It is strange that cflags_mozilla does not seem to be used by the BSDs,
which also require cflags. We should either fix this, or document this
subtlety with a comment.

::: lib/freebl/freebl.gyp
@@ +161,5 @@
>          ],
>        }],
> +      [ 'OS=="dragonfly" or OS=="freebsd" or OS=="netbsd" or OS=="openbsd"', {
> +        'cflags': [
> +          '-mpclmul',

This patch seems wrong because the -mpclmul flag is x86 and x86-64 specific:

https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/i386-and-x86-64-Options.html

Fortunately what is actually committed is different:

https://hg.mozilla.org/projects/nss/rev/7501558bfc1a0838ebe25ca21fbc188197c4dee5
cflags_mozilla are only for the NSS build as part of the Firefox build. The normal NSS build doesn't use them. This was carried over from the make build system to gyp. We might want to clean that up at some point.

>  -mpclmul flag is x86 and x86-64 specific
yep, I noticed before landing.
You need to log in before you can comment on or make changes to this bug.