0

The freebl library in NSS fails to build properly (as a part of Firefox) due to emmintrin.h header from Clang 3.7 throwing errors that I'd assume were due to a missing -msse2 flag. Even with this flag, the source file that calls this header fails.

14:08.94 d:/gecko-dev-release/security/nss/lib/freebl/intel-gcm-wrap.c(123,78) :
  error(clang): passing 'int' to parameter of incompatible type '__m128i' (vecto
r of 2 'long long' values)
14:08.94     _mm_storeu_si128((__m128i*)gcm->CTR, _mm_shuffle_epi8(_mm_add_epi32
(ONE, _mm_shuffle_epi8(_mm_loadu_si128((__m128i*)gcm->CTR), BSWAP_MASK)), BSWAP_
MASK));
14:08.94
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14:08.94 c:\Program Files\LLVM\bin\..\lib\clang\3.7.0\include\emmintrin.h(630,36
) :  note(clang): passing argument to parameter '__b' here
14:08.94 _mm_add_epi32(__m128i __a, __m128i __b)
14:08.94                                    ^
14:08.94 1 error generated.
14:08.96 intel-gcm-wrap.c
14:08.99 d:/gecko-dev-release/security/nss/lib/freebl/intel-gcm-wrap.c(123) : er
ror C2164: '_mm_shuffle_epi8' : intrinsic function not declared
14:08.99 d:/gecko-dev-release/security/nss/lib/freebl/intel-gcm-wrap.c(123) : er
ror C2284: '_mm_shuffle_epi8': illegal argument to intrinsic function, parameter
 1
14:08.99 d:/gecko-dev-release/security/nss/lib/freebl/intel-gcm-wrap.c(123) : er
ror C2284: '_mm_shuffle_epi8': illegal argument to intrinsic function, parameter
 2
14:08.99 d:/gecko-dev-release/security/nss/lib/freebl/intel-gcm-wrap.c(123) : er
ror C2440: 'function' : cannot convert from '' to '__m128i'
14:08.99 clang-cl.exe: error: clang frontend command failed with exit code 2 (us
e -v to see invocation)
14:09.00 ../../coreconf/rules.mk:384: recipe for target 'd:/gecko-dev-release/ob
jdir/security/nss/lib/freebl/intel-gcm-wrap.obj' failed
14:09.00 mozmake.EXE[7]: *** [d:/gecko-dev-release/objdir/security/nss/lib/freeb
l/intel-gcm-wrap.obj] Error 2
14:09.00 Makefile:568: recipe for target 'libs' failed
14:09.00 mozmake.EXE[6]: *** [libs] Error 2
14:09.00 Makefile:468: recipe for target 'libs-nss/lib/freebl' failed
14:09.00 mozmake.EXE[5]: *** [libs-nss/lib/freebl] Error 2
14:09.00 mozmake.EXE[5]: *** Waiting for unfinished jobs....
14:11.30 d:/gecko-dev-release/config/recurse.mk:74: recipe for target 'config/ex
ternal/nss/target' failed
14:11.30 mozmake.EXE[4]: *** [config/external/nss/target] Error 2
14:11.30 d:/gecko-dev-release/config/recurse.mk:36: recipe for target 'compile'
failed
14:11.30 mozmake.EXE[3]: *** [compile] Error 2
14:11.30 d:/gecko-dev-release/config/rules.mk:541: recipe for target 'default' f
ailed
14:11.30 mozmake.EXE[2]: *** [default] Error 2
14:11.30 d:/gecko-dev-release/client.mk:400: recipe for target 'realbuild' faile
d
14:11.30 mozmake.EXE[1]: *** [realbuild] Error 2
14:11.31 client.mk:171: recipe for target 'build' failed
14:11.31 mozmake.EXE: *** [build] Error 2
14:11.36 0 compiler warnings present.

You can browse the source directory here.

SRG3006
  • 447
  • 8
  • 21

1 Answers1

0

According to the clang internals manual:

__extension__: The expression form of this extension causes any evaluatable subexpression to be accepted as an integer constant expression.

If we take a look at the current definition that clang has for _mm_suffle_epi32 it becomes clear that this is described above as an "integer constant expression"s.

Looking through the history for that function-like macro, it seems it was modified to use the __extension__ keyword in order to "Fix vector macros to correctly check argument types", and then that change was over time virtually rolled back as you can see from the current definition.

In summary, it seems like this is a Clang library error. _mm_shuffle_epi32 isn't the most documented feature on the planet, but the research I turned up implied that it should result in an __mm128i. Perhaps, if they wish to correctly check argument types, they should declare this as a [inlined?] function, rather than a macro?

When I tried to engage in a discussion about this on various IRC channels, nobody responded, so... I thought I'd just put this here for you as an answer to your question, because it's too lengthy for a comment.

autistic
  • 1
  • 3
  • 35
  • 80