haskell-crypto / cryptonite

lowlevel set of cryptographic primitives for haskell
Other
226 stars 139 forks source link

Remove UNROLL macro. #352

Closed villesokk closed 1 year ago

villesokk commented 3 years ago

When compiling cryptonite on macOS Big Sur with an M1 Mac (Apple clang version 12.0.5) I get errors such as this:

cbits/decaf/p448/f_generic.c:56:8: error:
     warning: loop not unrolled: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning]
   |
56 | mask_t cryptonite_gf_deserialize (gf x, const uint8_t serial[SER_BYTES], int with_hibit) {
   |        ^

cbits/decaf/p448/f_field.h:54:38: error:
     note: expanded from macro 'cryptonite_gf_deserialize'
   |
54 | #define cryptonite_gf_deserialize    cryptonite_gf_448_deserialize
   |                                      ^
#define cryptonite_gf_deserialize    cryptonite_gf_448_deserialize

Looking at the definition of the UNROLL macro it seems that it's only defined for clang:

#ifdef __clang__
#if 100*__clang_major__ + __clang_minor__ > 305
#define UNROLL _Pragma("clang loop unroll(full)")
#endif
#endif

#ifndef UNROLL
#define UNROLL
#endif

If it never worked on GCC anyway and doesn't work with clang >= 12 it probably doesn't improve performance so I removed the UNROLL macro in the decaf code. Another option would be to use the -Wpass-failed=transform-warning compiler flag as suggested by the error message.

arrowd commented 2 years ago

What's preventing this from being merged? This PR should fix a build problem on FreeBSD.

vincenthz commented 1 year ago

archiving repository