From ba2c778f1b37acef04c140a80309ed3f293ecca9 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 15 Jul 2016 01:53:01 -0400 Subject: [PATCH 1/2] Fix typo in SunCC check --- rijndael.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rijndael.cpp b/rijndael.cpp index c89a0425..0546c2a9 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -83,7 +83,7 @@ NAMESPACE_BEGIN(CryptoPP) #endif // Hack for SunCC, http://github.com/weidai11/cryptopp/issues/224 -#if defined(__SUNPRO_CC >= 5130) +#if (__SUNPRO_CC >= 5130) # define MAYBE_CONST #else # define MAYBE_CONST const From 2c3b512b9e3c4762f04d9d7a1f851e7756d09ac3 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 15 Jul 2016 03:52:50 -0400 Subject: [PATCH 2/2] Rework Aarch32 (ARM32) and Aarch64 (ARM64) feature detection. Disable ASAN under ARM and GCC 4.8 --- cryptest.sh | 95 ++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/cryptest.sh b/cryptest.sh index dfa1b37b..3a3839f3 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -450,56 +450,6 @@ if [[ (-z "$HAVE_X32") ]]; then fi fi -# ARMv7a/Aarch32 (may run on Aarch64). -rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 -if [[ (-z "$HAVE_ARMV7A") ]]; then - HAVE_ARMV7A=0 - if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then - "$CXX" -DCRYPTOPP_ADHOC_MAIN -march=armv7a adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 - if [[ "$?" -eq "0" ]]; then - "$TMP/adhoc.exe" > /dev/null 2>&1 - if [[ "$?" -eq "0" ]]; then - HAVE_ARMV7A=1 - fi - fi - fi -fi - -# ARM NEON (may run on Aarch64). -rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 -if [[ (-z "$HAVE_ARM_NEON") ]]; then - HAVE_ARM_NEON=0 - if [[ ("$IS_ARM32" -ne "0") ]]; then - if [[ $(cat /proc/cpuinfo 2>/dev/null | "$GREP" -i -c NEON) -ne "0" ]]; then - HAVE_ARM_NEON=1 - fi - fi -fi - -# ARMv8/Aarch64, CRC and Crypto. -rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 -if [[ (-z "$HAVE_ARM_CRYPTO") ]]; then - HAVE_ARM_CRYPTO=0 - if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then - "$CXX" -DCRYPTOPP_ADHOC_MAIN -march=armv8-a+crypto adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 - if [[ "$?" -eq "0" ]]; then - HAVE_ARM_CRYPTO=1 - fi - fi -fi - -# ARMv8/Aarch64, CRC and Crypto. -rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 -if [[ (-z "$HAVE_ARM_CRC") ]]; then - HAVE_ARM_CRC=0 - if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then - "$CXX" -DCRYPTOPP_ADHOC_MAIN -march=armv8-a+crc adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 - if [[ "$?" -eq "0" ]]; then - HAVE_ARM_CRC=1 - fi - fi -fi - # "Modern compiler, old hardware" combinations HAVE_X86_AES=0 HAVE_X86_RDRAND=0 @@ -541,6 +491,31 @@ if [[ (-z "$HAVE_LDGOLD") ]]; then fi fi +# ARMv7 and ARMv8, including NEON, CRC32 and Crypto extensions +if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then + ARM_FEATURES=$(cat /proc/cpuinfo 2>&1 | "$AWK" '{IGNORECASE=1}{if ($1 == "Features") print}' | cut -f 2 -d ':') + + if [[ (-z "$HAVE_ARMV7A") ]]; then + # NEON is optional on two ARMv7-a cores + HAVE_ARMV7A=$(echo "$ARM_FEATURES" | "$GREP" -i -c 'neon') + fi + + rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ (-z "$HAVE_ARM_NEON") ]]; then + HAVE_ARM_NEON=$(echo "$ARM_FEATURES" | "$GREP" -i -c 'neon') + fi + + rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ (-z "$HAVE_ARM_CRYPTO") ]]; then + HAVE_ARM_CRYPTO=$(echo "$ARM_FEATURES" | "$EGREP" -i -c '(aes|pmull|sha1|sha2)') + fi + + rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ (-z "$HAVE_ARM_CRC") ]]; then + HAVE_ARM_CRC=$(echo "$ARM_FEATURES" | "$GREP" -i -c "crc32") + fi +fi + # Valgrind testing of C++03, C++11, C++14 and C++17 binaries. Valgrind tests take a long time... if [[ (-z "$HAVE_VALGRIND") ]]; then HAVE_VALGRIND=$(which valgrind 2>&1 | "$GREP" -v "no valgrind" | "$GREP" -i -c valgrind) @@ -577,14 +552,19 @@ if [[ (-z "$HAVE_DISASS") ]]; then fi fi -# Fixup... SunCC appears to generate bad code for BLAKE2s -if [[ ("$SUN_COMPILER" -ne "0") ]];then +# Fixup... SunCC appears to generate bad code for BLAKE2 +if [[ ("$SUN_COMPILER" -ne "0") ]]; then HAVE_O5=0 OPT_O5= HAVE_OFAST=0 OPT_OFAST= fi +# Fixup... GCC 4.8 ASAN produces false positives under ARM +if [[ ( ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") && "$GCC_48_COMPILER" -ne "0") ]]; then + HAVE_ASAN=0 +fi + # Benchmarks take a long time... if [[ (-z "$WANT_BENCHMARKS") ]]; then WANT_BENCHMARKS=1 @@ -832,6 +812,17 @@ if [[ ("$IS_ARM32" -ne "0") ]]; then fi fi +# Add to exercise ARMv8 more thoroughly. NEON is baked in under CPU flag asimd. +if [[ ("$IS_ARM64" -ne "0") ]]; then + if [[ ("$HAVE_ARM_CRC" -ne "0" && "$HAVE_ARM_CRYPTO" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-march=armv8-a+crc+crypto ") + elif [[ ("$HAVE_ARM_CRC" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-march=armv8-a+crc ") + elif [[ ("$HAVE_ARM_CRYPTO" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-march=armv8-a+crypto ") + fi +fi + if [[ ("$IS_SOLARIS" -ne "0") && ("$SUNCC_121_OR_ABOVE" -ne "0") ]]; then ISAINFO=$(isainfo -v 2>/dev/null) if [[ ($(echo "$ISAINFO" | "$GREP" -c "sse2") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__SSE2__ "; fi