haskell-crypto / cryptonite

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

AESNI and PCLMUL as per-function attributes #316

Closed ocheron closed 4 years ago

ocheron commented 4 years ago

In #314 was confirmed that flag support_aesni causes runtime failures in code not related to AES-NI with i386/amd64 processor not supporting SSSE3. This comes from the use of option -mssse3 at compile time, enabled for all C source files.

The PR adds an optional package flag to use instead function attributes, enabling the necessary target options where necessary, which means only in parts of the code protected with runtime CPU detection. The flag can be enabled in distributions when wanting broad CPU support and knowing the C compiler is compatible.

Mechanism known to be supported with:

Related to:

ocheron commented 4 years ago

Flag is enabled by default.

Version requirement with GCC is not high.

For clang the requirement is similar to LLVM version for GHC itself. According to this table most impacted users would be OS X 10.10 Yosemite with Xcode 6, but Xcode 7 is also available: https://trac.macports.org/wiki/XcodeVersionInfo