Fix ARM A-32 and Aarch64 feature tests (PR #737)
parent
886fd7903d
commit
41639e5ec6
80
GNUmakefile
80
GNUmakefile
|
|
@ -104,6 +104,16 @@ ifeq ($(IS_AIX),1)
|
|||
endif
|
||||
endif
|
||||
|
||||
# Hack to skip CPU feature tests for some recipes
|
||||
DETECT_FEATURES ?= 1
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),-DCRYPTOPP_DISABLE_ASM)
|
||||
DETECT_FEATURES := 0
|
||||
else ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
|
||||
DETECT_FEATURES := 0
|
||||
else ifeq ($(findstring distclean,$(MAKECMDGOALS)),distclean)
|
||||
DETECT_FEATURES := 0
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
##### General Variables #####
|
||||
###########################################################
|
||||
|
|
@ -190,7 +200,7 @@ ifneq ($(IS_X86)$(IS_X64),00)
|
|||
|
||||
# Begin GCC and compatibles
|
||||
ifneq ($(GCC_COMPILER)$(CLANG_COMPILER)$(INTEL_COMPILER),000)
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
# Tell MacPorts and Homebrew GCC to use Clang integrated assembler
|
||||
# http://github.com/weidai11/cryptopp/issues/190
|
||||
|
|
@ -301,7 +311,7 @@ ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
|||
# https://github.com/weidai11/cryptopp/issues/738
|
||||
UNUSED := $(shell rm -f a.out && rm -rf a.out.dSYM/)
|
||||
|
||||
# CRYPTOPP_DISABLE_ASM
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# End GCC and compatibles
|
||||
|
|
@ -309,7 +319,7 @@ endif
|
|||
|
||||
# Begin SunCC
|
||||
ifeq ($(SUN_COMPILER),1)
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
TPROG = TestPrograms/test_sse2.cxx
|
||||
TOPT = -xarch=sse2
|
||||
|
|
@ -417,7 +427,7 @@ ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
|||
# https://github.com/weidai11/cryptopp/issues/738
|
||||
UNUSED := $(shell rm -f a.out && rm -rf a.out.dSYM/)
|
||||
|
||||
# CRYPTOPP_DISABLE_ASM
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# End SunCC
|
||||
|
|
@ -451,11 +461,11 @@ endif
|
|||
###########################################################
|
||||
|
||||
ifneq ($(IS_ARM32)$(IS_ARMV8)$(IS_NEON),000)
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
ifeq ($(IS_ARM32)$(IS_NEON),11)
|
||||
|
||||
TPROG = TestPrograms/test_neon.cxx
|
||||
TPROG = TestPrograms/test_arm_neon.cxx
|
||||
TOPT = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
|
|
@ -488,16 +498,18 @@ endif
|
|||
|
||||
ifeq ($(IS_ARMV8),1)
|
||||
|
||||
TPROG = TestPrograms/test_asimd.cxx
|
||||
TPROG = TestPrograms/test_arm_acle.cxx
|
||||
TOPT = -march=armv8-a
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifneq ($(HAVE_OPT),0)
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
ACLE_FLAG += -DCRYPTOPP_ARM_ACLE_AVAILABLE=1
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_ACLE_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_asimd.cxx
|
||||
TPROG = TestPrograms/test_arm_asimd.cxx
|
||||
TOPT = -march=armv8-a
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
ASIMD_FLAG = -march=armv8-a
|
||||
ARIA_FLAG = -march=armv8-a
|
||||
|
|
@ -518,26 +530,46 @@ ifeq ($(IS_ARMV8),1)
|
|||
endif
|
||||
|
||||
ifneq ($(ASIMD_FLAG),)
|
||||
TPROG = TestPrograms/test_crc.cxx
|
||||
TOPT = -march=armv8-a+crc
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
TPROG = TestPrograms/test_arm_crc.cxx
|
||||
TOPT = -march=armv8.1-a+crc
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
CRC_FLAG = -march=armv8-a+crc
|
||||
CRC_FLAG = -march=armv8.1-a+crc
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_CRC32_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_crypto_v81.cxx
|
||||
TOPT = -march=armv8-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
TPROG = TestPrograms/test_arm_aes.cxx
|
||||
TOPT = -march=armv8.1-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
AES_FLAG = -march=armv8-a+crypto
|
||||
GCM_FLAG = -march=armv8-a+crypto
|
||||
SHA_FLAG = -march=armv8-a+crypto
|
||||
AES_FLAG = -march=armv8.1-a+crypto
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_AES_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_pmull.cxx
|
||||
TOPT = -march=armv8.1-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
GCM_FLAG = -march=armv8.1-a+crypto
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_PMULL_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_sha.cxx
|
||||
TOPT = -march=armv8.1-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
SHA_FLAG = -march=armv8.1-a+crypto
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_SHA_AVAILABLE=0
|
||||
endif
|
||||
|
||||
ifneq ($(AES_FLAG),)
|
||||
TPROG = TestPrograms/test_crypto_v84.cxx
|
||||
TOPT = -march=armv8.4-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) 2>&1 | $(GREP) -i -c -E $(BAD_RESULT))
|
||||
ifeq ($(HAVE_OPT),0)
|
||||
SM3_FLAG = -march=armv8.4-a+crypto
|
||||
SM4_FLAG = -march=armv8.4-a+crypto
|
||||
|
|
@ -551,7 +583,7 @@ ifeq ($(IS_ARMV8),1)
|
|||
# IS_ARMV8
|
||||
endif
|
||||
|
||||
# CRYPTOPP_DISABLE_ASM
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# IS_ARM32, IS_ARMV8, IS_NEON
|
||||
|
|
@ -566,7 +598,7 @@ endif
|
|||
# front-end. XLC/LLVM only supplies POWER8 so we have to set the flags for
|
||||
# XLC/LLVM to POWER8. I've got a feeling LLVM is going to cause trouble.
|
||||
ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
# LLVM front-ends only provide POWER8 and need special options to
|
||||
# get XLC defines. The POWER8 really jambs us up for ppc_simd.cpp
|
||||
|
|
@ -722,7 +754,7 @@ ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
|||
# https://github.com/weidai11/cryptopp/issues/738
|
||||
UNUSED := $(shell rm -f a.out && rm -rf a.out.dSYM/)
|
||||
|
||||
# CRYPTOPP_DISABLE_ASM
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# IBM XL C/C++ compiler
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
#include <arm_acle.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint8x16_t x;
|
||||
x=vaeseq_u8(x,x);
|
||||
x=vaesmcq_u8(x);
|
||||
x=vaesdq_u8(x,x);
|
||||
x=vaesimcq_u8(x);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x;
|
||||
x=veorq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// This is how config.h includes it.
|
||||
#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
# if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
poly64_t a1={0x9090909090909090}, b1={0xb0b0b0b0b0b0b0b0};
|
||||
poly8x16_t a2={0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0},
|
||||
b2={0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
|
||||
0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0};
|
||||
|
||||
poly128_t r1 = vmull_p64(a1, b1);
|
||||
poly128_t r2 = vmull_high_p64((poly64x2_t)(a2), (poly64x2_t)(b2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t y;
|
||||
y=vsha1cq_u32(y,0,y);
|
||||
y=vsha1mq_u32(y,1,y);
|
||||
y=vsha1pq_u32(y,2,y);
|
||||
y = vsha256hq_u32(y, y, y);
|
||||
y = vsha256h2q_u32(y, y, y);
|
||||
y = vsha256su1q_u32(y, y, y);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// This is how config.h includes it.
|
||||
#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
# if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x;
|
||||
x=veorq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// This is how config.h includes it.
|
||||
#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
# if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint8x16_t x;
|
||||
x=vaeseq_u8(x,x);
|
||||
x=vaesdq_u8(x,x);
|
||||
|
||||
uint32x4_t y;
|
||||
y=vsha1cq_u32(y,0,y);
|
||||
y=vsha1mq_u32(y,1,y);
|
||||
y=vsha1pq_u32(y,2,y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#include <arm_neon.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// This is how config.h includes it.
|
||||
#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
# if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
// test_acle.h determines if this is available. Then,
|
||||
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
|
||||
// if the ACLE header is not available.
|
||||
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
|
|||
4
config.h
4
config.h
|
|
@ -729,10 +729,12 @@ NAMESPACE_END
|
|||
#endif
|
||||
|
||||
// Limit the <arm_acle.h> include.
|
||||
#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
#if !defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
|
||||
# if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
|
||||
# define CRYPTOPP_ARM_ACLE_AVAILABLE 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Fixup Apple Clang and PMULL. Apple defines __ARM_FEATURE_CRYPTO for Xcode 6
|
||||
|
|
|
|||
Loading…
Reference in New Issue