4 --enable-silent-rules less verbose build output (undo: "make V=1") speeds up one-time build
5 --disable-ssp Do not compile with -fstack-protector
6 --disable-asm Do not compile assembly code -- This disables all (including non-assembly) platform-specific optimizations on Unix systems
7 --disable-pie Do not produce position independent executables
8 --disable-blocking-random Enable this switch only if /dev/urandom is totally broken on the target platform
9 --disable-minimal Only compile the minimum set of functions required for the high-level API
10 --disable-debug For maintainers only - please do not use
11 --disable-opt Optimize for the native CPU - The resulting library will be faster but not portable
12 --disable-valgrind Whether to enable Valgrind on the unit tests (requires GNU make)
13 --disable-valgrind-memcheck Whether to skip memcheck during the Valgrind tests
14 --disable-valgrind-helgrind Whether to skip helgrind during the Valgrind tests
15 --disable-valgrind-drd Whether to skip drd during the Valgrind tests
16 --disable-valgrind-sgcheck Whether to skip sgcheck during the Valgrind tests
17 --enable-soname-versions enable soname versions (must be disabled for Android) (default: enabled)
18 --disable-shared build shared libraries [default=yes]
19 --enable-static build static libraries [default=yes]
20 # --enable-fast-install[=PKGS] optimize for fast installation [default=yes]
21 # --disable-libtool-lock avoid locking (might break parallel builds)
23 # --with-pthreads use pthreads library, or --without-pthreads to disable threading support.
24 # --with-safecode For maintainers only - please do not use
25 # --with-ctgrind For maintainers only - please do not use
26 --without-pic try to use only PIC/non-PIC objects [default=use both]
27 # --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix].
28 # --with-gnu-ld assume the C compiler uses GNU ld [default=no]
29 # --with-sysroot[=DIR] Search for dependent libraries within DIR (or the
33 if test ! -x configure; then
40 diff --git a/configure.ac b/configure.ac
41 index fb579f4f..2ed423d9 100644
44 @@ -358,8 +358,7 @@ AS_IF([test "x$EMSCRIPTEN" = "x" -a "$host_os" != "pnacl"], [
45 AX_CHECK_COMPILE_FLAG([-mmmx], [CFLAGS="$CFLAGS -mmmx"])
46 AC_MSG_CHECKING(for MMX instructions set)
47 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
48 -#pragma GCC target("mmx")
49 -#include <mmintrin.h>
50 +#include <mmintrinx.h>
51 ]], [[ __m64 x = _mm_setzero_si64(); ]])],
53 AC_DEFINE([HAVE_MMINTRIN_H], [1], [mmx is available])
54 @@ -371,84 +370,78 @@ AS_IF([test "x$EMSCRIPTEN" = "x" -a "$host_os" != "pnacl"], [
55 AX_CHECK_COMPILE_FLAG([-msse2], [CFLAGS="$CFLAGS -msse2"])
56 AC_MSG_CHECKING(for SSE2 instructions set)
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
58 -#pragma GCC target("sse2")
64 -#include <emmintrin.h>
65 +#include <emmintrinx.h>
66 ]], [[ __m128d x = _mm_setzero_pd();
67 __m128i z = _mm_srli_epi64(_mm_setzero_si128(), 26); ]])],
69 AC_DEFINE([HAVE_EMMINTRIN_H], [1], [sse2 is available])
70 - AX_CHECK_COMPILE_FLAG([-msse2], [CFLAGS_SSE2="-msse2"])],
71 + AX_CHECK_COMPILE_FLAG([-msse2], [CFLAGS_SSE2=""])],
76 - AX_CHECK_COMPILE_FLAG([-msse3], [CFLAGS="$CFLAGS -msse3"])
77 + AX_CHECK_COMPILE_FLAG([-msse3], [CFLAGS="$CFLAGS"])
78 AC_MSG_CHECKING(for SSE3 instructions set)
79 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
80 -#pragma GCC target("sse3")
81 -#include <pmmintrin.h>
82 +#include <pmmintrinx.h>
83 ]], [[ __m128 x = _mm_addsub_ps(_mm_cvtpd_ps(_mm_setzero_pd()),
84 _mm_cvtpd_ps(_mm_setzero_pd())); ]])],
86 AC_DEFINE([HAVE_PMMINTRIN_H], [1], [sse3 is available])
87 - AX_CHECK_COMPILE_FLAG([-msse3], [CFLAGS_SSE3="-msse3"])],
88 + AX_CHECK_COMPILE_FLAG([-msse3], [CFLAGS_SSE3=""])],
93 - AX_CHECK_COMPILE_FLAG([-mssse3], [CFLAGS="$CFLAGS -mssse3"])
94 + AX_CHECK_COMPILE_FLAG([-mssse3], [CFLAGS="$CFLAGS"])
95 AC_MSG_CHECKING(for SSSE3 instructions set)
96 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
97 -#pragma GCC target("ssse3")
98 -#include <tmmintrin.h>
99 +#include <tmmintrinx.h>
100 ]], [[ __m64 x = _mm_abs_pi32(_m_from_int(0)); ]])],
102 AC_DEFINE([HAVE_TMMINTRIN_H], [1], [ssse3 is available])
103 - AX_CHECK_COMPILE_FLAG([-mssse3], [CFLAGS_SSSE3="-mssse3"])],
104 + AX_CHECK_COMPILE_FLAG([-mssse3], [CFLAGS_SSSE3=""])],
109 - AX_CHECK_COMPILE_FLAG([-msse4.1], [CFLAGS="$CFLAGS -msse4.1"])
110 + AX_CHECK_COMPILE_FLAG([-msse4.1], [CFLAGS="$CFLAGS"])
111 AC_MSG_CHECKING(for SSE4.1 instructions set)
112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
113 -#pragma GCC target("sse4.1")
114 -#include <smmintrin.h>
115 +#include <smmintrinx.h>
116 ]], [[ __m128i x = _mm_minpos_epu16(_mm_setzero_si128()); ]])],
118 AC_DEFINE([HAVE_SMMINTRIN_H], [1], [sse4.1 is available])
119 - AX_CHECK_COMPILE_FLAG([-msse4.1], [CFLAGS_SSE41="-msse4.1"])],
120 + AX_CHECK_COMPILE_FLAG([-msse4.1], [CFLAGS_SSE41=""])],
125 - AX_CHECK_COMPILE_FLAG([-mavx], [CFLAGS="$CFLAGS -mavx"])
126 + AX_CHECK_COMPILE_FLAG([-mavx], [CFLAGS="$CFLAGS"])
127 AC_MSG_CHECKING(for AVX instructions set)
128 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
129 #ifdef __native_client__
130 # error NativeClient detected - Avoiding AVX opcodes
132 -#pragma GCC target("avx")
133 -#include <immintrin.h>
134 +#include <immintrinx.h>
135 ]], [[ _mm256_zeroall(); ]])],
137 AC_DEFINE([HAVE_AVXINTRIN_H], [1], [AVX is available])
138 - AX_CHECK_COMPILE_FLAG([-mavx], [CFLAGS_AVX="-mavx"])],
139 + AX_CHECK_COMPILE_FLAG([-mavx], [CFLAGS_AVX=""])],
144 - AX_CHECK_COMPILE_FLAG([-mavx2], [CFLAGS="$CFLAGS -mavx2"])
145 + AX_CHECK_COMPILE_FLAG([-mavx2], [CFLAGS="$CFLAGS"])
146 AC_MSG_CHECKING(for AVX2 instructions set)
147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
148 #ifdef __native_client__
149 # error NativeClient detected - Avoiding AVX2 opcodes
151 -#pragma GCC target("avx2")
152 -#include <immintrin.h>
153 +#include <immintrinx.h>
155 __m256 x = _mm256_set1_ps(3.14);
156 __m256 y = _mm256_permutevar8x32_ps(x, _mm256_set1_epi32(42));
157 @@ -456,14 +449,13 @@ return _mm256_movemask_ps(_mm256_cmp_ps(x, y, _CMP_NEQ_OQ));
160 AC_DEFINE([HAVE_AVX2INTRIN_H], [1], [AVX2 is available])
161 - AX_CHECK_COMPILE_FLAG([-mavx2], [CFLAGS_AVX2="-mavx2"])
162 + AX_CHECK_COMPILE_FLAG([-mavx2], [CFLAGS_AVX2=""])
163 AC_MSG_CHECKING(if _mm256_broadcastsi128_si256 is correctly defined)
164 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
165 #ifdef __native_client__
166 # error NativeClient detected - Avoiding AVX2 opcodes
168 -#pragma GCC target("avx2")
169 -#include <immintrin.h>
170 +#include <immintrinx.h>
171 ]], [[ __m256i y = _mm256_broadcastsi128_si256(_mm_setzero_si128()); ]])],
172 [AC_MSG_RESULT(yes)],
174 @@ -480,8 +472,7 @@ return _mm256_movemask_ps(_mm256_cmp_ps(x, y, _CMP_NEQ_OQ));
175 #ifdef __native_client__
176 # error NativeClient detected - Avoiding AVX512F opcodes
178 -#pragma GCC target("avx512f")
179 -#include <immintrin.h>
180 +#include <immintrinx.h>
182 __m512i x = _mm512_setzero_epi32();
183 __m512i y = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), x);
184 @@ -500,32 +491,29 @@ __m512i y = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7),
185 #ifdef __native_client__
186 # error NativeClient detected - Avoiding AESNI opcodes
188 -#pragma GCC target("aes")
189 -#pragma GCC target("pclmul")
190 -#include <wmmintrin.h>
191 +#include <wmmintrinx.h>
192 ]], [[ __m128i x = _mm_aesimc_si128(_mm_setzero_si128());
193 __m128i y = _mm_clmulepi64_si128(_mm_setzero_si128(), _mm_setzero_si128(), 0);]])],
195 AC_DEFINE([HAVE_WMMINTRIN_H], [1], [aesni is available])
196 - AX_CHECK_COMPILE_FLAG([-maes], [CFLAGS_AESNI="-maes"])
197 - AX_CHECK_COMPILE_FLAG([-mpclmul], [CFLAGS_PCLMUL="-mpclmul"])
198 + AX_CHECK_COMPILE_FLAG([-maes], [CFLAGS_AESNI=""])
199 + AX_CHECK_COMPILE_FLAG([-mpclmul], [CFLAGS_PCLMUL=""])
205 - AX_CHECK_COMPILE_FLAG([-mrdrnd], [CFLAGS="$CFLAGS -mrdrnd"])
206 + AX_CHECK_COMPILE_FLAG([-mrdrnd], [CFLAGS="$CFLAGS"])
207 AC_MSG_CHECKING(for RDRAND)
208 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
209 #ifdef __native_client__
210 # error NativeClient detected - Avoiding RDRAND opcodes
212 -#pragma GCC target("rdrnd")
213 -#include <immintrin.h>
214 +#include <immintrinx.h>
215 ]], [[ unsigned long long x; _rdrand64_step(&x); ]])],
217 AC_DEFINE([HAVE_RDRAND], [1], [rdrand is available])
218 - AX_CHECK_COMPILE_FLAG([-mrdrnd], [CFLAGS_RDRAND="-mrdrnd"])
219 + AX_CHECK_COMPILE_FLAG([-mrdrnd], [CFLAGS_RDRAND=""])
223 diff --git a/src/libsodium/sodium/runtime.c b/src/libsodium/sodium/runtime.c
224 index ba1000f4..90fc016f 100644
225 --- a/src/libsodium/sodium/runtime.c
226 +++ b/src/libsodium/sodium/runtime.c
227 @@ -125,24 +125,28 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
229 cpu_features->has_sse2 = 0;
231 + cpu_features->has_sse2 = 0;
233 #ifdef HAVE_PMMINTRIN_H
234 cpu_features->has_sse3 = ((cpu_info[2] & CPUID_ECX_SSE3) != 0x0);
236 cpu_features->has_sse3 = 0;
238 + cpu_features->has_sse3 = 0;
240 #ifdef HAVE_TMMINTRIN_H
241 cpu_features->has_ssse3 = ((cpu_info[2] & CPUID_ECX_SSSE3) != 0x0);
243 cpu_features->has_ssse3 = 0;
245 + cpu_features->has_ssse3 = 0;
247 #ifdef HAVE_SMMINTRIN_H
248 cpu_features->has_sse41 = ((cpu_info[2] & CPUID_ECX_SSE41) != 0x0);
250 cpu_features->has_sse41 = 0;
252 + cpu_features->has_sse41 = 0;
254 cpu_features->has_avx = 0;
255 #ifdef HAVE_AVXINTRIN_H
256 @@ -169,6 +173,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
260 + cpu_features->has_avx = 0;
262 cpu_features->has_avx2 = 0;
263 #ifdef HAVE_AVX2INTRIN_H
264 @@ -179,6 +184,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
265 cpu_features->has_avx2 = ((cpu_info7[1] & CPUID_EBX_AVX2) != 0x0);
268 + cpu_features->has_avx2 = 0;
270 cpu_features->has_avx512f = 0;
271 #ifdef HAVE_AVX512FINTRIN_H
272 @@ -189,6 +195,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
273 cpu_features->has_avx512f = ((cpu_info7[1] & CPUID_EBX_AVX512F) != 0x0);
276 + cpu_features->has_avx512f = 0;
278 #ifdef HAVE_WMMINTRIN_H
279 cpu_features->has_pclmul = ((cpu_info[2] & CPUID_ECX_PCLMUL) != 0x0);
280 @@ -197,12 +204,15 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
281 cpu_features->has_pclmul = 0;
282 cpu_features->has_aesni = 0;
284 + cpu_features->has_pclmul = 0;
285 + cpu_features->has_aesni = 0;
288 cpu_features->has_rdrand = ((cpu_info[2] & CPUID_ECX_RDRAND) != 0x0);
290 cpu_features->has_rdrand = 0;
292 + cpu_features->has_rdrand = 0;
300 libsodium -- crypto library
302 NaCl (pronounced "salt") is a new easy-to-use high-speed software
303 library for network communication, encryption, decryption,
306 NaCl's goal is to provide all of the core operations needed to build
307 higher-level cryptographic tools.
309 Sodium is a portable, cross-compilable, installable, packageable
310 fork of NaCl with a compatible API.