Date: Mon, 18 Apr 2022 11:42:28 GMT From: Max Brazhnikov <makc@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 96151ece4c41 - main - archivers/7-zip: fix build on armv6/armv7 Message-ID: <202204181142.23IBgSUK092723@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by makc: URL: https://cgit.FreeBSD.org/ports/commit/?id=96151ece4c41ec9a060a5347704f1a51323dd57f commit 96151ece4c41ec9a060a5347704f1a51323dd57f Author: Max Brazhnikov <makc@FreeBSD.org> AuthorDate: 2022-04-18 11:40:48 +0000 Commit: Max Brazhnikov <makc@FreeBSD.org> CommitDate: 2022-04-18 11:40:48 +0000 archivers/7-zip: fix build on armv6/armv7 - Extend HWCAP detection patch to use correct auxvals on armv6/armv7. - Disable optimised AES, CRC, SHA-1, and SHA-256 kernels on armv6/armv7 as they don't build with base clang. PR: 263244 Submitted by: Robert Clausecker --- archivers/7-zip/Makefile | 5 ++++ archivers/7-zip/files/patch-C_7zCrc.c | 11 +++++++++ archivers/7-zip/files/patch-C_Aes.c | 11 +++++++++ archivers/7-zip/files/patch-C_AesOpt.c | 38 +++++++++++++++++++++++++++++++ archivers/7-zip/files/patch-C_CpuArch.c | 26 +++++++++++++-------- archivers/7-zip/files/patch-C_Sha1Opt.c | 11 +++++++++ archivers/7-zip/files/patch-C_Sha256Opt.c | 11 +++++++++ 7 files changed, 104 insertions(+), 9 deletions(-) diff --git a/archivers/7-zip/Makefile b/archivers/7-zip/Makefile index 549bd0fb3868..eeccb82cee65 100644 --- a/archivers/7-zip/Makefile +++ b/archivers/7-zip/Makefile @@ -30,6 +30,11 @@ CFLAGS_aarch64?= -march=armv8-a+crc+crypto NO_WRKSUBDIR= yes BUILD_WRKSRC= ${WRKSRC}/CPP/7zip/Bundles/Alone2 DOS2UNIX_FILES= C/CpuArch.c \ + C/7zCrc.c \ + C/Aes.c \ + C/AesOpt.c \ + C/Sha1Opt.c \ + C/Sha256Opt.c \ CPP/7zip/7zip_gcc.mak \ CPP/7zip/var_gcc.mak \ CPP/Windows/SystemInfo.cpp diff --git a/archivers/7-zip/files/patch-C_7zCrc.c b/archivers/7-zip/files/patch-C_7zCrc.c new file mode 100644 index 000000000000..085636273a14 --- /dev/null +++ b/archivers/7-zip/files/patch-C_7zCrc.c @@ -0,0 +1,11 @@ +--- C/7zCrc.c.orig 2022-04-12 15:58:06 UTC ++++ C/7zCrc.c +@@ -71,7 +71,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void * + + #ifdef MY_CPU_LE + +-#if defined(MY_CPU_ARM_OR_ARM64) ++#if defined(MY_CPU_ARM64) + + // #pragma message("ARM*") + diff --git a/archivers/7-zip/files/patch-C_Aes.c b/archivers/7-zip/files/patch-C_Aes.c new file mode 100644 index 000000000000..5c7f45168933 --- /dev/null +++ b/archivers/7-zip/files/patch-C_Aes.c @@ -0,0 +1,11 @@ +--- C/Aes.c.orig 2022-04-12 15:57:33 UTC ++++ C/Aes.c +@@ -55,7 +55,7 @@ static Byte InvS[256]; + + #ifdef MY_CPU_X86_OR_AMD64 + #define USE_HW_AES +-#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) ++#elif defined(MY_CPU_ARM) && defined(MY_CPU_LE) + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define USE_HW_AES diff --git a/archivers/7-zip/files/patch-C_AesOpt.c b/archivers/7-zip/files/patch-C_AesOpt.c new file mode 100644 index 000000000000..6366058533f0 --- /dev/null +++ b/archivers/7-zip/files/patch-C_AesOpt.c @@ -0,0 +1,38 @@ +--- C/AesOpt.c.orig 2022-04-12 15:59:22 UTC ++++ C/AesOpt.c +@@ -506,7 +506,7 @@ VAES_COMPAT_STUB (AesCtr_Code_HW) + #endif // ! USE_INTEL_VAES + + +-#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) ++#elif defined(MY_CPU_ARM64) && defined(MY_CPU_LE) + + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check +@@ -773,4 +773,25 @@ AES_FUNC_START2 (AesCtr_Code_HW) + + #endif // USE_HW_AES + +-#endif // MY_CPU_ARM_OR_ARM64 ++#else ++ ++/* no USE_HW_AES */ ++ ++#pragma message("AES HW_SW stub was used") ++ ++#define AES_TYPE_keys UInt32 ++#define AES_TYPE_data Byte ++ ++#define AES_FUNC_START(name) \ ++ void MY_FAST_CALL name(UInt32 *p, Byte *data, size_t numBlocks) \ ++ ++#define AES_COMPAT_STUB(name) \ ++ AES_FUNC_START(name); \ ++ AES_FUNC_START(name ## _HW) \ ++ { name(p, data, numBlocks); } ++ ++AES_COMPAT_STUB (AesCbc_Encode) ++AES_COMPAT_STUB (AesCbc_Decode) ++AES_COMPAT_STUB (AesCtr_Code) ++ ++#endif diff --git a/archivers/7-zip/files/patch-C_CpuArch.c b/archivers/7-zip/files/patch-C_CpuArch.c index 579b684d4337..be204095f526 100644 --- a/archivers/7-zip/files/patch-C_CpuArch.c +++ b/archivers/7-zip/files/patch-C_CpuArch.c @@ -1,30 +1,38 @@ --- C/CpuArch.c.orig 2021-12-12 14:45:15 UTC +++ C/CpuArch.c -@@ -417,6 +417,23 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP +@@ -417,6 +417,31 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP #include <sys/auxv.h> +#if defined(__FreeBSD__) -+static UInt64 get_hwcap() { ++static unsigned long get_hwcap(int aux) { + unsigned long hwcap; -+ if(elf_aux_info(AT_HWCAP, &hwcap, sizeof(unsigned long)) != 0) { -+ return(0); ++ if (elf_aux_info(aux, &hwcap, sizeof hwcap) != 0) { ++ return 0; + } + return hwcap; +} + -+BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap() & HWCAP_CRC32; } ++#ifdef MY_CPU_ARM64 ++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP) & HWCAP_CRC32; } +BoolInt CPU_IsSupported_NEON(void) { return 1; } -+BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap() & HWCAP_SHA1; } -+BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap() & HWCAP_SHA2; } -+BoolInt CPU_IsSupported_AES(void) { return get_hwcap() & HWCAP_AES; } ++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP) & HWCAP_SHA1; } ++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP) & HWCAP_SHA2; } ++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP) & HWCAP_AES; } ++#else /* MY_CPU_ARM */ ++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_CRC32; } ++BoolInt CPU_IsSupported_NEON(void) { return get_hwcap(AT_HWCAP) & HWCAP_NEON; } ++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP2) & HWCAP2_SHA1; } ++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_SHA2; } ++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_AES; } ++#endif + +#else // __FreeBSD__ + #define USE_HWCAP #ifdef USE_HWCAP -@@ -450,6 +467,7 @@ MY_HWCAP_CHECK_FUNC (SHA1) +@@ -450,6 +475,7 @@ MY_HWCAP_CHECK_FUNC (SHA1) MY_HWCAP_CHECK_FUNC (SHA2) MY_HWCAP_CHECK_FUNC (AES) diff --git a/archivers/7-zip/files/patch-C_Sha1Opt.c b/archivers/7-zip/files/patch-C_Sha1Opt.c new file mode 100644 index 000000000000..335ae642521d --- /dev/null +++ b/archivers/7-zip/files/patch-C_Sha1Opt.c @@ -0,0 +1,11 @@ +--- C/Sha1Opt.c.orig 2022-04-12 16:00:26 UTC ++++ C/Sha1Opt.c +@@ -212,7 +212,7 @@ void MY_FAST_CALL Sha1_UpdateBlocks_HW(UInt32 state[5] + + #endif // USE_HW_SHA + +-#elif defined(MY_CPU_ARM_OR_ARM64) ++#elif defined(MY_CPU_ARM64) + + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check diff --git a/archivers/7-zip/files/patch-C_Sha256Opt.c b/archivers/7-zip/files/patch-C_Sha256Opt.c new file mode 100644 index 000000000000..3e1eaa16fe61 --- /dev/null +++ b/archivers/7-zip/files/patch-C_Sha256Opt.c @@ -0,0 +1,11 @@ +--- C/Sha256Opt.c.orig 2022-04-12 16:00:07 UTC ++++ C/Sha256Opt.c +@@ -212,7 +212,7 @@ void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[ + + #endif // USE_HW_SHA + +-#elif defined(MY_CPU_ARM_OR_ARM64) ++#elif defined(MY_CPU_ARM64) + + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204181142.23IBgSUK092723>