git: e2d67bee9eb0 - main - www/openssl: Fix detection of ARM CPU features

From: Bernard Spil <brnrd_at_FreeBSD.org>
Date: Tue, 23 Nov 2021 18:50:07 UTC
The branch main has been updated by brnrd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e2d67bee9eb05d8c48a054edd5b52938b1c1d576

commit e2d67bee9eb05d8c48a054edd5b52938b1c1d576
Author:     Bernard Spil <brnrd@FreeBSD.org>
AuthorDate: 2021-11-23 18:44:13 +0000
Commit:     Bernard Spil <brnrd@FreeBSD.org>
CommitDate: 2021-11-23 18:44:13 +0000

    www/openssl: Fix detection of ARM CPU features
    
    Upstream:
     * https://github.com/openssl/openssl/pull/17082
     * https://github.com/openssl/openssl/pull/17085
    
    PR:             259937
    Submitted by:   allanjude
    Differential Revision:  https://reviews.freebsd.org/D33061
---
 security/openssl/Makefile           |  1 +
 security/openssl/files/patch-D33061 | 53 +++++++++++++++++++++++++++++++++++++
 security/openssl/files/patch-config |  5 ++--
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/security/openssl/Makefile b/security/openssl/Makefile
index 10a456a04cc9..630a02c963ef 100644
--- a/security/openssl/Makefile
+++ b/security/openssl/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	openssl
 PORTVERSION=	1.1.1l
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	security devel
 MASTER_SITES=	https://www.openssl.org/source/ \
diff --git a/security/openssl/files/patch-D33061 b/security/openssl/files/patch-D33061
new file mode 100644
index 000000000000..2a917ab079c9
--- /dev/null
+++ b/security/openssl/files/patch-D33061
@@ -0,0 +1,53 @@
+Upstream:
+ * https://github.com/openssl/openssl/pull/17079
+ * https://github.com/openssl/openssl/pull/17084
+
+
+--- Configurations/10-main.conf.orig	2021-08-24 13:38:47.000000000 +0000
++++ Configurations/10-main.conf	2021-11-18 21:12:30.060493000 +0000
+@@ -988,6 +988,13 @@
+         perlasm_scheme   => "elf",
+     },
+ 
++    "BSD-aarch64" => {
++        inherit_from     => [ "BSD-generic64", asm("aarch64_asm") ],
++        lib_cppflags     => add("-DL_ENDIAN"),
++        bn_ops           => "SIXTY_FOUR_BIT_LONG",
++        perlasm_scheme   => "linux64",
++    },
++
+     "bsdi-elf-gcc" => {
+         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
+         CC               => "gcc",
+--- crypto/armcap.c.orig	2021-08-24 13:38:47 UTC
++++ crypto/armcap.c
+@@ -106,20 +106,23 @@ static unsigned long getauxval(unsigned long key)
+  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas
+  * AArch64 used AT_HWCAP.
+  */
++# ifndef AT_HWCAP
++#  define AT_HWCAP               16
++# endif
++# ifndef AT_HWCAP2
++#  define AT_HWCAP2              26
++# endif
+ # if defined(__arm__) || defined (__arm)
+-#  define HWCAP                  16
+-                                  /* AT_HWCAP */
++#  define HWCAP                  AT_HWCAP
+ #  define HWCAP_NEON             (1 << 12)
+ 
+-#  define HWCAP_CE               26
+-                                  /* AT_HWCAP2 */
++#  define HWCAP_CE               AT_HWCAP2
+ #  define HWCAP_CE_AES           (1 << 0)
+ #  define HWCAP_CE_PMULL         (1 << 1)
+ #  define HWCAP_CE_SHA1          (1 << 2)
+ #  define HWCAP_CE_SHA256        (1 << 3)
+ # elif defined(__aarch64__)
+-#  define HWCAP                  16
+-                                  /* AT_HWCAP */
++#  define HWCAP                  AT_HWCAP
+ #  define HWCAP_NEON             (1 << 1)
+ 
+ #  define HWCAP_CE               HWCAP
diff --git a/security/openssl/files/patch-config b/security/openssl/files/patch-config
index 753e22c6d62d..d83edae81ff7 100644
--- a/security/openssl/files/patch-config
+++ b/security/openssl/files/patch-config
@@ -1,6 +1,6 @@
---- config.orig	2018-01-13 13:57:15 UTC
+--- config.orig	2021-08-24 13:38:47 UTC
 +++ config
-@@ -694,14 +694,8 @@ case "$GUESSOS" in
+@@ -708,14 +708,9 @@ case "$GUESSOS" in
    ia64-*-*bsd*)		OUT="BSD-ia64" ;;
    x86_64-*-dragonfly*)  OUT="BSD-x86_64" ;;
    amd64-*-*bsd*)	OUT="BSD-x86_64" ;;
@@ -12,6 +12,7 @@
 -			    libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
 -			fi
 -			case "`(file -L $libc) 2>/dev/null`" in
++  arm64-*-*bsd*)	OUT="BSD-aarch64" ;;
 +  *86*-*-*bsd*)	
 +			case "`(file -L /bin/sh) 2>/dev/null`" in
  			*ELF*)	OUT="BSD-x86-elf" ;;