From 537297163755ac768109090036885014d2be049e Mon Sep 17 00:00:00 2001 From: Sergey Kroshnin Date: Wed, 30 Jan 2019 22:46:21 +0300 Subject: [PATCH] Add compile options for Aarch64 (#1662) * Add compile options for Aarch64 * Fix failing builds after commit https://github.com/weidai11/cryptopp/commit/df9fa62205f2d341e2b1b26595a3a1b6377c60c5 * Update cryptopp Fix missing GF2NT_233_Multiply_Reduce_ARMv8 on Aarch64 * Add missing files to build cryptopp for aarch64 * Disable ARM Cryptopp ASM without NANO_SIMD_OPTIMIZATIONS * Fix Argon2 aarch64 SIMD --- CMakeLists.txt | 31 +++++++++++++++++++++---------- crypto/cryptopp | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a79482da..e310a1e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,13 +60,10 @@ else () else () add_definitions(-DCRYPTOPP_DISABLE_AESNI) endif () - # Fix failing builds after commit https://github.com/weidai11/cryptopp/commit/df9fa62205f2d341e2b1b26595a3a1b6377c60c5 - add_definitions(-DCRYPTOPP_DISABLE_CLMUL) elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") add_compile_options(-msse2) add_definitions(-DCRYPTOPP_DISABLE_SSSE3 - -DCRYPTOPP_DISABLE_AESNI - -DCRYPTOPP_DISABLE_CLMUL) + -DCRYPTOPP_DISABLE_AESNI) endif() if (ENABLE_AVX2) @@ -77,6 +74,13 @@ else () add_definitions(-DPERMUTE_WITH_SHUFFLES) endif() endif() + elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + if (NANO_SIMD_OPTIMIZATIONS OR RAIBLOCKS_SIMD_OPTIMIZATIONS) + add_compile_options(-march=armv8-a+crc+crypto) + else () + add_compile_options(-march=armv8-a) + add_definitions(-DCRYPTOPP_DISABLE_ASM) + endif () endif() endif () @@ -144,16 +148,21 @@ set_target_properties(libminiupnpc-static PROPERTIES INTERFACE_INCLUDE_DIRECTORI set (BUILD_SHARED OFF CACHE BOOL "") set (BUILD_TESTING OFF CACHE BOOL "") set (USE_INTERMEDIATE_OBJECTS_TARGET OFF CACHE BOOL "") -set (CRYPTOPP_WIN "") +set (CRYPTOPP_EXTRA "") if (WIN32) - set (CRYPTOPP_WIN crypto/cryptopp/x64dll.asm + set (CRYPTOPP_EXTRA crypto/cryptopp/x64dll.asm crypto/cryptopp/x64masm.asm) enable_language(ASM) enable_language(ASM_MASM) # similar to SSE2 settings add_definitions(-DCRYPTOPP_DISABLE_SSSE3 - -DCRYPTOPP_DISABLE_AESNI - -DCRYPTOPP_DISABLE_CLMUL) + -DCRYPTOPP_DISABLE_AESNI) +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND (NANO_SIMD_OPTIMIZATIONS OR RAIBLOCKS_SIMD_OPTIMIZATIONS)) + set (CRYPTOPP_EXTRA crypto/cryptopp/crc_simd.cpp + crypto/cryptopp/gcm_simd.cpp + crypto/cryptopp/gf2n_simd.cpp + crypto/cryptopp/neon_simd.cpp) + add_definitions(-DCRYPTOPP_NO_CPU_FEATURE_PROBES) endif () # Some Clang cannot handle mixed asm with positional arguments, where the # body is Intel style with no prefix and the templates are AT&T style. @@ -164,6 +173,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") message("CryptoPP with disabled ASM for ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") endif () add_definitions(-DCRYPTOPP_DISABLE_SHANI) +# Fix failing builds after commit https://github.com/weidai11/cryptopp/commit/df9fa62205f2d341e2b1b26595a3a1b6377c60c5 +add_definitions(-DCRYPTOPP_DISABLE_CLMUL) set (CRYPTOPP_LIBRARY cryptopp) add_library (cryptopp @@ -205,9 +216,9 @@ add_library (cryptopp crypto/cryptopp/sha_simd.cpp crypto/cryptopp/simple.cpp crypto/cryptopp/sse_simd.cpp - ${CRYPTOPP_WIN}) + ${CRYPTOPP_EXTRA}) -if (NANO_SIMD_OPTIMIZATIONS OR RAIBLOCKS_SIMD_OPTIMIZATIONS) +if ((NANO_SIMD_OPTIMIZATIONS OR RAIBLOCKS_SIMD_OPTIMIZATIONS) AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") set (ARGON_CORE crypto/phc-winner-argon2/src/opt.c) else () set (ARGON_CORE crypto/phc-winner-argon2/src/ref.c) diff --git a/crypto/cryptopp b/crypto/cryptopp index 1cd8ccbf..a4f6da8d 160000 --- a/crypto/cryptopp +++ b/crypto/cryptopp @@ -1 +1 @@ -Subproject commit 1cd8ccbf8253835a69647efb97b9fd17f919c982 +Subproject commit a4f6da8d304401c209a0e2ea89ef5377707d0b22