Fix compile on old PowerPC

This cleans up the compile on old PwerMac G5's. Our Altivec and Crypto code relies on Power7 and Power8 extensions. There's no need to shoehorn Altivec and Power4 into old platforms, so we disable Altivec and Crypto unless Power7 is available. The GNUmakefile sets CRYPTOPP_DISABLE_ALTIVEC if Power7 is not available.
pull/531/head
Jeffrey Walton 2017-10-17 20:47:14 -04:00
parent 9df87dc7d4
commit f8d97b83ed
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 14 additions and 12 deletions

View File

@ -339,11 +339,12 @@ ifeq ($(IS_ARMV8),1)
endif
# PowerPC and PowerPC-64
# Altivec is available with Power4, but the library is tied to Power7 and unaligned loads/stores.
ifneq ($(IS_PPC32)$(IS_PPC64)$(IS_AIX),000)
# GCC and some compatibles
HAVE_ALTIVEC = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -maltivec -dM -E - 2>/dev/null | $(GREP) -i -c '__ALTIVEC__')
HAVE_ALTIVEC = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -mcpu=power7 -maltivec -dM -E - 2>/dev/null | $(GREP) -i -c '__ALTIVEC__')
ifneq ($(HAVE_ALTIVEC),0)
ALTIVEC_FLAG = -maltivec
ALTIVEC_FLAG = -mcpu=power7 -maltivec
endif
# GCC and some compatibles
HAVE_CRYPTO = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -mcpu=power8 -maltivec -dM -E - 2>/dev/null | $(GREP) -i -c -E '_ARCH_PWR8|_ARCH_PWR9|__CRYPTO')
@ -354,9 +355,9 @@ ifneq ($(IS_PPC32)$(IS_PPC64)$(IS_AIX),000)
ALTIVEC_FLAG = -mcpu=power8 -maltivec
endif
# IBM XL C/C++
HAVE_ALTIVEC = $(shell $(CXX) $(CXXFLAGS) -qshowmacros -qaltivec -E adhoc.cpp.proto 2>/dev/null | $(GREP) -i -c '__ALTIVEC__')
HAVE_ALTIVEC = $(shell $(CXX) $(CXXFLAGS) -qshowmacros -qarch=pwr7 -qaltivec -E adhoc.cpp.proto 2>/dev/null | $(GREP) -i -c '__ALTIVEC__')
ifneq ($(HAVE_ALTIVEC),0)
ALTIVEC_FLAG = -qaltivec
ALTIVEC_FLAG = -qarch=pwr7 -qaltivec
endif
# IBM XL C/C++
HAVE_CRYPTO = $(shell $(CXX) $(CXXFLAGS) -qshowmacros -qarch=pwr8 -qaltivec -E adhoc.cpp.proto 2>/dev/null | $(GREP) -i -c -E '_ARCH_PWR8|_ARCH_PWR9|__CRYPTO')
@ -366,6 +367,10 @@ ifneq ($(IS_PPC32)$(IS_PPC64)$(IS_AIX),000)
SHA_FLAG = -qarch=pwr8 -qaltivec
ALTIVEC_FLAG = -qarch=pwr8 -qaltivec
endif
# Fail safe to disable intrinsics on down level machines, like PowerMac G5
ifeq ($(ALTIVEC_FLAG),)
CXXFLAGS += -DCRYPTOPP_DISABLE_ALTIVEC
endif
endif
# IBM XL C/C++ compiler
@ -378,10 +383,6 @@ ifeq ($(XLC_COMPILER),1)
ifneq ($(findstring -fPIC,$(CXXFLAGS)),)
CXXFLAGS := $(CXXFLAGS:-fPIC=-qpic)
endif
# Warnings and intermittent failures on early IBM XL C/C++
#ifneq ($(findstring -O3,$(CXXFLAGS)),)
# CXXFLAGS := $(CXXFLAGS:-O3=-O2)
#endif
endif
endif # IS_X86

View File

@ -600,20 +600,21 @@ NAMESPACE_END
#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
// An old Apple G5 with GCC 4.01 has AltiVec.
#if !defined(CRYPTOPP_ALTIVEC_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
// An old Apple G5 with GCC 4.01 has AltiVec, but its only Power4 or so.
// We need Power7 or above, so the makefile defines CRYPTOPP_DISABLE_ALTIVEC.
#if !defined(CRYPTOPP_ALTIVEC_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ALTIVEC) && !defined(CRYPTOPP_DISABLE_ASM)
# if defined(__ALTIVEC__) || (CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40000)
# define CRYPTOPP_ALTIVEC_AVAILABLE 1
# endif
#endif
#if !defined(CRYPTOPP_POWER8_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
#if !defined(CRYPTOPP_POWER8_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && defined(CRYPTOPP_ALTIVEC_AVAILABLE)
# if defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || (CRYPTOPP_GCC_VERSION >= 40800)
# define CRYPTOPP_POWER8_AVAILABLE 1
# endif
#endif
#if !defined(CRYPTOPP_POWER8_CRYPTO_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
#if !defined(CRYPTOPP_POWER8_CRYPTO_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && defined(CRYPTOPP_ALTIVEC_AVAILABLE)
# if defined(__CRYPTO__) || defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || (CRYPTOPP_GCC_VERSION >= 40800)
# define CRYPTOPP_POWER8_AES_AVAILABLE 1
//# define CRYPTOPP_POWER8_SHA_AVAILABLE 1