From dae01d056d433ab9b0aa6dd95bd73655345c4b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Ch=C3=A9ron?= Date: Fri, 6 Mar 2020 06:43:32 +0100 Subject: [PATCH] AES-NI with per-file target compiler options --- cbits/aes/x86ni.c | 7 +++++++ cryptonite.cabal | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cbits/aes/x86ni.c b/cbits/aes/x86ni.c index 590a897..f51b32d 100644 --- a/cbits/aes/x86ni.c +++ b/cbits/aes/x86ni.c @@ -30,6 +30,10 @@ #ifdef WITH_AESNI +#pragma GCC push_options +#pragma GCC target("ssse3", "aes") +#pragma clang attribute push (__attribute__((target("ssse3,aes"))), apply_to=function) + #include #include #include @@ -400,4 +404,7 @@ static inline __m128i ghash_add(__m128i tag, const table_4bit htable, __m128i m) #endif +#pragma clang attribute pop +#pragma GCC pop_options + #endif diff --git a/cryptonite.cabal b/cryptonite.cabal index 68cb78f..d0c51db 100644 --- a/cryptonite.cabal +++ b/cryptonite.cabal @@ -336,7 +336,7 @@ Library c-sources: cbits/cryptonite_rdrand.c if flag(support_aesni) && (os(linux) || os(freebsd) || os(osx)) && (arch(i386) || arch(x86_64)) - CC-options: -mssse3 -maes -DWITH_AESNI + CC-options: -DWITH_AESNI if flag(support_pclmuldq) CC-options: -msse4.1 -mpclmul -DWITH_PCLMUL C-sources: cbits/aes/x86ni.c