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 @@ -1,55 +1,60 @@ PORTNAME= 7-zip DISTVERSION= 21.07 PORTREVISION= 1 CATEGORIES= archivers MASTER_SITES= https://www.7-zip.org/a/ DISTNAME= 7z${DISTVERSION:S/.//}-src MAINTAINER= makc@FreeBSD.org COMMENT= Console version of the 7-Zip file archiver LICENSE= BSD3CLAUSE LGPL21+ UNRAR LICENSE_COMB= multi LICENSE_NAME_UNRAR= unRAR license LICENSE_FILE_BSD3CLAUSE= ${WRKSRC}/DOC/License.txt LICENSE_FILE_LGPL21+ = ${WRKSRC}/DOC/copying.txt LICENSE_FILE_UNRAR= ${WRKSRC}/DOC/unRarLicense.txt LICENSE_PERMS_UNRAR= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept LIB_DEPENDS= libsysinfo.so:devel/libsysinfo USES= 7z cpe dos2unix gmake localbase CPE_VENDOR= 7-zip MAKEFILE= ../../cmpl_clang.mak MAKE_ARGS= LOCAL_FLAGS="${CFLAGS}" \ LOCAL_LIBS="${LIBS} -lsysinfo" 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 PLIST_FILES= bin/7zz \ share/man/man1/7zz.1.gz PORTDOCS= 7zC.txt 7zFormat.txt License.txt Methods.txt \ lzma.txt readme.txt src-history.txt OPTIONS_DEFINE= DOCS post-patch: ${ECHO_CMD} > ${WRKSRC}/CPP/7zip/warn_clang.mak do-install: ${INSTALL_PROGRAM} ${BUILD_WRKSRC}/b/c/7zz ${STAGEDIR}/${PREFIX}/bin ${INSTALL_MAN} ${FILESDIR}/7zz.1 ${STAGEDIR}/${PREFIX}/share/man/man1 do-install-DOCS-on: ${MKDIR} ${STAGEDIR}${DOCSDIR} && \ ${INSTALL_DATA} ${PORTDOCS:C,^,${WRKSRC}/DOC/,} ${STAGEDIR}${DOCSDIR} .include 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,34 +1,42 @@ --- 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 +#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) +#endif // FreeBSD #endif // __APPLE__ #endif // _WIN32 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