cmake: Build bitcoin_crypto library
This commit is contained in:
4 files changed
+148
No files matched your search
@@ -29,6 +29,18 @@
|
||||
/* Copyright year */
|
||||
#define COPYRIGHT_YEAR @COPYRIGHT_YEAR@
|
||||
|
||||
/* Define this symbol to build code that uses ARMv8 SHA-NI intrinsics */
|
||||
#cmakedefine ENABLE_ARM_SHANI 1
|
||||
|
||||
/* Define this symbol to build code that uses AVX2 intrinsics */
|
||||
#cmakedefine ENABLE_AVX2 1
|
||||
|
||||
/* Define this symbol to build code that uses SSE4.1 intrinsics */
|
||||
#cmakedefine ENABLE_SSE41 1
|
||||
|
||||
/* Define this symbol to build code that uses x86 SHA-NI intrinsics */
|
||||
#cmakedefine ENABLE_X86_SHANI 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `fork', and to 0 if you don't.
|
||||
*/
|
||||
#cmakedefine01 HAVE_DECL_FORK
|
||||
|
||||
@@ -158,3 +158,70 @@ check_cxx_source_compiles("
|
||||
}
|
||||
" HAVE_SYSCTL_ARND
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
include(CheckSourceCompilesAndLinks)
|
||||
|
||||
# Check for SSE4.1 intrinsics.
|
||||
set(SSE41_CXXFLAGS -msse4.1)
|
||||
check_cxx_source_compiles_with_flags("${SSE41_CXXFLAGS}" "
|
||||
#include <immintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
__m128i a = _mm_set1_epi32(0);
|
||||
__m128i b = _mm_set1_epi32(1);
|
||||
__m128i r = _mm_blend_epi16(a, b, 0xFF);
|
||||
return _mm_extract_epi32(r, 3);
|
||||
}
|
||||
" HAVE_SSE41
|
||||
)
|
||||
set(ENABLE_SSE41 ${HAVE_SSE41})
|
||||
|
||||
# Check for AVX2 intrinsics.
|
||||
set(AVX2_CXXFLAGS -mavx -mavx2)
|
||||
check_cxx_source_compiles_with_flags("${AVX2_CXXFLAGS}" "
|
||||
#include <immintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
__m256i l = _mm256_set1_epi32(0);
|
||||
return _mm256_extract_epi32(l, 7);
|
||||
}
|
||||
" HAVE_AVX2
|
||||
)
|
||||
set(ENABLE_AVX2 ${HAVE_AVX2})
|
||||
|
||||
# Check for x86 SHA-NI intrinsics.
|
||||
set(X86_SHANI_CXXFLAGS -msse4 -msha)
|
||||
check_cxx_source_compiles_with_flags("${X86_SHANI_CXXFLAGS}" "
|
||||
#include <immintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
__m128i i = _mm_set1_epi32(0);
|
||||
__m128i j = _mm_set1_epi32(1);
|
||||
__m128i k = _mm_set1_epi32(2);
|
||||
return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0);
|
||||
}
|
||||
" HAVE_X86_SHANI
|
||||
)
|
||||
set(ENABLE_X86_SHANI ${HAVE_X86_SHANI})
|
||||
|
||||
# Check for ARMv8 SHA-NI intrinsics.
|
||||
set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto)
|
||||
check_cxx_source_compiles_with_flags("${ARM_SHANI_CXXFLAGS}" "
|
||||
#include <arm_neon.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
uint32x4_t a, b, c;
|
||||
vsha256h2q_u32(a, b, c);
|
||||
vsha256hq_u32(a, b, c);
|
||||
vsha256su0q_u32(a, b);
|
||||
vsha256su1q_u32(a, b, c);
|
||||
}
|
||||
" HAVE_ARM_SHANI
|
||||
)
|
||||
set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI})
|
||||
endif()
|
||||
Reference in new issue
Block a user