Add support for BSD-ppc, BSD-ppc64 and BSD-ppc64le configurations
authorpkubaj <pkubaj@FreeBSD.org>
Sat, 20 Nov 2021 20:40:06 +0000 (20:40 +0000)
committerPauli <pauli@openssl.org>
Thu, 9 Dec 2021 05:07:14 +0000 (16:07 +1100)
OpenSSL assumes AT_HWCAP = 16 (as on Linux), but on FreeBSD AT_HWCAP = 25
Switch to using AT_HWCAP, and setting it to 16 if it is not defined.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17090)

Configurations/10-main.conf
Configure
crypto/ppccap.c
util/perl/OpenSSL/config.pm

index 9f8fb32a86c3e875d53df3a4b8d198def14ecc3e..071b1e5abead6c52c16522d05d220d42b8ab6973 100644 (file)
@@ -1070,6 +1070,31 @@ my %targets = (
         perlasm_scheme   => "linux64",
     },
 
+    "BSD-ppc" => {
+        inherit_from     => [ "BSD-generic32" ],
+        asm_arch         => 'ppc32',
+        perlasm_scheme   => "linux32",
+        lib_cppflags     => add("-DB_ENDIAN"),
+    },
+
+    "BSD-ppc64" => {
+        inherit_from     => [ "BSD-generic64" ],
+        cflags           => add("-m64"),
+        cxxflags         => add("-m64"),
+        lib_cppflags     => add("-DB_ENDIAN"),
+        asm_arch         => 'ppc64',
+        perlasm_scheme   => "linux64",
+    },
+
+    "BSD-ppc64le" => {
+        inherit_from     => [ "BSD-generic64" ],
+        cflags           => add("-m64"),
+        cxxflags         => add("-m64"),
+        lib_cppflags     => add("-DL_ENDIAN"),
+        asm_arch         => 'ppc64',
+        perlasm_scheme   => "linux64le",
+    },
+
     "bsdi-elf-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         CC               => "gcc",
index b00b91ac63f59c16b2f8215e9d1a3387c8766ea4..f48b7ab075ce78312277957a56d33b907d5a6531 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1549,7 +1549,7 @@ my %predefined_CXX = $config{CXX}
 
 unless ($disabled{asm}) {
     # big endian systems can use ELFv2 ABI
-    if ($target eq "linux-ppc64") {
+    if ($target eq "linux-ppc64" || $target eq "BSD-ppc64") {
         $target{perlasm_scheme} = "linux64v2" if ($predefined_C{_CALL_ELF} == 2);
     }
 }
index dca3c5342bf5ff2386a95db2a91491721365e693..da371a53457fde16b475c335e7c16c85567564d6 100644 (file)
@@ -117,14 +117,18 @@ static unsigned long getauxval(unsigned long key)
 #endif
 
 /* I wish <sys/auxv.h> was universally available */
-#define HWCAP                   16      /* AT_HWCAP */
+#ifndef AT_HWCAP
+# define AT_HWCAP               16      /* AT_HWCAP */
+#endif
 #define HWCAP_PPC64             (1U << 30)
 #define HWCAP_ALTIVEC           (1U << 28)
 #define HWCAP_FPU               (1U << 27)
 #define HWCAP_POWER6_EXT        (1U << 9)
 #define HWCAP_VSX               (1U << 7)
 
-#define HWCAP2                  26      /* AT_HWCAP2 */
+#ifndef AT_HWCAP2
+# define AT_HWCAP2              26      /* AT_HWCAP2 */
+#endif
 #define HWCAP_VEC_CRYPTO        (1U << 25)
 #define HWCAP_ARCH_3_00         (1U << 23)
 
@@ -215,8 +219,8 @@ void OPENSSL_cpuid_setup(void)
 
 #ifdef OSSL_IMPLEMENT_GETAUXVAL
     {
-        unsigned long hwcap = getauxval(HWCAP);
-        unsigned long hwcap2 = getauxval(HWCAP2);
+        unsigned long hwcap = getauxval(AT_HWCAP);
+        unsigned long hwcap2 = getauxval(AT_HWCAP2);
 
         if (hwcap & HWCAP_FPU) {
             OPENSSL_ppccap_P |= PPC_FPU;
index e3802ade433027cb323a219fbb1263a4914e86c1..50efef423ab2cac2eb529073a98f08973bc4ba98 100755 (executable)
@@ -739,8 +739,9 @@ EOF
                                     disable => [ 'sse2' ] } ],
       [ 'alpha.*-.*-.*bsd.*',     { target => "BSD-generic64",
                                     defines => [ 'L_ENDIAN' ] } ],
-      [ 'powerpc64-.*-.*bsd.*',   { target => "BSD-generic64",
-                                    defines => [ 'B_ENDIAN' ] } ],
+      [ 'powerpc-.*-.*bsd.*',     { target => "BSD-ppc" } ],
+      [ 'powerpc64-.*-.*bsd.*',   { target => "BSD-ppc64" } ],
+      [ 'powerpc64le-.*-.*bsd.*', { target => "BSD-ppc64le" } ],
       [ 'sparc64-.*-.*bsd.*',     { target => "BSD-sparc64" } ],
       [ 'ia64-.*-.*bsd.*',        { target => "BSD-ia64" } ],
       [ 'x86_64-.*-dragonfly.*',  { target => "BSD-x86_64" } ],