diff mbox series

[bug#49025,v4,core-updates,22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.

Message ID 20210619150458.12057-23-maximedevos@telenet.be
State Accepted
Headers show
Series Support cross-compilation with meson | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

M June 19, 2021, 3:04 p.m. UTC
By computing this value outside the build code, new targets
can be added without causing rebuilds for other targets.

* gnu/packages/tls.scm
  (target->openssl-target): New procedure.
  (openssl)[arguments]<#:phases>{set-cross-compile}: Use it.
---
 gnu/packages/tls.scm | 46 ++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

Comments

M July 3, 2021, 3:47 p.m. UTC | #1
Maxime Devos schreef op za 19-06-2021 om 17:04 [+0200]:
> By computing this value outside the build code, new targets
> can be added without causing rebuilds for other targets.
> 
> [...]

> +(define (target->openssl-target target)
> +  "Return the value to set CONFIGURE_TARGET_ARCH to when cross-compiling
> +OpenSSL for TARGET."
> +  ;; Keep this code outside the build code,
> +  ;; such that new targets can be added
> +  ;; without causing rebuilds for other targets.
> +  (cond ((string-prefix? "i586" target)
> +         "hurd-x86")

For example, this should really be
(and (hurd-target? target) (target-x86?)) (or was it x86-32?),
such that i686-pc-gnu would be recognised as a hurd-x86 target,
aarch64-pc-gnu isn't (ok the Hurd doesn't support aarch64),
and i586-linux-gnu would be recognised as GNU/Linux, not GNU/Hurd?

> +        ((string-prefix? "i686" target)
> +         "linux-x86") [...]

Similar reasoning as above.

This can be fixed later though (without going through any rebuilds
for supported triplets).

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 72a1cd8f0c..1ed43f0ebd 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -310,6 +310,31 @@  required structures.")
 (define-public guile3.0-gnutls
   (deprecated-package "guile3.0-gnutls" gnutls))
 
+(define (target->openssl-target target)
+  "Return the value to set CONFIGURE_TARGET_ARCH to when cross-compiling
+OpenSSL for TARGET."
+  ;; Keep this code outside the build code,
+  ;; such that new targets can be added
+  ;; without causing rebuilds for other targets.
+  (cond ((string-prefix? "i586" target)
+         "hurd-x86")
+        ((string-prefix? "i686" target)
+         "linux-x86")
+        ((string-prefix? "x86_64" target)
+         "linux-x86_64")
+        ((string-prefix? "mips64el" target)
+         "linux-mips64")
+        ((string-prefix? "arm" target)
+         "linux-armv4")
+        ((string-prefix? "aarch64" target)
+         "linux-aarch64")
+        ((string-prefix? "powerpc64le" target)
+         "linux-ppc64le")
+        ((string-prefix? "powerpc64" target)
+         "linux-ppc64")
+        ((string-prefix? "powerpc" target)
+         "linux-ppc")))
+
 (define-public openssl
   (package
    (name "openssl")
@@ -348,25 +373,8 @@  required structures.")
                (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
-                         (cond
-                           ((string-prefix? "i586" target)
-                            "hurd-x86")
-                           ((string-prefix? "i686" target)
-                            "linux-x86")
-                           ((string-prefix? "x86_64" target)
-                            "linux-x86_64")
-                           ((string-prefix? "mips64el" target)
-                            "linux-mips64")
-                           ((string-prefix? "arm" target)
-                            "linux-armv4")
-                           ((string-prefix? "aarch64" target)
-                            "linux-aarch64")
-                           ((string-prefix? "powerpc64le" target)
-                            "linux-ppc64le")
-                           ((string-prefix? "powerpc64" target)
-                            "linux-ppc64")
-                           ((string-prefix? "powerpc" target)
-                            "linux-ppc"))))))
+                         #$(target->openssl-target
+                            (%current-target-system))))))
              #~())
         (replace 'configure
           (lambda _