mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 10:05:05 -07:00
Use SIMD-specific compiler flags only for files needing them
This commit is contained in:
parent
d4ff80e7a0
commit
f267352eec
37
configure.ac
37
configure.ac
@ -271,7 +271,8 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
#include <mmintrin.h>
|
||||
]], [[ __m64 x = _mm_setzero_si64(); ]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_MMINTRIN_H], [1], [mmx is available])],
|
||||
AC_DEFINE([HAVE_MMINTRIN_H], [1], [mmx is available])
|
||||
AX_CHECK_COMPILE_FLAG([-mmmx], [CFLAGS_MMX="-mmmx"])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING(for SSE2 instructions set)
|
||||
@ -283,7 +284,8 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
#include <emmintrin.h>
|
||||
]], [[ __m128d x = _mm_setzero_pd(); ]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_EMMINTRIN_H], [1], [sse2 is available])],
|
||||
AC_DEFINE([HAVE_EMMINTRIN_H], [1], [sse2 is available])
|
||||
AX_CHECK_COMPILE_FLAG([-msse2], [CFLAGS_SSE2="-msse2"])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING(for SSE3 instructions set)
|
||||
@ -296,7 +298,8 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
]], [[ __m128 x = _mm_addsub_ps(_mm_cvtpd_ps(_mm_setzero_pd()),
|
||||
_mm_cvtpd_ps(_mm_setzero_pd())); ]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_PMMINTRIN_H], [1], [sse3 is available])],
|
||||
AC_DEFINE([HAVE_PMMINTRIN_H], [1], [sse3 is available])
|
||||
AX_CHECK_COMPILE_FLAG([-msse3], [CFLAGS_SSE3="-msse3"])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING(for SSSE3 instructions set)
|
||||
@ -308,7 +311,21 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
#include <tmmintrin.h>
|
||||
]], [[ __m64 x = _mm_abs_pi32(_m_from_int(0)); ]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_TMMINTRIN_H], [1], [ssse3 is available])],
|
||||
AC_DEFINE([HAVE_TMMINTRIN_H], [1], [ssse3 is available])
|
||||
AX_CHECK_COMPILE_FLAG([-mssse3], [CFLAGS_SSSE3="-mssse3"])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING(for SSE4.1 instructions set)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#pragma GCC target("sse4.1")
|
||||
#ifndef __SSE4_1__
|
||||
# define __SSE4_1__
|
||||
#endif
|
||||
#include <smmintrin.h>
|
||||
]], [[ __m128i x = _mm_minpos_epu16(_mm_setzero_si128()); ]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_SMMINTRIN_H], [1], [sse4.1 is available])
|
||||
AX_CHECK_COMPILE_FLAG([-msse4.1], [CFLAGS_SSE4_1="-msse4.1"])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING(for AESNI instructions set and PCLMULQDQ)
|
||||
@ -326,12 +343,20 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
__m128i y = _mm_clmulepi64_si128(_mm_setzero_si128(), _mm_setzero_si128(), 0);]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_WMMINTRIN_H], [1], [aesni is available])
|
||||
AX_CHECK_COMPILE_FLAG([-maes], [CFLAGS="$CFLAGS -maes"])
|
||||
AX_CHECK_COMPILE_FLAG([-mpclmul], [CFLAGS="$CFLAGS -mpclmul"])
|
||||
AX_CHECK_COMPILE_FLAG([-maes], [CFLAGS_AESNI="-maes"])
|
||||
AX_CHECK_COMPILE_FLAG([-mpclmul], [CFLAGS_PCLMUL="-mpclmul"])
|
||||
],
|
||||
[AC_MSG_RESULT(no)])
|
||||
])
|
||||
|
||||
AC_SUBST(CFLAGS_MMX)
|
||||
AC_SUBST(CFLAGS_SSE2)
|
||||
AC_SUBST(CFLAGS_SSE3)
|
||||
AC_SUBST(CFLAGS_SSSE3)
|
||||
AC_SUBST(CFLAGS_SSE4_1)
|
||||
AC_SUBST(CFLAGS_AESNI)
|
||||
AC_SUBST(CFLAGS_PCLMUL)
|
||||
|
||||
AC_CHECK_HEADERS([sys/mman.h])
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
|
@ -2,7 +2,6 @@ lib_LTLIBRARIES = \
|
||||
libsodium.la
|
||||
|
||||
libsodium_la_SOURCES = \
|
||||
crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c \
|
||||
crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c \
|
||||
crypto_auth/crypto_auth.c \
|
||||
crypto_auth/hmacsha256/auth_hmacsha256_api.c \
|
||||
@ -63,7 +62,6 @@ libsodium_la_SOURCES = \
|
||||
crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c \
|
||||
crypto_pwhash/scryptsalsa208sha256/sysendian.h \
|
||||
crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
|
||||
crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \
|
||||
crypto_scalarmult/crypto_scalarmult.c \
|
||||
crypto_scalarmult/curve25519/scalarmult_curve25519_api.c \
|
||||
crypto_secretbox/crypto_secretbox.c \
|
||||
@ -269,3 +267,20 @@ endif
|
||||
|
||||
SUBDIRS = \
|
||||
include
|
||||
|
||||
libsodium_la_LIBADD = libaesni.la libsse2.la
|
||||
noinst_LTLIBRARIES = libaesni.la libsse2.la
|
||||
|
||||
libaesni_la_LDFLAGS = $(libsodium_la_LDFLAGS)
|
||||
libaesni_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \
|
||||
@CFLAGS_SSE4_1@ @CFLAGS_AESNI@ @CFLAGS_PCLMUL@
|
||||
|
||||
libaesni_la_SOURCES = \
|
||||
crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c
|
||||
|
||||
libsse2_la_LDFLAGS = $(libsodium_la_LDFLAGS)
|
||||
libsse2_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \
|
||||
@CFLAGS_SSE2@
|
||||
|
||||
libsse2_la_SOURCES = \
|
||||
crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
|
||||
|
@ -13,25 +13,10 @@
|
||||
|
||||
#ifdef HAVE_WMMINTRIN_H
|
||||
|
||||
#pragma GCC target("sse")
|
||||
#pragma GCC target("sse2")
|
||||
#pragma GCC target("ssse3")
|
||||
#pragma GCC target("sse4.1")
|
||||
#pragma GCC target("aes")
|
||||
#pragma GCC target("pclmul")
|
||||
|
||||
#ifndef __SSSE3__
|
||||
# define __SSSE3__
|
||||
#endif
|
||||
#ifndef __SSE4_1__
|
||||
# define __SSE4_1__
|
||||
#endif
|
||||
#ifndef __AES__
|
||||
# define __AES__
|
||||
#endif
|
||||
#ifndef __PCLMUL__
|
||||
# define __PCLMUL__
|
||||
#endif
|
||||
#include <immintrin.h>
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(_bswap64)
|
||||
|
Loading…
Reference in New Issue
Block a user