aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Kubaj <pkubaj@FreeBSD.org>2021-04-25 16:43:31 +0000
committerPiotr Kubaj <pkubaj@FreeBSD.org>2021-04-25 16:43:31 +0000
commit4181b0995f99dec92a283ec4b515bd9d2fea0985 (patch)
tree16943fac6f3c6f1d8bfb626663704498ff39fe51
parentbf677a321b96d8709c4519b5df6ba22488b9cbcb (diff)
downloadports-4181b0995f99dec92a283ec4b515bd9d2fea0985.tar.gz
ports-4181b0995f99dec92a283ec4b515bd9d2fea0985.zip
security/cryptopp: enable SIMD by default on powerpc and powerpc64
Upstream can now check at runtime for SIMD availaibility. Merge upstream commits https://github.com/weidai11/cryptopp/commit/91173a287e668f7ce7e5086789b8db2300a159b1 and https://github.com/weidai11/cryptopp/commit/21a40abc5ceeb0ccf6577a444f1b4c19fa6379c6 to implement it. Local patch is used because upstream patch doesn't apply. Remove -maltivec and -mvsx, upstream now properly sets those flags on their own.
-rw-r--r--security/cryptopp/Makefile5
-rw-r--r--security/cryptopp/files/patch-cpu.cpp111
2 files changed, 115 insertions, 1 deletions
diff --git a/security/cryptopp/Makefile b/security/cryptopp/Makefile
index f0e40036ee36..489dc524d2b7 100644
--- a/security/cryptopp/Makefile
+++ b/security/cryptopp/Makefile
@@ -2,6 +2,7 @@
PORTNAME= cryptopp
PORTVERSION= 8.5.0
+PORTREVISION= 1
CATEGORIES= security
MASTER_SITES= http://www.cryptopp.com/
DISTNAME= cryptopp${PORTVERSION:S/.//g}
@@ -35,6 +36,8 @@ OPTIONS_DEFINE_powerpc= SIMD
OPTIONS_DEFINE_powerpc64= SIMD
OPTIONS_DEFINE_powerpc64le= SIMD
OPTIONS_DEFAULT= TOOLS
+OPTIONS_DEFAULT_powerpc= SIMD
+OPTIONS_DEFAULT_powerpc64= SIMD
OPTIONS_DEFAULT_powerpc64le= SIMD
OPTIONS_SUB= yes
@@ -66,7 +69,7 @@ CXXFLAGS+= -DCRYPTOPP_DISABLE_SSSE3
CXXFLAGS+= -DCRYPTOPP_DISABLE_SSE4
. endif
. elif ${ARCH} == powerpc || ${ARCH:Mpowerpc64*}
-CXXFLAGS+= -DCRYPTOPP_ALTIVEC_AVAILABLE -maltivec -mcrypto -mvsx
+CXXFLAGS+= -DCRYPTOPP_ALTIVEC_AVAILABLE
. endif
.else
CXXFLAGS+= -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_SSE2 \
diff --git a/security/cryptopp/files/patch-cpu.cpp b/security/cryptopp/files/patch-cpu.cpp
new file mode 100644
index 000000000000..a8e71a174d54
--- /dev/null
+++ b/security/cryptopp/files/patch-cpu.cpp
@@ -0,0 +1,111 @@
+--- cpu.cpp.orig 2021-03-08 03:42:24 UTC
++++ cpu.cpp
+@@ -1172,6 +1172,11 @@ inline bool CPU_QueryAltivec()
+ unsigned int unused, arch;
+ GetAppleMachineInfo(unused, unused, arch);
+ return arch == AppleMachineInfo::PowerMac;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE_HAS_ALTIVEC)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
+ #endif
+ return false;
+ }
+@@ -1185,6 +1190,12 @@ inline bool CPU_QueryPower7()
+ #elif defined(_AIX)
+ if (__power_7_andup() != 0)
+ return true;
++
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE_ARCH_2_06)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE_ARCH_2_06;
+ #endif
+ return false;
+ }
+@@ -1198,6 +1209,11 @@ inline bool CPU_QueryPower8()
+ #elif defined(_AIX)
+ if (__power_8_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_ARCH_2_07)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_ARCH_2_07;
+ #endif
+ return false;
+ }
+@@ -1211,6 +1227,11 @@ inline bool CPU_QueryPower9()
+ #elif defined(_AIX)
+ if (__power_9_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_ARCH_3_00)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE_ARCH2_3_00;
+ #endif
+ return false;
+ }
+@@ -1225,6 +1246,11 @@ inline bool CPU_QueryAES()
+ #elif defined(_AIX)
+ if (__power_8_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_HAS_VEC_CRYPTO)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_HAS_VEC_CRYPTO;
+ #endif
+ return false;
+ }
+@@ -1239,6 +1265,11 @@ inline bool CPU_QueryPMULL()
+ #elif defined(_AIX)
+ if (__power_8_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_HAS_VEC_CRYPTO)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_HAS_VEC_CRYPTO;
+ #endif
+ return false;
+ }
+@@ -1253,6 +1284,11 @@ inline bool CPU_QuerySHA256()
+ #elif defined(_AIX)
+ if (__power_8_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_HAS_VEC_CRYPTO)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_HAS_VEC_CRYPTO;
+ #endif
+ return false;
+ }
+@@ -1266,6 +1302,11 @@ inline bool CPU_QuerySHA512()
+ #elif defined(_AIX)
+ if (__power_8_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_HAS_VEC_CRYPTO)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_HAS_VEC_CRYPTO;
+ #endif
+ return false;
+ }
+@@ -1280,6 +1321,11 @@ inline bool CPU_QueryDARN()
+ #elif defined(_AIX)
+ if (__power_9_andup() != 0)
+ return true;
++#elif defined(__FreeBSD__) && defined(PPC_FEATURE2_ARCH_3_00)
++ unsigned long cpufeatures;
++ if (elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures))
++ return false;
++ else return cpufeatures & PPC_FEATURE2_ARCH_3_00;
+ #endif
+ return false;
+ }