all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
@ 2021-06-14 15:22 Maxime Devos
  2021-06-14 16:04 ` Maxime Devos
                   ` (6 more replies)
  0 siblings, 7 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-14 15:22 UTC (permalink / raw)
  To: 49025

This patch series adds cross-compilation support to meson-build-system.
meson-build-system is used by many gtk applications (sometimes directly,
sometimes because a dependency uses meson-build-system).

This has been tested with

  ./pre-inst-env guix build --target=i686-linux-gnu glib

on a x86_64-linux system. The build succeeds, and
"guix gc --references ..." looked reasonable to me.

Meson cross-compilation is implemented by the last patch.
The one-before-last patch works-around the brokenness of
GCC cross-compilers on current core-updates
(see <http://issues.guix.gnu.org/48913>;).

The first two patches define a few utilities target-linux?,
target-x86-32? and target-x86-64? which are used by the last patch,
but could be useful elsewhere as well. The third patch is used
in various cross-compilation fixes.

The other 34 patches are cross-compilation fixes for dependencies
of glib, and follow-up patches making the package definitions
somewhat nicer IMHO (like removing trailing #t from phases,
and computing derivation for some architecture-independent packages
when cross-compiling and compiling natively).

Maxime Devos (37):
  utils: Define target-linux? predicate.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Make #:builder argument a G-expression.
  net-base: Fix cross-compilation, eliminating %build-inputs & friends
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpgerror: Maybe fix a cross-compilation bug.
  libgpg-error: Fix cross-compilation error.
  libgcrypt: Fix cross-compilation build error.
  wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  wrap-python3: Fix cross-compilation.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Find bin/env when cross-compiling.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  readline: Make #:configure-flags a G-expression.
  readline: Fix build error when cross-compiling.
  bash: Make #:configure-flags a G-expression.
  bash: Fix cross-compilation build error.
  fontconfig: Make the #:configure-flags argument a G-expression.
  fontconfig: Fix build error when cross-compiling.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  tk: Make #:configure-flags a G-expression.
  tk: Do not use %build-inputs when cross-compiling.
  libelf: Use the cross-compiler when cross-compiling.
  opendht: Correct 'nettle' variable name in inputs.
  cross-base: Fix cross-compiler for i686-linux-gnu.
  meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |  44 ++++---
 gnu/packages/base.scm              |   9 ++
 gnu/packages/bash.scm              |  39 +++---
 gnu/packages/cross-base.scm        |  63 ++++++++-
 gnu/packages/elf.scm               |  48 ++++---
 gnu/packages/fontutils.scm         |   8 +-
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  60 ++++++---
 gnu/packages/networking.scm        |   2 +-
 gnu/packages/python.scm            |  51 ++++----
 gnu/packages/readline.scm          |  27 ++--
 gnu/packages/tcl.scm               |  14 +-
 gnu/packages/tls.scm               | 142 ++++++++++----------
 guix/build-system/meson.scm        | 200 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 ++++++++++
 guix/packages.scm                  |  29 +++++
 guix/utils.scm                     |  26 ++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 20 files changed, 728 insertions(+), 214 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm


base-commit: 92803cbef5affa3dbbf049262e1fcf290d8d8622





^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
@ 2021-06-14 16:04 ` Maxime Devos
  2021-06-18  7:55 ` Mathieu Othacehe
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-14 16:04 UTC (permalink / raw)
  To: 49025

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Maxime Devos schreef op ma 14-06-2021 om 17:22 [+0200]:
>   opendht: Correct 'nettle' variable name in inputs.

This patch is not a cross-compilation fix.
It doesn't belong in this patch series.
Still a fix though.  I think it would address
the recent evaluation failures on ci.guix.gnu.org
for core-updates.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
  2021-06-14 16:04 ` Maxime Devos
@ 2021-06-18  7:55 ` Mathieu Othacehe
  2021-06-18  8:01   ` Mathieu Othacehe
                     ` (2 more replies)
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                   ` (4 subsequent siblings)
  6 siblings, 3 replies; 175+ messages in thread
From: Mathieu Othacehe @ 2021-06-18  7:55 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025


Hello Maxime,

I had a first look to this patchset, this is awesome work. I like how
you use G-exp in build expressions to fix cross-compilation issues.

I'd like to apply your patches to review them more closely, but I'm
having some troubles applying them from GNUS. Did you use "git
send-email" or another mechanism?

It would also be great if we could manage to have meson cross-compile
binaries for armhf/aarch64. As we do not have many substitutes for those
architectures, being able to cross-compile fully-featured images has
been a goal of mine for many years.

In the meantime, I applied the 35th patch hoping to fix Cuirass
evaluations on the core-updates branch.

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-18  7:55 ` Mathieu Othacehe
@ 2021-06-18  8:01   ` Mathieu Othacehe
  2021-06-18 12:32   ` Ludovic Courtès
  2021-06-18 14:58   ` Maxime Devos
  2 siblings, 0 replies; 175+ messages in thread
From: Mathieu Othacehe @ 2021-06-18  8:01 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025


> In the meantime, I applied the 35th patch hoping to fix Cuirass
> evaluations on the core-updates branch.

Turns out it is already fixed by
b4ad57ae3e5249ee7402b2ab3c41104ce9c01529 and core-updates evaluations
are still broken :(.

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-18  7:55 ` Mathieu Othacehe
  2021-06-18  8:01   ` Mathieu Othacehe
@ 2021-06-18 12:32   ` Ludovic Courtès
  2021-06-18 14:58   ` Maxime Devos
  2 siblings, 0 replies; 175+ messages in thread
From: Ludovic Courtès @ 2021-06-18 12:32 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: Maxime Devos, 49025

Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> I'd like to apply your patches to review them more closely, but I'm
> having some troubles applying them from GNUS. Did you use "git
> send-email" or another mechanism?

Patches are attached, which makes it a bit trickier to apply them.
Unfortunately mumi seems to be unable to extract them via URLs like
<https://issues.guix.gnu.org/issue/49025/patch-set/0>.

Ludo’.




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-18  7:55 ` Mathieu Othacehe
  2021-06-18  8:01   ` Mathieu Othacehe
  2021-06-18 12:32   ` Ludovic Courtès
@ 2021-06-18 14:58   ` Maxime Devos
  2 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 14:58 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 49025

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

Mathieu Othacehe schreef op vr 18-06-2021 om 09:55 [+0200]:
> Hello Maxime,
> 
> I had a first look to this patchset, this is awesome work. I like how
> you use G-exp in build expressions to fix cross-compilation issues.
> 
> I'd like to apply your patches to review them more closely, but I'm
> having some troubles applying them from GNUS. Did you use "git
> send-email" or another mechanism?

Some combination of "git send-email", "git format-patch --stdout --attach origin",
"git imap-send", manually fixing "References", "In-Reply-To" and "To" headers,
moving the mails to the ‘outbox’ of the e-mail client, trying to
flush the outbox, which didn't do anything and opening the mails in the outbox and
sending them individually.

I'll resend the patches with "git send-email", as a v2 (but the content is
identical).

> It would also be great if we could manage to have meson cross-compile
> binaries for armhf/aarch64. [...

I was thinking of cross-compiling of cross-compiling for the Hurd.
The glib-or-gtk-build-system would need cross-building support as well,
but it's ‘merely’ a variant of gnu-build-system with two extra phases,
so that should be easy.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate.
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
  2021-06-14 16:04 ` Maxime Devos
  2021-06-18  7:55 ` Mathieu Othacehe
@ 2021-06-18 16:09 ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
                     ` (36 more replies)
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                   ` (3 subsequent siblings)
  6 siblings, 37 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-linux?): New predicate.
* tests/utils.scm
  ("target-linux?"): Test it.
  ("target-mingw?"): Also test ‘target-mingw?’.
---
 guix/utils.scm  |  6 ++++++
 tests/utils.scm | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19990ceb8a..4ff2602e23 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,6 +82,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -543,6 +545,10 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  (string-contains target "linux"))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25552..80a0e669a4 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,22 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map (compose ->bool target-linux?)
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map (compose ->bool target-mingw?)
+       '("i686-linux-gnu" "i686-pc-gnu"
+         "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 02/37] utils: Define a target-x86-32? and target-x86-64? predicate.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
                     ` (35 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
---
 guix/utils.scm  | 20 ++++++++++++++++++++
 tests/utils.scm | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 4ff2602e23..2256ea2ca6 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -84,6 +84,8 @@
             package-name->name+version
             target-linux?
             target-mingw?
+            target-x86-32?
+            target-x86-64?
             target-arm32?
             target-aarch64?
             target-arm?
@@ -553,6 +555,24 @@ a character other than '@'."
   (and target
        (string-suffix? "-mingw32" target)))
 
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+                                                (%current-system))))
+  "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+  ;; Intel also has a 16-bit architecture in the iN86 series, i286
+  ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+  ;; procedure is not named target-x86?.
+  (or (string-prefix? "i386-" target)
+      (string-prefix? "i486-" target)
+      (string-prefix? "i586-" target)
+      (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+                                                 (%current-system))))
+  "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+  (string-prefix? "x86_64-" target))
+
 (define* (target-arm32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index 80a0e669a4..92439b5587 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
        '("i686-linux-gnu" "i686-pc-gnu"
          "i686-w64-mingw32")))
 
+(test-equal "target-x86-32?"
+  '(#f #f #f #t #t #t #t #f)
+  ;; These are (according to Wikipedia) two RISC architectures
+  ;; by Intel and presumably not compatible with the x86-32 series.
+  (map target-x86-32?
+       '("i860-gnu" "i960-gnu"
+         ;; This is a 16-bit architecture
+         "i286-gnu"
+         ;; These are part of the x86-32 series.
+         "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+         ;; Maybe this one will exist some day, but not yet.
+         "i786-gnu")))
+
+(test-equal "target-x86-64?"
+  '(#t #f #f #f)
+  (map target-x86-64?
+       `("x86_64-linux-gnu" "i386-linux-gnu"
+         ;; Just because it includes "64" doesn't make it 64-bit.
+         "aarch64-linux-gnu"
+         ;; Note that (expt 2 109) in decimal notation starts with 64.
+         ;; However, it isn't 32-bit.
+         ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 03/37] packages: Define this-package-input and this-package-native-input.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
                     ` (34 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index a66dbea1b7..80c8bbebf0 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47d10af5bc..91ec38e4cc 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1851,6 +1852,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 04/37] net-base: Make #:builder argument a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
                     ` (33 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp-native and this-package-native-input later.

* gnu/packages/admin.scm (net-base)[arguments]{#:builder}: Make this
  a G-expression.
---
 gnu/packages/admin.scm | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 531686fdbb..5c7e41f51b 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -74,6 +74,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages autogen)
@@ -936,25 +937,25 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
-       #:builder (begin
-                   (use-modules (guix build utils)
-                                (srfi srfi-26))
-
-                   (let* ((source (assoc-ref %build-inputs "source"))
-                          (tar    (assoc-ref %build-inputs "tar"))
-                          (xz     (assoc-ref %build-inputs "xz"))
-                          (output (assoc-ref %outputs "out"))
-                          (etc    (string-append output "/etc")))
-                     (setenv "PATH" (string-append xz "/bin"))
-                     (invoke (string-append tar "/bin/tar") "xvf"
-                             source)
-                     (chdir ,(string-append "netbase-" version))
-                     (mkdir-p etc)
-                     (for-each copy-file
-                               '("etc-services" "etc-protocols" "etc-rpc")
-                               (map (cut string-append etc "/" <>)
-                                    '("services" "protocols" "rpc")))
-                     #t))))
+       #:builder ,#~(begin
+                      (use-modules (guix build utils)
+                                   (srfi srfi-26))
+
+                      (let* ((source (assoc-ref %build-inputs "source"))
+                             (tar    (assoc-ref %build-inputs "tar"))
+                             (xz     (assoc-ref %build-inputs "xz"))
+                             (output (assoc-ref %outputs "out"))
+                             (etc    (string-append output "/etc")))
+                        (setenv "PATH" (string-append xz "/bin"))
+                        (invoke (string-append tar "/bin/tar") "xvf"
+                                source)
+                        (chdir #$(string-append "netbase-" version))
+                        (mkdir-p etc)
+                        (for-each copy-file
+                                  '("etc-services" "etc-protocols" "etc-rpc")
+                                  (map (cut string-append etc "/" <>)
+                                       '("services" "protocols" "rpc")))
+                        #t))))
     (native-inputs `(("tar" ,tar)
                      ("xz" ,xz)))
     (synopsis "IANA protocol, port, and RPC number assignments")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (2 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 06/37] net-base: Don't cross-compile Maxime Devos
                     ` (32 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"source" is not in %build-inputs when cross-compiling, so another
approach for referring to the package source code is needed.

* gnu/packages/admin.scm (net-base)[arguments]<#:builder>: Eliminate
  %build-inputs and %outputs.
---
 gnu/packages/admin.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 5c7e41f51b..f499a1252b 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -941,10 +941,10 @@ to allow automatic login and starting any app.")
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
 
-                      (let* ((source (assoc-ref %build-inputs "source"))
-                             (tar    (assoc-ref %build-inputs "tar"))
-                             (xz     (assoc-ref %build-inputs "xz"))
-                             (output (assoc-ref %outputs "out"))
+                      (let* ((source #+(package-source this-package))
+                             (tar    #+(this-package-native-input "tar"))
+                             (xz     #+(this-package-native-input "xz"))
+                             (output #$output)
                              (etc    (string-append output "/etc")))
                         (setenv "PATH" (string-append xz "/bin"))
                         (invoke (string-append tar "/bin/tar") "xvf"
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 06/37] net-base: Don't cross-compile.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (3 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
                     ` (31 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

net-base is pure data, so cross-compiling is pointless.

* gnu/packages/admin.scm
  (net-base)[arguments]<#:target>: Set to #f.
  (net-base)[arguments]<#:allowed-references>: Disallow all
  references.
---
 gnu/packages/admin.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index f499a1252b..5e41ba9967 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -937,6 +937,11 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
+       ;; This package consists solely of architecture-independent
+       ;; tables. Cross-compilation is pointless! Make sure we'll
+       ;; always get the same derivation.
+       #:target #f
+       #:allowed-references ()
        #:builder ,#~(begin
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 07/37] tzdata: Don't bother with cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (4 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 06/37] net-base: Don't cross-compile Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
                     ` (30 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

The time zone database is architecture-independent,
so trying to cross-compile it is pointless!

* gnu/packages/base.scm
  (tzdata)[arguments]<#:target>: Set to #f.
  (tzdata)[allowed-references]: Only include the "out" output itself,
  to make sure no (architecture-dependent) binaries are installed.
---
 gnu/packages/base.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index d30299a7b6..2674be8048 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1251,6 +1252,14 @@ command.")
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f
+       ;; This consists purely of (architecture-independent) data,
+       ;; so ‘cross-compilation’ is pointless here!
+       ;; (The binaries zic, dump, and tzselect are deleted in the post-install
+       ;; phase.)
+       #:target #f
+       ;; share/zoneinfo/posix is a symlink to share/zoneinfo,
+       ;; so include the package itself in #:allowed-references.
+       #:allowed-references ("out")
        #:make-flags (let ((out (assoc-ref %outputs "out"))
                           (tmp (getenv "TMPDIR")))
                       (list (string-append "TOPDIR=" out)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 08/37] libgpg-error: Remove trailing #f from phases.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (5 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
                     ` (29 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These aren't required anymore.

* gnu/packages/gnupg.scm (libgpgerror)[arguments]{cross-symlinks}:
  Remove trailing #f.
---
 gnu/packages/gnupg.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index cb481b38e1..2f44e6ec6a 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -114,8 +114,7 @@
                            (string-append x "-unknown-linux-gnu")))))
                    (symlink
                     (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))
-                 #t))))
+                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 09/37] libgpg-error: Prevent silent miscompilation some systems.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (6 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
                     ` (28 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/gpg.scm
  (libgpgerror)[arguments]<#:phases>{cross-symlinks}: Only
  link to src/syscfg/lock-obj-pub.linux-gnu.h if the package
  is being compiled for a Linux target. Do not link either
  if the architecture is unknown, as the headers vary with
  the architecture.
---
 gnu/packages/gnupg.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 2f44e6ec6a..de213d381f 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
 (define-public libgpg-error
@@ -94,27 +96,37 @@
     (build-system gnu-build-system)
     (arguments
      (if (%current-target-system)
-         `(#:modules ((ice-9 match)
-                      (guix build gnu-build-system)
+         `(#:modules ((guix build gnu-build-system)
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
-             ;; file. See Cross-Compiling section at:
+             ;; file if required. Note that these platform files depend on
+             ;; both the operating system and architecture!
+             ;;
+             ;; See Cross-Compiling section at:
              ;; https://github.com/gpg/libgpg-error/blob/master/README
              (add-after 'unpack 'cross-symlinks
-               (lambda* (#:key target inputs #:allow-other-keys)
-                 (let ((triplet
-                        (match (string-take target
-                                            (string-index target #\-))
-                          ("armhf" "arm-unknown-linux-gnueabi")
-                          ("mips64el" "mips-unknown-linux-gnu")
-                          (x
-                           (string-append x "-unknown-linux-gnu")))))
-                   (symlink
-                    (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
+               (lambda _
+                 (define (link triplet source)
+                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                            (string-append "src/syscfg/lock-obj-pub."
+                                           source ".h")))
+                 ,(let* ((target (%current-target-system))
+                         (architecture
+                          (string-take target (string-index target #\-))))
+                    (cond ((target-linux? target)
+                           (match architecture
+                             ("armhf"
+                              `(link "arm-unknown-linux-gnueabi" "linux-gnu"))
+                             ("mips64el"
+                              `(link "mips-unknown-linux-gnu" "linux-gnu"))
+                             ;; Don't always link to the "linux-gnu"
+                             ;; configuration, as this is not correct for
+                             ;; all architectures.
+                             (_ #t)))
+                          (#t #t)))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 10/37] libgpgerror: Maybe fix a cross-compilation bug.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (7 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
                     ` (27 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Previously, a symlink was created at
src/syscfg/lock-obj-pub.linux-gnu.h pointing at
lock-obj-pub.MANGLED-TARGET.h. I would think this has
to be the other way around, but I am not really sure.

* gnu/packages/gnupg.scm
  (gnupg)[arguments]<#:phases>{cross-symlinks}(link): Switch
  'triplet' and 'source'.
---
 gnu/packages/gnupg.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index de213d381f..f5d4118af9 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -110,9 +110,9 @@
              (add-after 'unpack 'cross-symlinks
                (lambda _
                  (define (link triplet source)
-                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                   (symlink (string-append "lock-obj-pub." source ".h")
                             (string-append "src/syscfg/lock-obj-pub."
-                                           source ".h")))
+                                           triplet ".h")))
                  ,(let* ((target (%current-target-system))
                          (architecture
                           (string-take target (string-index target #\-))))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 11/37] libgpg-error: Fix cross-compilation error.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (8 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
                     ` (26 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

TODO: inform upstream about the cross-compilation error.

* gnu/packages/gnupg.scm
  (libgpg-error)[arguments]{fix-gen-lock-obj.sh}: Prevent generated
  header files from being sprinkled with ‘\c’.
---
 gnu/packages/gnupg.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index f5d4118af9..1fee30584c 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -100,6 +100,13 @@
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
+             ;; If this is left out, some generated header
+             ;; files will be sprinkled with ‘\c’, which
+             ;; the compiler won't like.
+             (add-after 'unpack 'fix-gen-lock-obj.sh
+               (lambda _
+                 (substitute* "src/gen-lock-obj.sh"
+                   (("if test -n `echo -n`") "if ! test -n `echo -n`"))))
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
              ;; file if required. Note that these platform files depend on
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 12/37] libgcrypt: Fix cross-compilation build error.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (9 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
                     ` (25 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling a package using gnu-build-system,
%build-inputs does not exist. But libgcrypt uses %build-inputs
anyway. Fix it.

* gnu/packages/gnupg.scm
  (libgcrypt)[arguments]<#:configure-flags>: Make this a G-exp
  instead of a raw S-exp. Eliminate %build-inputs and use
  this-package-input instead.
---
 gnu/packages/gnupg.scm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 1fee30584c..35cfdf6f43 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -74,6 +74,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
@@ -169,11 +170,12 @@ Daemon and possibly more in the future.")
      ;; 'configure' uses 'gpg-error-config' to determine the '-L' flag, and
      ;; the 'gpg-error-config' it runs is the native one---i.e., the wrong one.
      `(#:configure-flags
-       (list (string-append "--with-gpg-error-prefix="
-                            (assoc-ref %build-inputs "libgpg-error-host"))
-             ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
-             ,@(if (%current-target-system) '("--disable-asm")
-                   '()))))
+       ,#~(list (string-append "--with-gpg-error-prefix="
+                               #$(this-package-input "libgpg-error-host"))
+                ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
+                #$@(if (%current-target-system)
+                       #~("--disable-asm")
+                       #~()))))
     (outputs '("out" "debug"))
     (home-page "https://gnupg.org/")
     (synopsis "Cryptographic function library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (10 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 14/37] wrap-python3: Fix cross-compilation Maxime Devos
                     ` (24 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp later.

* gnu/packages/python.scm (wrap-python3)<#:builder>: Make this
  a G-expression.
---
 gnu/packages/python.scm | 46 ++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index b2ec486d7a..9628836567 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -573,29 +573,29 @@ for more information.")))
     (arguments
      `(#:modules ((guix build utils))
        #:builder
-         (begin
-           (use-modules (guix build utils))
-           (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                 (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
-                (mkdir-p bin)
-                (for-each
-                  (lambda (old new)
-                    (symlink (string-append python old)
-                             (string-append bin "/" new)))
-                  `("python3" ,"pydoc3" ,"idle3" ,"pip3")
-                  `("python"  ,"pydoc"  ,"idle"  ,"pip"))
-                ;; python-config outputs search paths based upon its location,
-                ;; use a bash wrapper to avoid changing its outputs.
-                (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                           "/bin/bash"))
-                      (old  (string-append python "python3-config"))
-                      (new  (string-append bin "/python-config")))
-                  (with-output-to-file new
-                    (lambda ()
-                      (format #t "#!~a~%" bash)
-                      (format #t "exec \"~a\" \"$@\"~%" old)
-                      (chmod new #o755)
-                      #t)))))))
+       ,#~(begin
+            (use-modules (guix build utils))
+            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
+                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
+              (mkdir-p bin)
+              (for-each
+               (lambda (old new)
+                 (symlink (string-append python old)
+                          (string-append bin "/" new)))
+               `("python3" ,"pydoc3" ,"idle3" ,"pip3")
+               `("python"  ,"pydoc"  ,"idle"  ,"pip"))
+              ;; python-config outputs search paths based upon its location,
+              ;; use a bash wrapper to avoid changing its outputs.
+              (let ((bash (string-append (assoc-ref %build-inputs "bash")
+                                         "/bin/bash"))
+                    (old  (string-append python "python3-config"))
+                    (new  (string-append bin "/python-config")))
+                (with-output-to-file new
+                  (lambda ()
+                    (format #t "#!~a~%" bash)
+                    (format #t "exec \"~a\" \"$@\"~%" old)
+                    (chmod new #o755)
+                    #t)))))))
     (synopsis "Wrapper for the Python 3 commands")
     (description
      "This package provides wrappers for the commands of Python@tie{}3.x such
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 14/37] wrap-python3: Fix cross-compilation.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (11 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 15/37] python: Fix reference to input when cross-compiling Maxime Devos
                     ` (23 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling, "bash" is missing from %build-inputs,
leading to a build error. Use this-package-input instead of
%build-inputs to resolve this. While we're at it, eliminate
all uses of %outputs and %build-inputs.

* gnu/packages/python.scm
  (wrap-python3)[arguments]<#:builder>: Eliminte %outputs
  and %build-inputs.
---
 gnu/packages/python.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 9628836567..fbad0b65b8 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -60,6 +60,7 @@
 ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -575,8 +576,8 @@ for more information.")))
        #:builder
        ,#~(begin
             (use-modules (guix build utils))
-            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
+            (let ((bin (string-append #$output "/bin"))
+                  (python #$(file-append (this-package-input "python") "/bin/")))
               (mkdir-p bin)
               (for-each
                (lambda (old new)
@@ -586,8 +587,7 @@ for more information.")))
                `("python"  ,"pydoc"  ,"idle"  ,"pip"))
               ;; python-config outputs search paths based upon its location,
               ;; use a bash wrapper to avoid changing its outputs.
-              (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                         "/bin/bash"))
+              (let ((bash #$(file-append (this-package-input "bash") "/bin/bash"))
                     (old  (string-append python "python3-config"))
                     (new  (string-append bin "/python-config")))
                 (with-output-to-file new
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 15/37] python: Fix reference to input when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (12 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 14/37] wrap-python3: Fix cross-compilation Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 16/37] openssl: Remove trailing #t from phases Maxime Devos
                     ` (22 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"sitecustomize.py" is a native input, so look it up
in 'native-inputs', not 'inputs'.

* gnu/packages/python.scm (customize-site): Look up "sizecustomize.py"
  in 'native-inputs', not 'inputs'.
---
 gnu/packages/python.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index fbad0b65b8..f004b8e739 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -111,13 +111,14 @@
 
 (define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
-  `(lambda* (#:key inputs outputs #:allow-other-keys)
+  `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
-            (sitecustomize.py (assoc-ref inputs "sitecustomize.py"))
+            (sitecustomize.py (assoc-ref (or native-inputs inputs)
+                                         "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 16/37] openssl: Remove trailing #t from phases.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (13 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 15/37] python: Fix reference to input when cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
                     ` (21 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Delete trailing #t.
---
 gnu/packages/tls.scm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 608a7d05b8..5bfc5545db 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -366,8 +366,7 @@ required structures.")
                            ((string-prefix? "powerpc64" target)
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
-                            "linux-ppc")))
-                 #t)))
+                            "linux-ppc"))))))
            '())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
@@ -406,8 +405,7 @@ required structures.")
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
-                        (find-files lib "\\.a$"))
-              #t)))
+                        (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda* (#:key outputs #:allow-other-keys)
                ;; Move man3 pages and full HTML documentation to "doc".
@@ -420,8 +418,7 @@ required structures.")
                  (copy-recursively man3 man-target)
                  (delete-file-recursively man3)
                  (copy-recursively html html-target)
-                 (delete-file-recursively html)
-                 #t)))
+                 (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
          (lambda* (#:key outputs #:allow-other-keys)
@@ -430,8 +427,7 @@ required structures.")
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
                                                      ,(package-version this-package)
-                                                     "/misc"))
-             #t))))))
+                                                     "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 17/37] openssl: Make the #:phases argument a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (14 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 16/37] openssl: Remove trailing #t from phases Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
                     ` (20 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-native-input later.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Make this a G-expression.
  (openssl-1.0)[arguments]<#:phases>: Likewise.
---
 gnu/packages/tls.scm | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 5bfc5545db..9de9a78e84 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -38,6 +38,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -341,9 +342,10 @@ required structures.")
       ;; so we explicitly disallow it here.
       #:disallowed-references ,(list (canonical-package perl))
       #:phases
+      ,#~
       (modify-phases %standard-phases
-       ,@(if (%current-target-system)
-           '((add-before
+       #$@(if (%current-target-system)
+          #~((add-before
                'configure 'set-cross-compile
                (lambda* (#:key target outputs #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
@@ -367,7 +369,7 @@ required structures.")
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
                             "linux-ppc"))))))
-           '())
+             #~())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
@@ -377,9 +379,9 @@ required structures.")
                 (("/usr/bin/env")
                  (string-append (assoc-ref %build-inputs "coreutils")
                                 "/bin/env")))
-              (invoke ,@(if (%current-target-system)
-                          '("./Configure")
-                          '("./config"))
+              (invoke #$@(if (%current-target-system)
+                             #~("./Configure")
+                             #~("./config"))
                       "shared"       ;build shared libraries
                       "--libdir=lib"
 
@@ -388,13 +390,13 @@ required structures.")
                       ;; conventional.
                       (string-append "--openssldir=" out
                                      "/share/openssl-"
-                                     ,(package-version this-package))
+                                     #$(package-version this-package))
 
                       (string-append "--prefix=" out)
                       (string-append "-Wl,-rpath," lib)
-                      ,@(if (%current-target-system)
-                          '((getenv "CONFIGURE_TARGET_ARCH"))
-                          '())))))
+                      #$@(if (%current-target-system)
+                             #~((getenv "CONFIGURE_TARGET_ARCH"))
+                             #~())))))
         (add-after 'install 'move-static-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Move static libraries to the "static" output.
@@ -426,7 +428,7 @@ required structures.")
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
-                                                     ,(package-version this-package)
+                                                     #$(package-version this-package)
                                                      "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
@@ -471,7 +473,7 @@ required structures.")
        ;; Parallel build is not supported in 1.0.x.
        ((#:parallel-build? _ #f) #f)
        ((#:phases phases)
-        `(modify-phases ,phases
+       #~(modify-phases #$phases
            (add-before 'patch-source-shebangs 'patch-tests
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
@@ -494,9 +496,9 @@ required structures.")
 	     ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
 	     (lambda* (#:key outputs #:allow-other-keys)
 	       (let ((out (assoc-ref outputs "out")))
-		 (invoke ,@(if (%current-target-system)
-			       '("./Configure")
-			       '("./config"))
+		 (invoke #$@(if (%current-target-system)
+			        #~("./Configure")
+			        #~("./config"))
 			 "shared"                 ;build shared libraries
 			 "--libdir=lib"
 
@@ -504,12 +506,12 @@ required structures.")
 			 ;; PREFIX/ssl.  Change that to something more
 			 ;; conventional.
 			 (string-append "--openssldir=" out
-					"/share/openssl-" ,version)
+					"/share/openssl-" #$version)
 
 			 (string-append "--prefix=" out)
-			 ,@(if (%current-target-system)
-			       '((getenv "CONFIGURE_TARGET_ARCH"))
-			       '())))))
+			 #$@(if (%current-target-system)
+			        '((getenv "CONFIGURE_TARGET_ARCH"))
+			        '())))))
         (delete 'move-extra-documentation)
         (add-after 'install 'move-man3-pages
           (lambda* (#:key outputs #:allow-other-keys)
@@ -534,7 +536,7 @@ required structures.")
                ;; scripts.  Remove them to avoid retaining a reference on Perl.
                (let ((out (assoc-ref outputs "out")))
                  (delete-file-recursively (string-append out "/share/openssl-"
-                                                         ,version "/misc"))
+                                                         #$version "/misc"))
                  #t)))))))))
 
 (define-public libressl
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 18/37] openssl: Use G-exp machinery for referring to outputs.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (15 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
                     ` (19 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This doesn't fix anything broken, just for simplifying
the code a little while we're rebuilding the world anyway.
IMHO this makes the code a little more readable.

* gnu/packages/tls.scm (openssl)[arguments]<#:phases>: Don't refer
  to the association list 'outputs', use #$output, #$output:doc
  and #$output:static instead.
---
 gnu/packages/tls.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 9de9a78e84..90211c733d 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -347,7 +348,7 @@ required structures.")
        #$@(if (%current-target-system)
           #~((add-before
                'configure 'set-cross-compile
-               (lambda* (#:key target outputs #:allow-other-keys)
+               (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
                          (cond
@@ -371,8 +372,8 @@ required structures.")
                             "linux-ppc"))))))
              #~())
         (replace 'configure
-          (lambda* (#:key outputs #:allow-other-keys)
-            (let* ((out (assoc-ref outputs "out"))
+          (lambda _
+            (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
               (substitute* "config"
@@ -398,23 +399,23 @@ required structures.")
                              #~((getenv "CONFIGURE_TARGET_ARCH"))
                              #~())))))
         (add-after 'install 'move-static-libraries
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
             ;; Move static libraries to the "static" output.
-            (let* ((out    (assoc-ref outputs "out"))
+            (let* ((out    #$output)
                    (lib    (string-append out "/lib"))
-                   (static (assoc-ref outputs "static"))
+                   (static #$output:static)
                    (slib   (string-append static "/lib")))
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
                ;; Move man3 pages and full HTML documentation to "doc".
-               (let* ((out    (assoc-ref outputs "out"))
+               (let* ((out    #$output)
                       (man3   (string-append out "/share/man/man3"))
                       (html (string-append out "/share/doc/openssl"))
-                      (doc    (assoc-ref outputs "doc"))
+                      (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
                  (copy-recursively man3 man-target)
@@ -423,13 +424,12 @@ required structures.")
                  (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
-         (lambda* (#:key outputs #:allow-other-keys)
+         (lambda _
            ;; The 'misc' directory contains random undocumented shell and Perl
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
-           (let ((out (assoc-ref outputs "out")))
-             (delete-file-recursively (string-append out "/share/openssl-"
-                                                     #$(package-version this-package)
-                                                     "/misc"))))))))
+           (delete-file-recursively (string-append #$output "/share/openssl-"
+                                                   #$(package-version this-package)
+                                                   "/misc")))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 19/37] openssl: Move documentation instead of copying and deleting it.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (16 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
                     ` (18 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Use
  'rename-file' instead of 'copy-recursively' and
  'delete-file-recursively'.
---
 gnu/packages/tls.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 90211c733d..9aa0b5a212 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -418,10 +418,10 @@ required structures.")
                       (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (copy-recursively man3 man-target)
-                 (delete-file-recursively man3)
-                 (copy-recursively html html-target)
-                 (delete-file-recursively html))))
+                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname html-target))
+                 (rename-file man3 man-target)
+                 (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
          (lambda _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 20/37] openssl: Move all man pages to separate output, not only man3.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (17 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
                     ` (17 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

There does not seem to be any reason to only move man3 pages.
So, move all man pages to a separate output for documentation.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Move
  all man pages, not only man3.
---
 gnu/packages/tls.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 9aa0b5a212..c178806805 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -411,16 +411,16 @@ required structures.")
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda _
-               ;; Move man3 pages and full HTML documentation to "doc".
+               ;; Move man pages and full HTML documentation to "doc".
                (let* ((out    #$output)
-                      (man3   (string-append out "/share/man/man3"))
-                      (html (string-append out "/share/doc/openssl"))
+                      (man    (string-append out "/share/man"))
+                      (html   (string-append out "/share/doc/openssl"))
                       (doc    #$output:doc)
-                      (man-target (string-append doc "/share/man/man3"))
+                      (man-target (string-append doc "/share/man"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname man-target))
                  (mkdir-p (dirname html-target))
-                 (rename-file man3 man-target)
+                 (rename-file man man-target)
                  (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 21/37] openssl: Find bin/env when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (18 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
                     ` (16 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so find bin/env by another way.

* (openssl)[arguments]<#:phases>{configure}: Don't use '%build-inputs',
  use 'which' instead.
---
 gnu/packages/tls.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index c178806805..a4e754e27f 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -376,10 +376,10 @@ required structures.")
             (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
+              ;; Don't use (assoc-ref %build-inputs "coreutils"), as
+              ;; %build-inputs is not defined when cross-compiling.
               (substitute* "config"
-                (("/usr/bin/env")
-                 (string-append (assoc-ref %build-inputs "coreutils")
-                                "/bin/env")))
+                (("/usr/bin/env") (which "env")))
               (invoke #$@(if (%current-target-system)
                              #~("./Configure")
                              #~("./config"))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (19 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
                     ` (15 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

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(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index a4e754e27f..af91e42888 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -313,6 +313,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")
@@ -351,25 +376,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 _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 23/37] readline: Make #:configure-flags a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (20 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 24/37] readline: Fix build error when cross-compiling Maxime Devos
                     ` (14 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allos using ungexp and this-package-input later.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Make this a
  G-expression.
---
 gnu/packages/readline.scm | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index b4c91675a4..6cfa24c666 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -29,6 +29,7 @@
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (ice-9 format))
 
 (define (patch-url version seqno)
@@ -76,19 +77,19 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                      (assoc-ref %build-inputs "ncurses")
-                                      "/lib")
+                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
+                                         (assoc-ref %build-inputs "ncurses")
+                                         "/lib")
 
-                       ;; This test does an 'AC_TRY_RUN', which aborts when
-                       ;; cross-compiling, so provide the correct answer.
-                       ,@(if (%current-target-system)
-                             '("bash_cv_wcwidth_broken=no")
-                             '())
-                       ;; MinGW: ncurses provides the termcap api.
-                       ,@(if (target-mingw?)
-                             '("bash_cv_termcap_lib=ncurses")
-                             '()))
+                          ;; This test does an 'AC_TRY_RUN', which aborts when
+                          ;; cross-compiling, so provide the correct answer.
+                          #$@(if (%current-target-system)
+                                 '("bash_cv_wcwidth_broken=no")
+                                 '())
+                          ;; MinGW: ncurses provides the termcap api.
+                          #$@(if (target-mingw?)
+                                 '("bash_cv_termcap_lib=ncurses")
+                                 '()))
 
                  ,@(if (target-mingw?)
                        ;; MinGW: termcap in ncurses
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 24/37] readline: Fix build error when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (21 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
                     ` (13 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling, so
use this-package-input instead.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/readline.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index 6cfa24c666..f9f2797247 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,9 +78,10 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                         (assoc-ref %build-inputs "ncurses")
-                                         "/lib")
+                 ,#~(list (string-append
+                           "LDFLAGS=-Wl,-rpath -Wl,"
+                           #$(this-package-input "ncurses")
+                           "/lib")
 
                           ;; This test does an 'AC_TRY_RUN', which aborts when
                           ;; cross-compiling, so provide the correct answer.
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 25/37] bash: Make #:configure-flags a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (22 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 24/37] readline: Fix build error when cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 26/37] bash: Fix cross-compilation build error Maxime Devos
                     ` (12 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-input later.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Make this a G-expression
  instead of a raw S-expression.
---
 gnu/packages/bash.scm | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 7e98367bbb..b3af873a66 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -109,15 +109,15 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
                                   "-DSSH_SOURCE_BASHRC")
                                 " "))
          (configure-flags
-          ``("--with-installed-readline"
-             ,,(string-append "CPPFLAGS=" cppflags)
-             ,(string-append
-               "LDFLAGS=-Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "readline")
-               "/lib"
-               " -Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "ncurses")
-               "/lib")))
+          #~`("--with-installed-readline"
+              ,#$(string-append "CPPFLAGS=" cppflags)
+              ,(string-append
+                "LDFLAGS=-Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "readline")
+                "/lib"
+                " -Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "ncurses")
+                "/lib")))
          (version "5.1"))
     (package
      (name "bash")
@@ -143,8 +143,8 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
       `(;; When cross-compiling, `configure' incorrectly guesses that job
         ;; control is missing.
         #:configure-flags ,(if (%current-target-system)
-                               `(cons* "bash_cv_job_control_missing=no"
-                                       ,configure-flags)
+                               #~(cons* "bash_cv_job_control_missing=no"
+                                        #$configure-flags)
                                configure-flags)
 
         ;; Bash is reportedly not parallel-safe.  See, for instance,
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 26/37] bash: Fix cross-compilation build error.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (23 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
                     ` (11 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use this-package-input instead.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/bash.scm | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index b3af873a66..d51ab26bc8 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -103,22 +103,25 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
           1))
 
 (define-public bash
-  (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
-                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
-                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
-                                  "-DSSH_SOURCE_BASHRC")
-                                " "))
-         (configure-flags
-          #~`("--with-installed-readline"
-              ,#$(string-append "CPPFLAGS=" cppflags)
-              ,(string-append
-                "LDFLAGS=-Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "readline")
-                "/lib"
-                " -Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "ncurses")
-                "/lib")))
-         (version "5.1"))
+  (let ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
+                                 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
+                                 "-DNON_INTERACTIVE_LOGIN_SHELLS"
+                                 "-DSSH_SOURCE_BASHRC")
+                               " "))
+        (version "5.1"))
+    ;; Delay expansion to inside a lexical environment
+    ;; where this-package is bound.
+    (define-syntax configure-flags
+      (identifier-syntax
+       #~`("--with-installed-readline"
+           ,#$(string-append "CPPFLAGS=" cppflags)
+           ,(string-append
+             "LDFLAGS=-Wl,-rpath -Wl,"
+             ;; %build-inputs does not exist when cross-compiling,
+             ;; so use this-package-input instead.
+             #$(file-append (this-package-input "readline") "/lib")
+             " -Wl,-rpath -Wl,"
+             #$(file-append (this-package-input "ncurses") "/lib")))))
     (package
      (name "bash")
      (source (origin
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 27/37] fontconfig: Make the #:configure-flags argument a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (24 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 26/37] bash: Fix cross-compilation build error Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
                     ` (10 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Make this a
  G-expression instead of a raw S-expression.
  (fontconfig-with-documentation)[arguments]<#:configure-flags>: Likewise.
---
 gnu/packages/fontutils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index dbce5beba8..234f11129a 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -64,6 +64,7 @@
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages tex)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix svn-download)
@@ -347,6 +348,7 @@ Font Format (WOFF).")
         ("python" ,python-minimal)))    ;to avoid a cycle through tk
      (arguments
       `(#:configure-flags
+        ,#~
         (list "--disable-docs"
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
@@ -400,7 +402,7 @@ high quality, anti-aliased and subpixel rendered text on a display.")
     (arguments
      (substitute-keyword-arguments (package-arguments fontconfig)
        ((#:configure-flags configure-flags)
-        `(delete "--disable-docs" ,configure-flags))
+        #~(delete "--disable-docs" #$configure-flags))
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
            (add-after 'install 'move-man-sections
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 28/37] fontconfig: Fix build error when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (25 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 29/37] glib: Use a correct python in scripts " Maxime Devos
                     ` (9 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/fontutils.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 234f11129a..b0d40efeae 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -353,8 +353,8 @@ Font Format (WOFF).")
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
               (string-append "--with-default-fonts="
-                             (assoc-ref %build-inputs "font-dejavu")
-                             "/share/fonts")
+                             #$(file-append (this-package-input "font-dejavu")
+                                            "/share/fonts"))
 
               ;; Register fonts from user and system profiles.
               (string-append "--with-add-fonts="
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 29/37] glib: Use a correct python in scripts when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (26 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
                     ` (8 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

During the build, a native python should be used as these
scripts will be invoked during the build, but when installed,
they should be a python for the system we're compiling for.

* gnu/packages/glib.scm
  (glib)[arguments]<#:phases>{patch-python-references}: Look up
  "python" in 'native-inputs', not 'inputs'.
  (glib)[inputs]{python,python-wrapper,bash-minimal}: New inputs.
---
 gnu/packages/glib.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 94276ae0ef..25c5ae494b 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -222,14 +223,19 @@ shared NFS home directories.")
              #t))
          ;; Python references are not being patched in patch-phase of build,
          ;; despite using python-wrapper as input. So we patch them manually.
+         ;;
+         ;; These python scripts are both used during build and installed,
+         ;; so at first, use a python from 'native-inputs', not 'inputs'. When
+         ;; cross-compiling, the 'patch-shebangs' phase will replace
+         ;; the native python with a python from 'inputs'.
          (add-after 'unpack 'patch-python-references
-           (lambda* (#:key inputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
              (substitute* '("gio/gdbus-2.0/codegen/gdbus-codegen.in"
                             "glib/gtester-report.in"
                             "gobject/glib-genmarshal.in"
                             "gobject/glib-mkenums.in")
                (("@PYTHON@")
-                (string-append (assoc-ref inputs "python")
+                (string-append (assoc-ref (or native-inputs inputs) "python")
                                "/bin/python"
                                ,(version-major+minor
                                  (package-version python)))))
@@ -282,6 +288,13 @@ shared NFS home directories.")
        ("xsltproc" ,libxslt)))
     (inputs
      `(("bash-completion" ,bash-completion)
+       ;; "python", "python-wrapper" and "bash-minimal"
+       ;; are for the 'patch-shebangs' phase, to make
+       ;; sure the installed scripts end up with a correct shebang
+       ;; when cross-compiling.
+       ("python" ,python)
+       ("python-wrapper" ,python-wrapper)
+       ("bash-minimal" ,(canonical-package bash-minimal))
        ("dbus" ,dbus)
        ("libelf" ,libelf)))
     (propagated-inputs
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 30/37] glib: Verify the cross-compiled python is used in installed scripts.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (27 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 29/37] glib: Use a correct python in scripts " Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
                     ` (7 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/glib.scm (glib)[arguments]<#:disallowed-references>:
  Disallow the native python when cross-compiling.
---
 gnu/packages/glib.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 25c5ae494b..244544ea6f 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -77,6 +77,8 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-26)
   #:use-module ((srfi srfi-1) #:hide (zip))
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
@@ -200,7 +202,15 @@ shared NFS home directories.")
     (outputs '("out"   ; everything
                "bin")) ; glib-mkenums, gtester, etc.; depends on Python
     (arguments
-     `(#:disallowed-references (,tzdata-for-tests)
+     `(#:disallowed-references
+       (,tzdata-for-tests
+        ;; Verify glib-mkenums, gtester, ... use the cross-compiled
+        ;; python.
+        ,@(if (%current-target-system)
+              (map (cut gexp-input <> #:native? #t)
+                   `(,(this-package-native-input "python")
+                     ,(this-package-native-input "python-wrapper")))
+              '()))
        #:configure-flags '("-Dman=true"
                            "-Dselinux=disabled")
        #:phases
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (28 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
                     ` (6 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Otherwise, "tzdata" won't be found when cross-compiling
and string-append will complain about types. Alternatively,
"tzdata" could be moved from 'native-inputs' to 'inputs'.

* gnu/packages/glib.scm (glib)[arguments]<#:phases>{pre-check}:
  Look up "tzdata" in 'native-inputs', not 'inputs'.
---
 gnu/packages/glib.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 244544ea6f..57e8282a89 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -251,10 +251,11 @@ shared NFS home directories.")
                                  (package-version python)))))
              #t))
          (add-before 'check 'pre-check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              ;; For tests/gdatetime.c.
              (setenv "TZDIR"
-                     (string-append (assoc-ref inputs "tzdata")
+                     (string-append (assoc-ref (or native-inputs inputs)
+                                               "tzdata")
                                     "/share/zoneinfo"))
              ;; Some tests want write access there.
              (setenv "HOME" (getcwd))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 32/37] tk: Make #:configure-flags a G-expression.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (29 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
                     ` (5 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/tcl.scm (tk)[arguments]<#:configure-flags>: Make
  this a G-expression instead of an S-expression.
---
 gnu/packages/tcl.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index 5fccfa5da9..c87a8187f2 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -230,15 +230,16 @@ X11 GUIs.")
                                           "/lib -lfontconfig")))))))
 
        #:configure-flags
+       ,#~
        (list (string-append "--with-tcl="
                             (assoc-ref %build-inputs "tcl")
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-             ,@(if (%current-target-system)
-                   '("tcl_cv_strtod_buggy=1"
-                     "ac_cv_func_strtod=yes")
-                   '()))
+             #$@(if (%current-target-system)
+                    #~("tcl_cv_strtod_buggy=1"
+                        "ac_cv_func_strtod=yes")
+                    #~()))
 
        ;; The tests require a running X server, so we just skip them.
        #:tests? #f))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 33/37] tk: Do not use %build-inputs when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (30 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 34/37] libelf: Use the cross-compiler " Maxime Devos
                     ` (4 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exists when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/tcl.scm
  (tk)[arguments]<#:configure-flags>: Use 'this-package-input'
  instead of '%build-inputs' when cross-compiling.
---
 gnu/packages/tcl.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index c87a8187f2..91ba8bbb3f 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -29,6 +29,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -232,7 +233,9 @@ X11 GUIs.")
        #:configure-flags
        ,#~
        (list (string-append "--with-tcl="
-                            (assoc-ref %build-inputs "tcl")
+                            #$(if (%current-target-system)
+                                  (this-package-input "tcl")
+                                  #~(assoc-ref %build-inputs "tcl"))
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 34/37] libelf: Use the cross-compiler when cross-compiling.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (31 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
                     ` (3 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script when cross-compiling.
  (libelf)[arguments]<#:phases>{configure}: Do not replace
  when cross-compiling.
  (libelf)[native-inputs]: Add autoconf when cross-compiling.
---
 gnu/packages/elf.scm | 48 +++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..66c2334e5c 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,36 @@ static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ,(if (%current-target-system)
+              ;; This old 'configure' script doesn't
+              ;; support cross-compilation well. E.g., it fails
+              ;; to find the cross-compiler.
+              `(add-before 'bootstrap 'delete-configure
+                 (lambda _
+                   (delete-file "configure")))
+              `(replace 'configure
+                 ;; This old `configure' script doesn't support
+                 ;; variables passed as arguments. TODO: would
+                 ;; simply regenerating 'configure' work
+                 ;; well enough, even if compiling natively
+                 ;; on powerpc or aarch64?
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((out (assoc-ref outputs "out")))
+                     (setenv "CONFIG_SHELL" (which "bash"))
+                     (invoke "./configure"
+                             (string-append "--prefix=" out)
+                             ,@(if (string=? "powerpc64le-linux"
+                                             (%current-system))
+                                   '("--host=powerpc64le-unknown-linux-gnu")
+                                   '())
+                             ,@(if (string=? "aarch64-linux"
+                                             (%current-system))
+                                   '("--host=aarch64-unknown-linux-gnu")
+                                   '())))))))))
+    (native-inputs
+     (if (%current-target-system)
+         `(("autoconf" ,autoconf))
+         '()))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 35/37] opendht: Correct 'nettle' variable name in inputs.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (32 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 34/37] libelf: Use the cross-compiler " Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
                     ` (2 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Previously, opendht referred to 'nettle-3.7'.
But nettle-3.7 has been renamed to simply 'nettle'.
So, refer to 'nettle' instead of 'nettle-3.7'.

This should fix recent evaluation failures of core-updates
on ci.guix.gnu.org.

* gnu/packages/networking.scm
  (opendht)[inputs]{nettle}: Refer to 'nettle' instead of 'nettle-3.7'.
---
 gnu/packages/networking.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index 62c4d7a392..6b154067b1 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -3478,7 +3478,7 @@ and targeted primarily for asynchronous processing of HTTP-requests.")
     (build-system cmake-build-system)
     (inputs
      `(("argon2" ,argon2)
-       ("nettle" ,nettle-3.7)
+       ("nettle" ,nettle)
        ("readline" ,readline)
        ("jsoncpp" ,jsoncpp)
        ("openssl" ,openssl)             ;required for the DHT proxy
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 36/37] cross-base: Fix cross-compiler for i686-linux-gnu.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (33 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 37/37] meson: Support cross-compilation Maxime Devos
  2021-06-18 16:18   ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

GCC doesn't find libgcc_s.so anymore and looks in the wrong
location.  Fix this (well, more a work-around really).

* gnu/packages/cross-base.scm
  (cross-gcc-arguments)<#:configure-flags>:
  Add --with-toolexecdir, such that libstdc++ ends up in the right
  place. Add --with-slibdir such that libgcc_s.so end up in the right place.
  (cross-gcc-arguments)<#:phases>{move-shared-libraries}:
  New phase, moving libraries in the correct place.
  Delete .la files, libasan.so and libusan.so to prevent circular
  references. Likewise, fix a reference in libstdc++.so.VERSION-gdb.py.
---
 gnu/packages/cross-base.scm | 63 +++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 9487ac9238..995b4ae065 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1)
@@ -169,9 +171,26 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                                 ))
 
                        ;; Install cross-built libraries such as libgcc_s.so in
-                       ;; the "lib" output.
+                       ;; the "lib" output. At least for version 8.4.0, GCC
+                       ;; will put libstdc++ in ${toolexecdir}/lib instead.
+                       ;; (A bug?) So set --with-toolexecdir as well.
+
                        ,@(if libc
-                             `((string-append "--with-toolexeclibdir="
+                             `((string-append "--with-toolexecdir="
+                                              (assoc-ref %outputs "lib"))
+                               (string-append "--with-toolexeclibdir="
+                                              (assoc-ref %outputs "lib")
+                                              "/" ,target "/lib"))
+                             '())
+                       ;; At least for GCC 8.0, libgcc_s.so and libstdc++.so
+                       ;; are not installed in the location specified in
+                       ;; --with-toolexeclibdir so GCC will not find it
+                       ;; when cross-compiling, say, GNU Hello.
+                       ;;
+                       ;; Work-around by specifying slibdir. This is not
+                       ;; sufficient, see move-shared-libraries below.
+                       ,@(if (and libc (version>=? (package-version xgcc) "8.0"))
+                             `((string-append "--with-slibdir="
                                               (assoc-ref %outputs "lib")
                                               "/" ,target "/lib"))
                              '())
@@ -193,7 +212,45 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                      ,flags))
             flags))
        ((#:phases phases)
-        `(cross-gcc-build-phases ,target ,phases))))))
+        (if (and libc (version>=? (package-version xgcc) "8.0"))
+            #~(modify-phases (cross-gcc-build-phases #$target #$phases)
+                (add-after 'install 'move-shared-libraries
+                  (lambda _
+                    (let* ((slib (format #f "~a/~a/lib/" #$output:lib #$target))
+                           (badlib (format #f "~a/~a/lib/" #$output #$target))
+                           (libs (map basename (find-files badlib #:fail-on-error? #t))))
+                      (for-each
+                       (lambda (lib)
+                         (let ((from (string-append badlib lib))
+                               (to   (string-append slib lib)))
+                           (when (file-exists? to)
+                             (error "~a was found twice, refusing to overwrite!"
+                                    lib))
+                           ;; The debugging script libstdc++.so.VERSION-gdb.py has
+                           ;; reference to #$output. Correct it.
+                           (when (string-suffix? "-gdb.py" lib)
+                             (substitute* from
+                               (("libdir = '(.*)'")
+                                (string-append "libdir = '" slib "'")))
+                             (system* "cat" from))
+                           ;; The .la files have references to BADLIB,
+                           ;; leading to cyclic references between
+                           ;; the outputs of the package. Remove them
+                           ;; and hope noone notices.
+                           ;;
+                           ;; Likewise, libasan.so.* and libubsan.so.*
+                           ;; have references to #$output.
+                           (if (or (string-suffix? ".la" lib)
+                                   (string-prefix? "libasan.so" lib)
+                                   (string-prefix? "libubsan.so" lib))
+                               (delete-file from)
+                               (rename-file from to))))
+                       libs)
+                      ;; If you have "cyclic references" problems,
+                      ;; uncomment this and use --keep-failed to figure
+                      ;; things out.
+                      (copy-recursively #$output:lib "out-test")))))
+            #~(cross-gcc-build-phases #$target #$phases)))))))
 
 (define (cross-gcc-patches xgcc target)
   "Return GCC patches needed for XGCC and TARGET."
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 37/37] meson: Support cross-compilation.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (34 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
@ 2021-06-18 16:09   ` Maxime Devos
  2021-06-18 16:18   ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:09 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

For cross-compilation, meson needs to be passed a
‘cross file’ with information on the architecture,
CPU type, endianness and operating system, and the
name of the cross-compiler binaries.

The new module (guix build meson-configuration) has
some utilities for writing these cross files, used
by 'make-cross-file' in a G-exp.  The values for
the cross file are generated by 'make-machine-alist'
and 'make-binaries-alist'.

'make-machine-alist' and 'make-binaries-alist' live
on the host side, such that new architectures and operating
systems can be added without causing rebuilds for old
architectures.

Currently, only GNU/Hurd, GNU/Linux, MinGW, x86-32 and
x86-64 are supported by 'make-machine-alist'. For other
architectures, someone needs to figure out what to
use as ‘CPU type’ first.  Only i686-linux-gnu has been
tested.

This has been tested with:

$ ./pre-inst-env guix build glib --target=i686-linux-gnu

on a x86_64-linux system.  ‘If it compiles, it should work.’

* guix/build/meson-configuration.scm
  (configuration-port): New parameter.
  (write-section-header): New procedure.
  (write-assignment): New procedure.
  (write-assignments): New procedure.
* guix/build-system/meson.scm
  (target-hurd?): New predicate.
  (make-machine-alist): New procedure.
  (make-binaries-alist): New procedure.
  (make-cross-file): New procedure.
  (meson-cross-build): New procedure.
  (lower)[build-inputs]: Add standard cross packages when cross-compiling.
  Do not include regular 'inputs' when cross-compiling.
  (lower)[host-inputs]: Include 'inputs' when cross-compiling.
  (lower)[target-inputs]: Add cross packages when cross-compiling.
  (lower)[build]: Call 'meson-cross-build' instead of 'cross-build'
  when cross-compiling.
  (lower)[target]: Set it.
  (lower)[private-keywords]: Do not remove #:target when cross-compiling.
---
 Makefile.am                        |   1 +
 guix/build-system/meson.scm        | 197 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 +++++++++++
 3 files changed, 250 insertions(+), 19 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

diff --git a/Makefile.am b/Makefile.am
index a10e06e5a7..d4bf626fd5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -234,6 +234,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/java-utils.scm			\
   guix/build/lisp-utils.scm			\
+  guix/build/meson-configuration.scm		\
   guix/build/maven/java.scm			\
   guix/build/maven/plugin.scm			\
   guix/build/maven/pom.scm			\
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 5adc0f92c8..1f763af2aa 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (guix packages)
   #:use-module (ice-9 match)
   #:export (%meson-build-system-modules
-            meson-build-system))
+            meson-build-system
+            make-cross-file))
 
 ;; Commentary:
 ;;
@@ -40,6 +42,62 @@
 ;;
 ;; Code:
 
+(define (target-hurd? triplet)
+  (and (string-suffix? "-gnu" triplet)
+       (not (string-contains triplet "linux"))))
+
+(define (make-machine-alist triplet)
+  "Make an association list describing what should go into
+the ‘host_machine’ section of the cross file when cross-compiling
+for TRIPLET."
+  `((system . ,(cond ((target-hurd? triplet) "gnu")
+                     ((target-linux? triplet) "linux")
+                     ((target-mingw? triplet) "windows")
+                     (#t (error "meson: unknown operating system"))))
+    (cpu_family . ,(cond ((target-x86-32? triplet) "x86")
+                         ((target-x86-64? triplet) "x86_64")
+                         ((target-arm32? triplet) "arm")
+                         ((target-aarch64? triplet) "aarch64")
+                         ((target-powerpc? triplet)
+                          (if (target-64bit? triplet)
+                              "ppc64"
+                              "ppc"))
+                         (#t (error "meson: unknown architecture"))))
+    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
+                   (substring triplet 0 4))
+                  ((target-x86-64? triplet) "x86_64")
+                  (#t (error "meson: unknown CPU"))))
+    (endian . ,(cond ((string-prefix? "powerpc64le-" triplet) "little")
+                     ((string-prefix? "mips64el-" triplet) "little")
+                     ((target-x86-32? triplet) "little")
+                     ((target-x86-64? triplet) "little")
+                     (#t (error "meson: unknown architecture"))))))
+
+(define (make-binaries-alist triplet)
+  "Make an associatoin list describing what should go into
+the ‘binaries’ section of the cross file when cross-compiling for
+TRIPLET."
+  `((c . ,(cc-for-target triplet))
+    (cpp . ,(cxx-for-target triplet))
+    (pkgconfig . ,(pkg-config-for-target triplet))
+    (objcopy . ,(string-append triplet "-objcopy"))
+    (ar . ,(string-append triplet "-ar"))
+    (ld . ,(string-append triplet "-ld"))
+    (strip . ,(string-append triplet "-strip"))))
+
+(define (make-cross-file triplet)
+  (computed-file "cross-file"
+    (with-imported-modules '((guix build meson-configuration))
+      #~(begin
+          (use-modules (guix build meson-configuration))
+          (call-with-output-file #$output
+            (lambda (f)
+              (parameterize ((configuration-port f))
+                (write-section-header "host_machine")
+                (write-assignments '#$(make-machine-alist triplet))
+                (write-section-header "binaries")
+                (write-assignments '#$(make-binaries-alist triplet)))))))))
+
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
@@ -68,24 +126,34 @@
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    `(#:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
-
-  (and (not target) ;; TODO: add support for cross-compilation.
-       (bag
-         (name name)
-         (system system)
-         (build-inputs `(("meson" ,meson)
-                         ("ninja" ,ninja)
-                         ,@native-inputs
-                         ,@inputs
-                         ;; Keep the standard inputs of 'gnu-build-system'.
-                         ,@(standard-packages)))
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (outputs outputs)
-         (build meson-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:meson #:ninja #:inputs #:native-inputs #:outputs
+      ,@(if target
+            '()
+            '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (build-inputs `(("meson" ,meson)
+                    ("ninja" ,ninja)
+                    ,@native-inputs
+                    ,@(if target '() inputs)
+                    ;; Keep the standard inputs of 'gnu-build-system'.
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages)))
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target inputs '())))
+    ;; Keep the standard inputs of 'gnu-buid-system'.
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target meson-cross-build meson-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (meson-build name inputs
                       #:key
@@ -161,6 +229,97 @@ has a 'meson.build' file."
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (meson-cross-build name
+                            #:key
+                            target
+                            build-inputs host-inputs target-inputs
+                            guile source
+                            (outputs '("out"))
+                            (configure-flags ''())
+                            (search-paths '())
+                            (native-search-paths '())
+
+                            (build-type "debugoptimized")
+                            (tests? #f)
+                            (test-target "test")
+                            (glib-or-gtk? #f)
+                            (parallel-build? #t)
+                            (parallel-tests? #f)
+                            (validate-runpath? #t)
+                            (patch-shebangs? #t)
+                            (strip-binaries? #t)
+                            (strip-flags ''("--strip-debug"))
+                            (strip-directories ''("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                            (elf-directories ''("lib" "lib64" "libexec"
+                                                "bin" "sbin"))
+                            (phases '%standard-phases)
+                            (system (%current-system))
+                            (imported-modules %meson-build-system-modules)
+                            (modules '((guix build meson-build-system)
+                                       (guix build utils)))
+                            allowed-references
+                            disallowed-references)
+  "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that
+SOURCE has a 'meson.build' file."
+  (define cross-file
+    (make-cross-file target))
+  (define inputs
+    (if (null? target-inputs)
+        (input-tuples->gexp host-inputs)
+        #~(append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs))))
+  (define builder
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@(sexp->gexp modules))
+
+          (define build-phases
+            #$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
+                (if glib-or-gtk?
+                    phases
+                    #~(modify-phases #$phases
+                        (delete 'glib-or-gtk-compile-schemas)
+                        (delete 'glib-or-gtk-wrap)))))
+
+          ;; Do not use 'with-build-variables', as there should be
+          ;; no reason to use %build-inputs and friends.
+          (meson-build #:source #+source
+                       #:system #$system
+                       #:outputs #$(outputs->gexp outputs)
+                       #:inputs #$inputs
+                       #:native-inputs #+(input-tuples->gexp build-inputs)
+                       #:search-paths '#$(sexp->gexp
+                                          (map search-path-specification->sexp
+                                                     search-paths))
+                       #:native-search-paths '#$(sexp->gexp
+                                                 (map search-path-specification->sexp
+                                                      native-search-paths))
+                       #:phases build-phases
+                       #:configure-flags `("--cross-file" #+cross-file
+                                           ,@#$(sexp->gexp configure-flags))
+                       #:build-type #$build-type
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:parallel-build? #$parallel-build?
+                       #:parallel-tests? #$parallel-tests?
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$(sexp->gexp strip-flags)
+                       #:strip-directories #$(sexp->gexp strip-directories)
+                       #:elf-directories #$(sexp->gexp elf-directories)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define meson-build-system
   (build-system
     (name 'meson)
diff --git a/guix/build/meson-configuration.scm b/guix/build/meson-configuration.scm
new file mode 100644
index 0000000000..81b4eaa7e1
--- /dev/null
+++ b/guix/build/meson-configuration.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-configuration)
+  #:use-module (ice-9 match)
+  #:export (write-section-header write-assignment
+            write-assignments make-machine-alist
+            configuration-port))
+
+;; Commentary:
+;;
+;; Utilities for generating a ‘Cross build definition file’ for
+;; the Meson build system.  Configuration values are currently
+;; never escaped.  In practice this is unlikely to be a problem
+;; in the build environment.
+;;
+;; Code:
+
+(define configuration-port
+  (fluid->parameter (make-unbound-fluid)))
+
+(define (write-section-header section-name)
+  "Write a section header for section named SECTION-NAME
+to the configuration port."
+  (format (configuration-port) "[~a]~%" section-name))
+
+(define (write-assignment key value)
+  "Write an assignment of VALUE to KEY to the configuration
+port.  VALUE must be a string (without any special characters
+such as quotes), a boolean or an integer.  Lists are currently
+not supported"
+  (define port (configuration-port))
+  (match value
+    ((? string?)
+     (format port "~a = '~a'~%" key value))
+    ((? integer?)
+     (format port "~a = ~a~%" key value))
+    (#f
+     (format port "~a = true~%" key))
+    (#t
+     (format port "~a = false~%" key))))
+
+(define* (write-assignments alist)
+  "Write the assignments in ALIST, an association list,
+to the configuration port."
+  (for-each (match-lambda
+              ((key . value)
+               (write-assignment key value)))
+            alist))
+
+(define* (make-machine-alist #:key system cpu-family cpu endian)
+  "Make an association list for the [host_machine] section."
+  `((system . ,system)
+    (cpu-family . ,cpu-family)
+    (cpu . ,cpu)
+    (endian . ,endian)))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate.
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
                     ` (35 preceding siblings ...)
  2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 37/37] meson: Support cross-compilation Maxime Devos
@ 2021-06-18 16:18   ` Maxime Devos
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 16:18 UTC (permalink / raw)
  To: 49025; +Cc: othacehe

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

> [[PATCH v2 core-updates]  01/37] utils: Define target-linux? predicate.

Oops --subject-prefix doesn't work as I thought it does.
I'll send a v3.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 01/37] utils: Define target-linux? predicate.
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
                   ` (2 preceding siblings ...)
  2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
@ 2021-06-18 17:15 ` Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
                     ` (35 more replies)
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                   ` (2 subsequent siblings)
  6 siblings, 36 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:15 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-linux?): New predicate.
* tests/utils.scm
  ("target-linux?"): Test it.
  ("target-mingw?"): Also test ‘target-mingw?’.
---
 guix/utils.scm  |  6 ++++++
 tests/utils.scm | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19990ceb8a..4ff2602e23 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,6 +82,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -543,6 +545,10 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  (string-contains target "linux"))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25552..80a0e669a4 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,22 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map (compose ->bool target-linux?)
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map (compose ->bool target-mingw?)
+       '("i686-linux-gnu" "i686-pc-gnu"
+         "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
@ 2021-06-18 17:15   ` Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
                     ` (34 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:15 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
---
 guix/utils.scm  | 20 ++++++++++++++++++++
 tests/utils.scm | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 4ff2602e23..2256ea2ca6 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -84,6 +84,8 @@
             package-name->name+version
             target-linux?
             target-mingw?
+            target-x86-32?
+            target-x86-64?
             target-arm32?
             target-aarch64?
             target-arm?
@@ -553,6 +555,24 @@ a character other than '@'."
   (and target
        (string-suffix? "-mingw32" target)))
 
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+                                                (%current-system))))
+  "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+  ;; Intel also has a 16-bit architecture in the iN86 series, i286
+  ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+  ;; procedure is not named target-x86?.
+  (or (string-prefix? "i386-" target)
+      (string-prefix? "i486-" target)
+      (string-prefix? "i586-" target)
+      (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+                                                 (%current-system))))
+  "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+  (string-prefix? "x86_64-" target))
+
 (define* (target-arm32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index 80a0e669a4..92439b5587 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
        '("i686-linux-gnu" "i686-pc-gnu"
          "i686-w64-mingw32")))
 
+(test-equal "target-x86-32?"
+  '(#f #f #f #t #t #t #t #f)
+  ;; These are (according to Wikipedia) two RISC architectures
+  ;; by Intel and presumably not compatible with the x86-32 series.
+  (map target-x86-32?
+       '("i860-gnu" "i960-gnu"
+         ;; This is a 16-bit architecture
+         "i286-gnu"
+         ;; These are part of the x86-32 series.
+         "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+         ;; Maybe this one will exist some day, but not yet.
+         "i786-gnu")))
+
+(test-equal "target-x86-64?"
+  '(#t #f #f #f)
+  (map target-x86-64?
+       `("x86_64-linux-gnu" "i386-linux-gnu"
+         ;; Just because it includes "64" doesn't make it 64-bit.
+         "aarch64-linux-gnu"
+         ;; Note that (expt 2 109) in decimal notation starts with 64.
+         ;; However, it isn't 32-bit.
+         ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 03/37] packages: Define this-package-input and this-package-native-input.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
@ 2021-06-18 17:15   ` Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
                     ` (33 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:15 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index a66dbea1b7..80c8bbebf0 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47d10af5bc..91ec38e4cc 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1851,6 +1852,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 04/37] net-base: Make #:builder argument a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-06-18 17:15   ` Maxime Devos
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
                     ` (32 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:15 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp-native and this-package-native-input later.

* gnu/packages/admin.scm (net-base)[arguments]{#:builder}: Make this
  a G-expression.
---
 gnu/packages/admin.scm | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 531686fdbb..5c7e41f51b 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -74,6 +74,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages autogen)
@@ -936,25 +937,25 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
-       #:builder (begin
-                   (use-modules (guix build utils)
-                                (srfi srfi-26))
-
-                   (let* ((source (assoc-ref %build-inputs "source"))
-                          (tar    (assoc-ref %build-inputs "tar"))
-                          (xz     (assoc-ref %build-inputs "xz"))
-                          (output (assoc-ref %outputs "out"))
-                          (etc    (string-append output "/etc")))
-                     (setenv "PATH" (string-append xz "/bin"))
-                     (invoke (string-append tar "/bin/tar") "xvf"
-                             source)
-                     (chdir ,(string-append "netbase-" version))
-                     (mkdir-p etc)
-                     (for-each copy-file
-                               '("etc-services" "etc-protocols" "etc-rpc")
-                               (map (cut string-append etc "/" <>)
-                                    '("services" "protocols" "rpc")))
-                     #t))))
+       #:builder ,#~(begin
+                      (use-modules (guix build utils)
+                                   (srfi srfi-26))
+
+                      (let* ((source (assoc-ref %build-inputs "source"))
+                             (tar    (assoc-ref %build-inputs "tar"))
+                             (xz     (assoc-ref %build-inputs "xz"))
+                             (output (assoc-ref %outputs "out"))
+                             (etc    (string-append output "/etc")))
+                        (setenv "PATH" (string-append xz "/bin"))
+                        (invoke (string-append tar "/bin/tar") "xvf"
+                                source)
+                        (chdir #$(string-append "netbase-" version))
+                        (mkdir-p etc)
+                        (for-each copy-file
+                                  '("etc-services" "etc-protocols" "etc-rpc")
+                                  (map (cut string-append etc "/" <>)
+                                       '("services" "protocols" "rpc")))
+                        #t))))
     (native-inputs `(("tar" ,tar)
                      ("xz" ,xz)))
     (synopsis "IANA protocol, port, and RPC number assignments")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (2 preceding siblings ...)
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
@ 2021-06-18 17:15   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 06/37] net-base: Don't cross-compile Maxime Devos
                     ` (31 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:15 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"source" is not in %build-inputs when cross-compiling, so another
approach for referring to the package source code is needed.

* gnu/packages/admin.scm (net-base)[arguments]<#:builder>: Eliminate
  %build-inputs and %outputs.
---
 gnu/packages/admin.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 5c7e41f51b..f499a1252b 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -941,10 +941,10 @@ to allow automatic login and starting any app.")
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
 
-                      (let* ((source (assoc-ref %build-inputs "source"))
-                             (tar    (assoc-ref %build-inputs "tar"))
-                             (xz     (assoc-ref %build-inputs "xz"))
-                             (output (assoc-ref %outputs "out"))
+                      (let* ((source #+(package-source this-package))
+                             (tar    #+(this-package-native-input "tar"))
+                             (xz     #+(this-package-native-input "xz"))
+                             (output #$output)
                              (etc    (string-append output "/etc")))
                         (setenv "PATH" (string-append xz "/bin"))
                         (invoke (string-append tar "/bin/tar") "xvf"
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 06/37] net-base: Don't cross-compile.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (3 preceding siblings ...)
  2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
                     ` (30 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

net-base is pure data, so cross-compiling is pointless.

* gnu/packages/admin.scm
  (net-base)[arguments]<#:target>: Set to #f.
  (net-base)[arguments]<#:allowed-references>: Disallow all
  references.
---
 gnu/packages/admin.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index f499a1252b..5e41ba9967 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -937,6 +937,11 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
+       ;; This package consists solely of architecture-independent
+       ;; tables. Cross-compilation is pointless! Make sure we'll
+       ;; always get the same derivation.
+       #:target #f
+       #:allowed-references ()
        #:builder ,#~(begin
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 07/37] tzdata: Don't bother with cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (4 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 06/37] net-base: Don't cross-compile Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
                     ` (29 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

The time zone database is architecture-independent,
so trying to cross-compile it is pointless!

* gnu/packages/base.scm
  (tzdata)[arguments]<#:target>: Set to #f.
  (tzdata)[allowed-references]: Only include the "out" output itself,
  to make sure no (architecture-dependent) binaries are installed.
---
 gnu/packages/base.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index d30299a7b6..2674be8048 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1251,6 +1252,14 @@ command.")
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f
+       ;; This consists purely of (architecture-independent) data,
+       ;; so ‘cross-compilation’ is pointless here!
+       ;; (The binaries zic, dump, and tzselect are deleted in the post-install
+       ;; phase.)
+       #:target #f
+       ;; share/zoneinfo/posix is a symlink to share/zoneinfo,
+       ;; so include the package itself in #:allowed-references.
+       #:allowed-references ("out")
        #:make-flags (let ((out (assoc-ref %outputs "out"))
                           (tmp (getenv "TMPDIR")))
                       (list (string-append "TOPDIR=" out)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 08/37] libgpg-error: Remove trailing #f from phases.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (5 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
                     ` (28 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These aren't required anymore.

* gnu/packages/gnupg.scm (libgpgerror)[arguments]{cross-symlinks}:
  Remove trailing #f.
---
 gnu/packages/gnupg.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index cb481b38e1..2f44e6ec6a 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -114,8 +114,7 @@
                            (string-append x "-unknown-linux-gnu")))))
                    (symlink
                     (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))
-                 #t))))
+                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 09/37] libgpg-error: Prevent silent miscompilation some systems.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (6 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
                     ` (27 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/gpg.scm
  (libgpgerror)[arguments]<#:phases>{cross-symlinks}: Only
  link to src/syscfg/lock-obj-pub.linux-gnu.h if the package
  is being compiled for a Linux target. Do not link either
  if the architecture is unknown, as the headers vary with
  the architecture.
---
 gnu/packages/gnupg.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 2f44e6ec6a..de213d381f 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
 (define-public libgpg-error
@@ -94,27 +96,37 @@
     (build-system gnu-build-system)
     (arguments
      (if (%current-target-system)
-         `(#:modules ((ice-9 match)
-                      (guix build gnu-build-system)
+         `(#:modules ((guix build gnu-build-system)
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
-             ;; file. See Cross-Compiling section at:
+             ;; file if required. Note that these platform files depend on
+             ;; both the operating system and architecture!
+             ;;
+             ;; See Cross-Compiling section at:
              ;; https://github.com/gpg/libgpg-error/blob/master/README
              (add-after 'unpack 'cross-symlinks
-               (lambda* (#:key target inputs #:allow-other-keys)
-                 (let ((triplet
-                        (match (string-take target
-                                            (string-index target #\-))
-                          ("armhf" "arm-unknown-linux-gnueabi")
-                          ("mips64el" "mips-unknown-linux-gnu")
-                          (x
-                           (string-append x "-unknown-linux-gnu")))))
-                   (symlink
-                    (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
+               (lambda _
+                 (define (link triplet source)
+                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                            (string-append "src/syscfg/lock-obj-pub."
+                                           source ".h")))
+                 ,(let* ((target (%current-target-system))
+                         (architecture
+                          (string-take target (string-index target #\-))))
+                    (cond ((target-linux? target)
+                           (match architecture
+                             ("armhf"
+                              `(link "arm-unknown-linux-gnueabi" "linux-gnu"))
+                             ("mips64el"
+                              `(link "mips-unknown-linux-gnu" "linux-gnu"))
+                             ;; Don't always link to the "linux-gnu"
+                             ;; configuration, as this is not correct for
+                             ;; all architectures.
+                             (_ #t)))
+                          (#t #t)))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 10/37] libgpgerror: Maybe fix a cross-compilation bug.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (7 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
                     ` (26 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Previously, a symlink was created at
src/syscfg/lock-obj-pub.linux-gnu.h pointing at
lock-obj-pub.MANGLED-TARGET.h. I would think this has
to be the other way around, but I am not really sure.

* gnu/packages/gnupg.scm
  (gnupg)[arguments]<#:phases>{cross-symlinks}(link): Switch
  'triplet' and 'source'.
---
 gnu/packages/gnupg.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index de213d381f..f5d4118af9 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -110,9 +110,9 @@
              (add-after 'unpack 'cross-symlinks
                (lambda _
                  (define (link triplet source)
-                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                   (symlink (string-append "lock-obj-pub." source ".h")
                             (string-append "src/syscfg/lock-obj-pub."
-                                           source ".h")))
+                                           triplet ".h")))
                  ,(let* ((target (%current-target-system))
                          (architecture
                           (string-take target (string-index target #\-))))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 11/37] libgpg-error: Fix cross-compilation error.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (8 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
                     ` (25 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

TODO: inform upstream about the cross-compilation error.

* gnu/packages/gnupg.scm
  (libgpg-error)[arguments]{fix-gen-lock-obj.sh}: Prevent generated
  header files from being sprinkled with ‘\c’.
---
 gnu/packages/gnupg.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index f5d4118af9..1fee30584c 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -100,6 +100,13 @@
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
+             ;; If this is left out, some generated header
+             ;; files will be sprinkled with ‘\c’, which
+             ;; the compiler won't like.
+             (add-after 'unpack 'fix-gen-lock-obj.sh
+               (lambda _
+                 (substitute* "src/gen-lock-obj.sh"
+                   (("if test -n `echo -n`") "if ! test -n `echo -n`"))))
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
              ;; file if required. Note that these platform files depend on
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 12/37] libgcrypt: Fix cross-compilation build error.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (9 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
                     ` (24 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling a package using gnu-build-system,
%build-inputs does not exist. But libgcrypt uses %build-inputs
anyway. Fix it.

* gnu/packages/gnupg.scm
  (libgcrypt)[arguments]<#:configure-flags>: Make this a G-exp
  instead of a raw S-exp. Eliminate %build-inputs and use
  this-package-input instead.
---
 gnu/packages/gnupg.scm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 1fee30584c..35cfdf6f43 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -74,6 +74,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
@@ -169,11 +170,12 @@ Daemon and possibly more in the future.")
      ;; 'configure' uses 'gpg-error-config' to determine the '-L' flag, and
      ;; the 'gpg-error-config' it runs is the native one---i.e., the wrong one.
      `(#:configure-flags
-       (list (string-append "--with-gpg-error-prefix="
-                            (assoc-ref %build-inputs "libgpg-error-host"))
-             ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
-             ,@(if (%current-target-system) '("--disable-asm")
-                   '()))))
+       ,#~(list (string-append "--with-gpg-error-prefix="
+                               #$(this-package-input "libgpg-error-host"))
+                ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
+                #$@(if (%current-target-system)
+                       #~("--disable-asm")
+                       #~()))))
     (outputs '("out" "debug"))
     (home-page "https://gnupg.org/")
     (synopsis "Cryptographic function library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (10 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 14/37] wrap-python3: Fix cross-compilation Maxime Devos
                     ` (23 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp later.

* gnu/packages/python.scm (wrap-python3)<#:builder>: Make this
  a G-expression.
---
 gnu/packages/python.scm | 46 ++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index b2ec486d7a..9628836567 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -573,29 +573,29 @@ for more information.")))
     (arguments
      `(#:modules ((guix build utils))
        #:builder
-         (begin
-           (use-modules (guix build utils))
-           (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                 (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
-                (mkdir-p bin)
-                (for-each
-                  (lambda (old new)
-                    (symlink (string-append python old)
-                             (string-append bin "/" new)))
-                  `("python3" ,"pydoc3" ,"idle3" ,"pip3")
-                  `("python"  ,"pydoc"  ,"idle"  ,"pip"))
-                ;; python-config outputs search paths based upon its location,
-                ;; use a bash wrapper to avoid changing its outputs.
-                (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                           "/bin/bash"))
-                      (old  (string-append python "python3-config"))
-                      (new  (string-append bin "/python-config")))
-                  (with-output-to-file new
-                    (lambda ()
-                      (format #t "#!~a~%" bash)
-                      (format #t "exec \"~a\" \"$@\"~%" old)
-                      (chmod new #o755)
-                      #t)))))))
+       ,#~(begin
+            (use-modules (guix build utils))
+            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
+                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
+              (mkdir-p bin)
+              (for-each
+               (lambda (old new)
+                 (symlink (string-append python old)
+                          (string-append bin "/" new)))
+               `("python3" ,"pydoc3" ,"idle3" ,"pip3")
+               `("python"  ,"pydoc"  ,"idle"  ,"pip"))
+              ;; python-config outputs search paths based upon its location,
+              ;; use a bash wrapper to avoid changing its outputs.
+              (let ((bash (string-append (assoc-ref %build-inputs "bash")
+                                         "/bin/bash"))
+                    (old  (string-append python "python3-config"))
+                    (new  (string-append bin "/python-config")))
+                (with-output-to-file new
+                  (lambda ()
+                    (format #t "#!~a~%" bash)
+                    (format #t "exec \"~a\" \"$@\"~%" old)
+                    (chmod new #o755)
+                    #t)))))))
     (synopsis "Wrapper for the Python 3 commands")
     (description
      "This package provides wrappers for the commands of Python@tie{}3.x such
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 14/37] wrap-python3: Fix cross-compilation.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (11 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 15/37] python: Fix reference to input when cross-compiling Maxime Devos
                     ` (22 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling, "bash" is missing from %build-inputs,
leading to a build error. Use this-package-input instead of
%build-inputs to resolve this. While we're at it, eliminate
all uses of %outputs and %build-inputs.

* gnu/packages/python.scm
  (wrap-python3)[arguments]<#:builder>: Eliminte %outputs
  and %build-inputs.
---
 gnu/packages/python.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 9628836567..fbad0b65b8 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -60,6 +60,7 @@
 ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -575,8 +576,8 @@ for more information.")))
        #:builder
        ,#~(begin
             (use-modules (guix build utils))
-            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
+            (let ((bin (string-append #$output "/bin"))
+                  (python #$(file-append (this-package-input "python") "/bin/")))
               (mkdir-p bin)
               (for-each
                (lambda (old new)
@@ -586,8 +587,7 @@ for more information.")))
                `("python"  ,"pydoc"  ,"idle"  ,"pip"))
               ;; python-config outputs search paths based upon its location,
               ;; use a bash wrapper to avoid changing its outputs.
-              (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                         "/bin/bash"))
+              (let ((bash #$(file-append (this-package-input "bash") "/bin/bash"))
                     (old  (string-append python "python3-config"))
                     (new  (string-append bin "/python-config")))
                 (with-output-to-file new
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 15/37] python: Fix reference to input when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (12 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 14/37] wrap-python3: Fix cross-compilation Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 16/37] openssl: Remove trailing #t from phases Maxime Devos
                     ` (21 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"sitecustomize.py" is a native input, so look it up
in 'native-inputs', not 'inputs'.

* gnu/packages/python.scm (customize-site): Look up "sizecustomize.py"
  in 'native-inputs', not 'inputs'.
---
 gnu/packages/python.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index fbad0b65b8..f004b8e739 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -111,13 +111,14 @@
 
 (define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
-  `(lambda* (#:key inputs outputs #:allow-other-keys)
+  `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
-            (sitecustomize.py (assoc-ref inputs "sitecustomize.py"))
+            (sitecustomize.py (assoc-ref (or native-inputs inputs)
+                                         "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 16/37] openssl: Remove trailing #t from phases.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (13 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 15/37] python: Fix reference to input when cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
                     ` (20 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Delete trailing #t.
---
 gnu/packages/tls.scm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 608a7d05b8..5bfc5545db 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -366,8 +366,7 @@ required structures.")
                            ((string-prefix? "powerpc64" target)
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
-                            "linux-ppc")))
-                 #t)))
+                            "linux-ppc"))))))
            '())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
@@ -406,8 +405,7 @@ required structures.")
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
-                        (find-files lib "\\.a$"))
-              #t)))
+                        (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda* (#:key outputs #:allow-other-keys)
                ;; Move man3 pages and full HTML documentation to "doc".
@@ -420,8 +418,7 @@ required structures.")
                  (copy-recursively man3 man-target)
                  (delete-file-recursively man3)
                  (copy-recursively html html-target)
-                 (delete-file-recursively html)
-                 #t)))
+                 (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
          (lambda* (#:key outputs #:allow-other-keys)
@@ -430,8 +427,7 @@ required structures.")
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
                                                      ,(package-version this-package)
-                                                     "/misc"))
-             #t))))))
+                                                     "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 17/37] openssl: Make the #:phases argument a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (14 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 16/37] openssl: Remove trailing #t from phases Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
                     ` (19 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-native-input later.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Make this a G-expression.
  (openssl-1.0)[arguments]<#:phases>: Likewise.
---
 gnu/packages/tls.scm | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 5bfc5545db..9de9a78e84 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -38,6 +38,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -341,9 +342,10 @@ required structures.")
       ;; so we explicitly disallow it here.
       #:disallowed-references ,(list (canonical-package perl))
       #:phases
+      ,#~
       (modify-phases %standard-phases
-       ,@(if (%current-target-system)
-           '((add-before
+       #$@(if (%current-target-system)
+          #~((add-before
                'configure 'set-cross-compile
                (lambda* (#:key target outputs #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
@@ -367,7 +369,7 @@ required structures.")
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
                             "linux-ppc"))))))
-           '())
+             #~())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
@@ -377,9 +379,9 @@ required structures.")
                 (("/usr/bin/env")
                  (string-append (assoc-ref %build-inputs "coreutils")
                                 "/bin/env")))
-              (invoke ,@(if (%current-target-system)
-                          '("./Configure")
-                          '("./config"))
+              (invoke #$@(if (%current-target-system)
+                             #~("./Configure")
+                             #~("./config"))
                       "shared"       ;build shared libraries
                       "--libdir=lib"
 
@@ -388,13 +390,13 @@ required structures.")
                       ;; conventional.
                       (string-append "--openssldir=" out
                                      "/share/openssl-"
-                                     ,(package-version this-package))
+                                     #$(package-version this-package))
 
                       (string-append "--prefix=" out)
                       (string-append "-Wl,-rpath," lib)
-                      ,@(if (%current-target-system)
-                          '((getenv "CONFIGURE_TARGET_ARCH"))
-                          '())))))
+                      #$@(if (%current-target-system)
+                             #~((getenv "CONFIGURE_TARGET_ARCH"))
+                             #~())))))
         (add-after 'install 'move-static-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Move static libraries to the "static" output.
@@ -426,7 +428,7 @@ required structures.")
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
-                                                     ,(package-version this-package)
+                                                     #$(package-version this-package)
                                                      "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
@@ -471,7 +473,7 @@ required structures.")
        ;; Parallel build is not supported in 1.0.x.
        ((#:parallel-build? _ #f) #f)
        ((#:phases phases)
-        `(modify-phases ,phases
+       #~(modify-phases #$phases
            (add-before 'patch-source-shebangs 'patch-tests
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
@@ -494,9 +496,9 @@ required structures.")
 	     ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
 	     (lambda* (#:key outputs #:allow-other-keys)
 	       (let ((out (assoc-ref outputs "out")))
-		 (invoke ,@(if (%current-target-system)
-			       '("./Configure")
-			       '("./config"))
+		 (invoke #$@(if (%current-target-system)
+			        #~("./Configure")
+			        #~("./config"))
 			 "shared"                 ;build shared libraries
 			 "--libdir=lib"
 
@@ -504,12 +506,12 @@ required structures.")
 			 ;; PREFIX/ssl.  Change that to something more
 			 ;; conventional.
 			 (string-append "--openssldir=" out
-					"/share/openssl-" ,version)
+					"/share/openssl-" #$version)
 
 			 (string-append "--prefix=" out)
-			 ,@(if (%current-target-system)
-			       '((getenv "CONFIGURE_TARGET_ARCH"))
-			       '())))))
+			 #$@(if (%current-target-system)
+			        '((getenv "CONFIGURE_TARGET_ARCH"))
+			        '())))))
         (delete 'move-extra-documentation)
         (add-after 'install 'move-man3-pages
           (lambda* (#:key outputs #:allow-other-keys)
@@ -534,7 +536,7 @@ required structures.")
                ;; scripts.  Remove them to avoid retaining a reference on Perl.
                (let ((out (assoc-ref outputs "out")))
                  (delete-file-recursively (string-append out "/share/openssl-"
-                                                         ,version "/misc"))
+                                                         #$version "/misc"))
                  #t)))))))))
 
 (define-public libressl
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 18/37] openssl: Use G-exp machinery for referring to outputs.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (15 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
                     ` (18 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This doesn't fix anything broken, just for simplifying
the code a little while we're rebuilding the world anyway.
IMHO this makes the code a little more readable.

* gnu/packages/tls.scm (openssl)[arguments]<#:phases>: Don't refer
  to the association list 'outputs', use #$output, #$output:doc
  and #$output:static instead.
---
 gnu/packages/tls.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 9de9a78e84..90211c733d 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -347,7 +348,7 @@ required structures.")
        #$@(if (%current-target-system)
           #~((add-before
                'configure 'set-cross-compile
-               (lambda* (#:key target outputs #:allow-other-keys)
+               (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
                          (cond
@@ -371,8 +372,8 @@ required structures.")
                             "linux-ppc"))))))
              #~())
         (replace 'configure
-          (lambda* (#:key outputs #:allow-other-keys)
-            (let* ((out (assoc-ref outputs "out"))
+          (lambda _
+            (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
               (substitute* "config"
@@ -398,23 +399,23 @@ required structures.")
                              #~((getenv "CONFIGURE_TARGET_ARCH"))
                              #~())))))
         (add-after 'install 'move-static-libraries
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
             ;; Move static libraries to the "static" output.
-            (let* ((out    (assoc-ref outputs "out"))
+            (let* ((out    #$output)
                    (lib    (string-append out "/lib"))
-                   (static (assoc-ref outputs "static"))
+                   (static #$output:static)
                    (slib   (string-append static "/lib")))
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
                ;; Move man3 pages and full HTML documentation to "doc".
-               (let* ((out    (assoc-ref outputs "out"))
+               (let* ((out    #$output)
                       (man3   (string-append out "/share/man/man3"))
                       (html (string-append out "/share/doc/openssl"))
-                      (doc    (assoc-ref outputs "doc"))
+                      (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
                  (copy-recursively man3 man-target)
@@ -423,13 +424,12 @@ required structures.")
                  (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
-         (lambda* (#:key outputs #:allow-other-keys)
+         (lambda _
            ;; The 'misc' directory contains random undocumented shell and Perl
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
-           (let ((out (assoc-ref outputs "out")))
-             (delete-file-recursively (string-append out "/share/openssl-"
-                                                     #$(package-version this-package)
-                                                     "/misc"))))))))
+           (delete-file-recursively (string-append #$output "/share/openssl-"
+                                                   #$(package-version this-package)
+                                                   "/misc")))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 19/37] openssl: Move documentation instead of copying and deleting it.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (16 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
                     ` (17 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Use
  'rename-file' instead of 'copy-recursively' and
  'delete-file-recursively'.
---
 gnu/packages/tls.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 90211c733d..9aa0b5a212 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -418,10 +418,10 @@ required structures.")
                       (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (copy-recursively man3 man-target)
-                 (delete-file-recursively man3)
-                 (copy-recursively html html-target)
-                 (delete-file-recursively html))))
+                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname html-target))
+                 (rename-file man3 man-target)
+                 (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
          (lambda _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 20/37] openssl: Move all man pages to separate output, not only man3.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (17 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
                     ` (16 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

There does not seem to be any reason to only move man3 pages.
So, move all man pages to a separate output for documentation.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Move
  all man pages, not only man3.
---
 gnu/packages/tls.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 9aa0b5a212..c178806805 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -411,16 +411,16 @@ required structures.")
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda _
-               ;; Move man3 pages and full HTML documentation to "doc".
+               ;; Move man pages and full HTML documentation to "doc".
                (let* ((out    #$output)
-                      (man3   (string-append out "/share/man/man3"))
-                      (html (string-append out "/share/doc/openssl"))
+                      (man    (string-append out "/share/man"))
+                      (html   (string-append out "/share/doc/openssl"))
                       (doc    #$output:doc)
-                      (man-target (string-append doc "/share/man/man3"))
+                      (man-target (string-append doc "/share/man"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname man-target))
                  (mkdir-p (dirname html-target))
-                 (rename-file man3 man-target)
+                 (rename-file man man-target)
                  (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 21/37] openssl: Find bin/env when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (18 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
                     ` (15 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so find bin/env by another way.

* (openssl)[arguments]<#:phases>{configure}: Don't use '%build-inputs',
  use 'which' instead.
---
 gnu/packages/tls.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index c178806805..a4e754e27f 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -376,10 +376,10 @@ required structures.")
             (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
+              ;; Don't use (assoc-ref %build-inputs "coreutils"), as
+              ;; %build-inputs is not defined when cross-compiling.
               (substitute* "config"
-                (("/usr/bin/env")
-                 (string-append (assoc-ref %build-inputs "coreutils")
-                                "/bin/env")))
+                (("/usr/bin/env") (which "env")))
               (invoke #$@(if (%current-target-system)
                              #~("./Configure")
                              #~("./config"))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (19 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
                     ` (14 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

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(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index a4e754e27f..af91e42888 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -313,6 +313,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")
@@ -351,25 +376,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 _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 23/37] readline: Make #:configure-flags a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (20 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 24/37] readline: Fix build error when cross-compiling Maxime Devos
                     ` (13 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allos using ungexp and this-package-input later.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Make this a
  G-expression.
---
 gnu/packages/readline.scm | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index b4c91675a4..6cfa24c666 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -29,6 +29,7 @@
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (ice-9 format))
 
 (define (patch-url version seqno)
@@ -76,19 +77,19 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                      (assoc-ref %build-inputs "ncurses")
-                                      "/lib")
+                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
+                                         (assoc-ref %build-inputs "ncurses")
+                                         "/lib")
 
-                       ;; This test does an 'AC_TRY_RUN', which aborts when
-                       ;; cross-compiling, so provide the correct answer.
-                       ,@(if (%current-target-system)
-                             '("bash_cv_wcwidth_broken=no")
-                             '())
-                       ;; MinGW: ncurses provides the termcap api.
-                       ,@(if (target-mingw?)
-                             '("bash_cv_termcap_lib=ncurses")
-                             '()))
+                          ;; This test does an 'AC_TRY_RUN', which aborts when
+                          ;; cross-compiling, so provide the correct answer.
+                          #$@(if (%current-target-system)
+                                 '("bash_cv_wcwidth_broken=no")
+                                 '())
+                          ;; MinGW: ncurses provides the termcap api.
+                          #$@(if (target-mingw?)
+                                 '("bash_cv_termcap_lib=ncurses")
+                                 '()))
 
                  ,@(if (target-mingw?)
                        ;; MinGW: termcap in ncurses
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 24/37] readline: Fix build error when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (21 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
                     ` (12 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling, so
use this-package-input instead.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/readline.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index 6cfa24c666..f9f2797247 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,9 +78,10 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                         (assoc-ref %build-inputs "ncurses")
-                                         "/lib")
+                 ,#~(list (string-append
+                           "LDFLAGS=-Wl,-rpath -Wl,"
+                           #$(this-package-input "ncurses")
+                           "/lib")
 
                           ;; This test does an 'AC_TRY_RUN', which aborts when
                           ;; cross-compiling, so provide the correct answer.
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 25/37] bash: Make #:configure-flags a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (22 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 24/37] readline: Fix build error when cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 26/37] bash: Fix cross-compilation build error Maxime Devos
                     ` (11 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-input later.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Make this a G-expression
  instead of a raw S-expression.
---
 gnu/packages/bash.scm | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 7e98367bbb..b3af873a66 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -109,15 +109,15 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
                                   "-DSSH_SOURCE_BASHRC")
                                 " "))
          (configure-flags
-          ``("--with-installed-readline"
-             ,,(string-append "CPPFLAGS=" cppflags)
-             ,(string-append
-               "LDFLAGS=-Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "readline")
-               "/lib"
-               " -Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "ncurses")
-               "/lib")))
+          #~`("--with-installed-readline"
+              ,#$(string-append "CPPFLAGS=" cppflags)
+              ,(string-append
+                "LDFLAGS=-Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "readline")
+                "/lib"
+                " -Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "ncurses")
+                "/lib")))
          (version "5.1"))
     (package
      (name "bash")
@@ -143,8 +143,8 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
       `(;; When cross-compiling, `configure' incorrectly guesses that job
         ;; control is missing.
         #:configure-flags ,(if (%current-target-system)
-                               `(cons* "bash_cv_job_control_missing=no"
-                                       ,configure-flags)
+                               #~(cons* "bash_cv_job_control_missing=no"
+                                        #$configure-flags)
                                configure-flags)
 
         ;; Bash is reportedly not parallel-safe.  See, for instance,
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 26/37] bash: Fix cross-compilation build error.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (23 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
                     ` (10 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use this-package-input instead.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/bash.scm | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index b3af873a66..d51ab26bc8 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -103,22 +103,25 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
           1))
 
 (define-public bash
-  (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
-                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
-                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
-                                  "-DSSH_SOURCE_BASHRC")
-                                " "))
-         (configure-flags
-          #~`("--with-installed-readline"
-              ,#$(string-append "CPPFLAGS=" cppflags)
-              ,(string-append
-                "LDFLAGS=-Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "readline")
-                "/lib"
-                " -Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "ncurses")
-                "/lib")))
-         (version "5.1"))
+  (let ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
+                                 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
+                                 "-DNON_INTERACTIVE_LOGIN_SHELLS"
+                                 "-DSSH_SOURCE_BASHRC")
+                               " "))
+        (version "5.1"))
+    ;; Delay expansion to inside a lexical environment
+    ;; where this-package is bound.
+    (define-syntax configure-flags
+      (identifier-syntax
+       #~`("--with-installed-readline"
+           ,#$(string-append "CPPFLAGS=" cppflags)
+           ,(string-append
+             "LDFLAGS=-Wl,-rpath -Wl,"
+             ;; %build-inputs does not exist when cross-compiling,
+             ;; so use this-package-input instead.
+             #$(file-append (this-package-input "readline") "/lib")
+             " -Wl,-rpath -Wl,"
+             #$(file-append (this-package-input "ncurses") "/lib")))))
     (package
      (name "bash")
      (source (origin
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 27/37] fontconfig: Make the #:configure-flags argument a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (24 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 26/37] bash: Fix cross-compilation build error Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
                     ` (9 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Make this a
  G-expression instead of a raw S-expression.
  (fontconfig-with-documentation)[arguments]<#:configure-flags>: Likewise.
---
 gnu/packages/fontutils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index dbce5beba8..234f11129a 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -64,6 +64,7 @@
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages tex)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix svn-download)
@@ -347,6 +348,7 @@ Font Format (WOFF).")
         ("python" ,python-minimal)))    ;to avoid a cycle through tk
      (arguments
       `(#:configure-flags
+        ,#~
         (list "--disable-docs"
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
@@ -400,7 +402,7 @@ high quality, anti-aliased and subpixel rendered text on a display.")
     (arguments
      (substitute-keyword-arguments (package-arguments fontconfig)
        ((#:configure-flags configure-flags)
-        `(delete "--disable-docs" ,configure-flags))
+        #~(delete "--disable-docs" #$configure-flags))
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
            (add-after 'install 'move-man-sections
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 28/37] fontconfig: Fix build error when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (25 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 29/37] glib: Use a correct python in scripts " Maxime Devos
                     ` (8 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/fontutils.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 234f11129a..b0d40efeae 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -353,8 +353,8 @@ Font Format (WOFF).")
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
               (string-append "--with-default-fonts="
-                             (assoc-ref %build-inputs "font-dejavu")
-                             "/share/fonts")
+                             #$(file-append (this-package-input "font-dejavu")
+                                            "/share/fonts"))
 
               ;; Register fonts from user and system profiles.
               (string-append "--with-add-fonts="
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 29/37] glib: Use a correct python in scripts when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (26 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
                     ` (7 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

During the build, a native python should be used as these
scripts will be invoked during the build, but when installed,
they should be a python for the system we're compiling for.

* gnu/packages/glib.scm
  (glib)[arguments]<#:phases>{patch-python-references}: Look up
  "python" in 'native-inputs', not 'inputs'.
  (glib)[inputs]{python,python-wrapper,bash-minimal}: New inputs.
---
 gnu/packages/glib.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 94276ae0ef..25c5ae494b 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -222,14 +223,19 @@ shared NFS home directories.")
              #t))
          ;; Python references are not being patched in patch-phase of build,
          ;; despite using python-wrapper as input. So we patch them manually.
+         ;;
+         ;; These python scripts are both used during build and installed,
+         ;; so at first, use a python from 'native-inputs', not 'inputs'. When
+         ;; cross-compiling, the 'patch-shebangs' phase will replace
+         ;; the native python with a python from 'inputs'.
          (add-after 'unpack 'patch-python-references
-           (lambda* (#:key inputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
              (substitute* '("gio/gdbus-2.0/codegen/gdbus-codegen.in"
                             "glib/gtester-report.in"
                             "gobject/glib-genmarshal.in"
                             "gobject/glib-mkenums.in")
                (("@PYTHON@")
-                (string-append (assoc-ref inputs "python")
+                (string-append (assoc-ref (or native-inputs inputs) "python")
                                "/bin/python"
                                ,(version-major+minor
                                  (package-version python)))))
@@ -282,6 +288,13 @@ shared NFS home directories.")
        ("xsltproc" ,libxslt)))
     (inputs
      `(("bash-completion" ,bash-completion)
+       ;; "python", "python-wrapper" and "bash-minimal"
+       ;; are for the 'patch-shebangs' phase, to make
+       ;; sure the installed scripts end up with a correct shebang
+       ;; when cross-compiling.
+       ("python" ,python)
+       ("python-wrapper" ,python-wrapper)
+       ("bash-minimal" ,(canonical-package bash-minimal))
        ("dbus" ,dbus)
        ("libelf" ,libelf)))
     (propagated-inputs
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 30/37] glib: Verify the cross-compiled python is used in installed scripts.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (27 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 29/37] glib: Use a correct python in scripts " Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
                     ` (6 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/glib.scm (glib)[arguments]<#:disallowed-references>:
  Disallow the native python when cross-compiling.
---
 gnu/packages/glib.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 25c5ae494b..244544ea6f 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -77,6 +77,8 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-26)
   #:use-module ((srfi srfi-1) #:hide (zip))
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
@@ -200,7 +202,15 @@ shared NFS home directories.")
     (outputs '("out"   ; everything
                "bin")) ; glib-mkenums, gtester, etc.; depends on Python
     (arguments
-     `(#:disallowed-references (,tzdata-for-tests)
+     `(#:disallowed-references
+       (,tzdata-for-tests
+        ;; Verify glib-mkenums, gtester, ... use the cross-compiled
+        ;; python.
+        ,@(if (%current-target-system)
+              (map (cut gexp-input <> #:native? #t)
+                   `(,(this-package-native-input "python")
+                     ,(this-package-native-input "python-wrapper")))
+              '()))
        #:configure-flags '("-Dman=true"
                            "-Dselinux=disabled")
        #:phases
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (28 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
                     ` (5 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Otherwise, "tzdata" won't be found when cross-compiling
and string-append will complain about types. Alternatively,
"tzdata" could be moved from 'native-inputs' to 'inputs'.

* gnu/packages/glib.scm (glib)[arguments]<#:phases>{pre-check}:
  Look up "tzdata" in 'native-inputs', not 'inputs'.
---
 gnu/packages/glib.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 244544ea6f..57e8282a89 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -251,10 +251,11 @@ shared NFS home directories.")
                                  (package-version python)))))
              #t))
          (add-before 'check 'pre-check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              ;; For tests/gdatetime.c.
              (setenv "TZDIR"
-                     (string-append (assoc-ref inputs "tzdata")
+                     (string-append (assoc-ref (or native-inputs inputs)
+                                               "tzdata")
                                     "/share/zoneinfo"))
              ;; Some tests want write access there.
              (setenv "HOME" (getcwd))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 32/37] tk: Make #:configure-flags a G-expression.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (29 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
                     ` (4 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/tcl.scm (tk)[arguments]<#:configure-flags>: Make
  this a G-expression instead of an S-expression.
---
 gnu/packages/tcl.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index 5fccfa5da9..c87a8187f2 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -230,15 +230,16 @@ X11 GUIs.")
                                           "/lib -lfontconfig")))))))
 
        #:configure-flags
+       ,#~
        (list (string-append "--with-tcl="
                             (assoc-ref %build-inputs "tcl")
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-             ,@(if (%current-target-system)
-                   '("tcl_cv_strtod_buggy=1"
-                     "ac_cv_func_strtod=yes")
-                   '()))
+             #$@(if (%current-target-system)
+                    #~("tcl_cv_strtod_buggy=1"
+                        "ac_cv_func_strtod=yes")
+                    #~()))
 
        ;; The tests require a running X server, so we just skip them.
        #:tests? #f))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 33/37] tk: Do not use %build-inputs when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (30 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 34/37] libelf: Use the cross-compiler " Maxime Devos
                     ` (3 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exists when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/tcl.scm
  (tk)[arguments]<#:configure-flags>: Use 'this-package-input'
  instead of '%build-inputs' when cross-compiling.
---
 gnu/packages/tcl.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index c87a8187f2..91ba8bbb3f 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -29,6 +29,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -232,7 +233,9 @@ X11 GUIs.")
        #:configure-flags
        ,#~
        (list (string-append "--with-tcl="
-                            (assoc-ref %build-inputs "tcl")
+                            #$(if (%current-target-system)
+                                  (this-package-input "tcl")
+                                  #~(assoc-ref %build-inputs "tcl"))
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 34/37] libelf: Use the cross-compiler when cross-compiling.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (31 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
                     ` (2 subsequent siblings)
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script when cross-compiling.
  (libelf)[arguments]<#:phases>{configure}: Do not replace
  when cross-compiling.
  (libelf)[native-inputs]: Add autoconf when cross-compiling.
---
 gnu/packages/elf.scm | 48 +++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..66c2334e5c 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,36 @@ static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ,(if (%current-target-system)
+              ;; This old 'configure' script doesn't
+              ;; support cross-compilation well. E.g., it fails
+              ;; to find the cross-compiler.
+              `(add-before 'bootstrap 'delete-configure
+                 (lambda _
+                   (delete-file "configure")))
+              `(replace 'configure
+                 ;; This old `configure' script doesn't support
+                 ;; variables passed as arguments. TODO: would
+                 ;; simply regenerating 'configure' work
+                 ;; well enough, even if compiling natively
+                 ;; on powerpc or aarch64?
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((out (assoc-ref outputs "out")))
+                     (setenv "CONFIG_SHELL" (which "bash"))
+                     (invoke "./configure"
+                             (string-append "--prefix=" out)
+                             ,@(if (string=? "powerpc64le-linux"
+                                             (%current-system))
+                                   '("--host=powerpc64le-unknown-linux-gnu")
+                                   '())
+                             ,@(if (string=? "aarch64-linux"
+                                             (%current-system))
+                                   '("--host=aarch64-unknown-linux-gnu")
+                                   '())))))))))
+    (native-inputs
+     (if (%current-target-system)
+         `(("autoconf" ,autoconf))
+         '()))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 35/37] opendht: Correct 'nettle' variable name in inputs.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (32 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 34/37] libelf: Use the cross-compiler " Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 37/37] meson: Support cross-compilation Maxime Devos
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Previously, opendht referred to 'nettle-3.7'.
But nettle-3.7 has been renamed to simply 'nettle'.
So, refer to 'nettle' instead of 'nettle-3.7'.

This should fix recent evaluation failures of core-updates
on ci.guix.gnu.org.

* gnu/packages/networking.scm
  (opendht)[inputs]{nettle}: Refer to 'nettle' instead of 'nettle-3.7'.
---
 gnu/packages/networking.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index 62c4d7a392..6b154067b1 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -3478,7 +3478,7 @@ and targeted primarily for asynchronous processing of HTTP-requests.")
     (build-system cmake-build-system)
     (inputs
      `(("argon2" ,argon2)
-       ("nettle" ,nettle-3.7)
+       ("nettle" ,nettle)
        ("readline" ,readline)
        ("jsoncpp" ,jsoncpp)
        ("openssl" ,openssl)             ;required for the DHT proxy
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (33 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  2021-06-19  7:43     ` Maxime Devos
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 37/37] meson: Support cross-compilation Maxime Devos
  35 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

GCC doesn't find libgcc_s.so anymore and looks in the wrong
location.  Fix this (well, more a work-around really).

* gnu/packages/cross-base.scm
  (cross-gcc-arguments)<#:configure-flags>:
  Add --with-toolexecdir, such that libstdc++ ends up in the right
  place. Add --with-slibdir such that libgcc_s.so end up in the right place.
  (cross-gcc-arguments)<#:phases>{move-shared-libraries}:
  New phase, moving libraries in the correct place.
  Delete .la files, libasan.so and libusan.so to prevent circular
  references. Likewise, fix a reference in libstdc++.so.VERSION-gdb.py.
---
 gnu/packages/cross-base.scm | 63 +++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 9487ac9238..995b4ae065 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1)
@@ -169,9 +171,26 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                                 ))
 
                        ;; Install cross-built libraries such as libgcc_s.so in
-                       ;; the "lib" output.
+                       ;; the "lib" output. At least for version 8.4.0, GCC
+                       ;; will put libstdc++ in ${toolexecdir}/lib instead.
+                       ;; (A bug?) So set --with-toolexecdir as well.
+
                        ,@(if libc
-                             `((string-append "--with-toolexeclibdir="
+                             `((string-append "--with-toolexecdir="
+                                              (assoc-ref %outputs "lib"))
+                               (string-append "--with-toolexeclibdir="
+                                              (assoc-ref %outputs "lib")
+                                              "/" ,target "/lib"))
+                             '())
+                       ;; At least for GCC 8.0, libgcc_s.so and libstdc++.so
+                       ;; are not installed in the location specified in
+                       ;; --with-toolexeclibdir so GCC will not find it
+                       ;; when cross-compiling, say, GNU Hello.
+                       ;;
+                       ;; Work-around by specifying slibdir. This is not
+                       ;; sufficient, see move-shared-libraries below.
+                       ,@(if (and libc (version>=? (package-version xgcc) "8.0"))
+                             `((string-append "--with-slibdir="
                                               (assoc-ref %outputs "lib")
                                               "/" ,target "/lib"))
                              '())
@@ -193,7 +212,45 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                      ,flags))
             flags))
        ((#:phases phases)
-        `(cross-gcc-build-phases ,target ,phases))))))
+        (if (and libc (version>=? (package-version xgcc) "8.0"))
+            #~(modify-phases (cross-gcc-build-phases #$target #$phases)
+                (add-after 'install 'move-shared-libraries
+                  (lambda _
+                    (let* ((slib (format #f "~a/~a/lib/" #$output:lib #$target))
+                           (badlib (format #f "~a/~a/lib/" #$output #$target))
+                           (libs (map basename (find-files badlib #:fail-on-error? #t))))
+                      (for-each
+                       (lambda (lib)
+                         (let ((from (string-append badlib lib))
+                               (to   (string-append slib lib)))
+                           (when (file-exists? to)
+                             (error "~a was found twice, refusing to overwrite!"
+                                    lib))
+                           ;; The debugging script libstdc++.so.VERSION-gdb.py has
+                           ;; reference to #$output. Correct it.
+                           (when (string-suffix? "-gdb.py" lib)
+                             (substitute* from
+                               (("libdir = '(.*)'")
+                                (string-append "libdir = '" slib "'")))
+                             (system* "cat" from))
+                           ;; The .la files have references to BADLIB,
+                           ;; leading to cyclic references between
+                           ;; the outputs of the package. Remove them
+                           ;; and hope noone notices.
+                           ;;
+                           ;; Likewise, libasan.so.* and libubsan.so.*
+                           ;; have references to #$output.
+                           (if (or (string-suffix? ".la" lib)
+                                   (string-prefix? "libasan.so" lib)
+                                   (string-prefix? "libubsan.so" lib))
+                               (delete-file from)
+                               (rename-file from to))))
+                       libs)
+                      ;; If you have "cyclic references" problems,
+                      ;; uncomment this and use --keep-failed to figure
+                      ;; things out.
+                      (copy-recursively #$output:lib "out-test")))))
+            #~(cross-gcc-build-phases #$target #$phases)))))))
 
 (define (cross-gcc-patches xgcc target)
   "Return GCC patches needed for XGCC and TARGET."
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 37/37] meson: Support cross-compilation.
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
                     ` (34 preceding siblings ...)
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
@ 2021-06-18 17:16   ` Maxime Devos
  35 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-18 17:16 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

For cross-compilation, meson needs to be passed a
‘cross file’ with information on the architecture,
CPU type, endianness and operating system, and the
name of the cross-compiler binaries.

The new module (guix build meson-configuration) has
some utilities for writing these cross files, used
by 'make-cross-file' in a G-exp.  The values for
the cross file are generated by 'make-machine-alist'
and 'make-binaries-alist'.

'make-machine-alist' and 'make-binaries-alist' live
on the host side, such that new architectures and operating
systems can be added without causing rebuilds for old
architectures.

Currently, only GNU/Hurd, GNU/Linux, MinGW, x86-32 and
x86-64 are supported by 'make-machine-alist'. For other
architectures, someone needs to figure out what to
use as ‘CPU type’ first.  Only i686-linux-gnu has been
tested.

This has been tested with:

$ ./pre-inst-env guix build glib --target=i686-linux-gnu

on a x86_64-linux system.  ‘If it compiles, it should work.’

* guix/build/meson-configuration.scm
  (configuration-port): New parameter.
  (write-section-header): New procedure.
  (write-assignment): New procedure.
  (write-assignments): New procedure.
* guix/build-system/meson.scm
  (target-hurd?): New predicate.
  (make-machine-alist): New procedure.
  (make-binaries-alist): New procedure.
  (make-cross-file): New procedure.
  (meson-cross-build): New procedure.
  (lower)[build-inputs]: Add standard cross packages when cross-compiling.
  Do not include regular 'inputs' when cross-compiling.
  (lower)[host-inputs]: Include 'inputs' when cross-compiling.
  (lower)[target-inputs]: Add cross packages when cross-compiling.
  (lower)[build]: Call 'meson-cross-build' instead of 'cross-build'
  when cross-compiling.
  (lower)[target]: Set it.
  (lower)[private-keywords]: Do not remove #:target when cross-compiling.
---
 Makefile.am                        |   1 +
 guix/build-system/meson.scm        | 197 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 +++++++++++
 3 files changed, 250 insertions(+), 19 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

diff --git a/Makefile.am b/Makefile.am
index a10e06e5a7..d4bf626fd5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -234,6 +234,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/java-utils.scm			\
   guix/build/lisp-utils.scm			\
+  guix/build/meson-configuration.scm		\
   guix/build/maven/java.scm			\
   guix/build/maven/plugin.scm			\
   guix/build/maven/pom.scm			\
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 5adc0f92c8..1f763af2aa 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (guix packages)
   #:use-module (ice-9 match)
   #:export (%meson-build-system-modules
-            meson-build-system))
+            meson-build-system
+            make-cross-file))
 
 ;; Commentary:
 ;;
@@ -40,6 +42,62 @@
 ;;
 ;; Code:
 
+(define (target-hurd? triplet)
+  (and (string-suffix? "-gnu" triplet)
+       (not (string-contains triplet "linux"))))
+
+(define (make-machine-alist triplet)
+  "Make an association list describing what should go into
+the ‘host_machine’ section of the cross file when cross-compiling
+for TRIPLET."
+  `((system . ,(cond ((target-hurd? triplet) "gnu")
+                     ((target-linux? triplet) "linux")
+                     ((target-mingw? triplet) "windows")
+                     (#t (error "meson: unknown operating system"))))
+    (cpu_family . ,(cond ((target-x86-32? triplet) "x86")
+                         ((target-x86-64? triplet) "x86_64")
+                         ((target-arm32? triplet) "arm")
+                         ((target-aarch64? triplet) "aarch64")
+                         ((target-powerpc? triplet)
+                          (if (target-64bit? triplet)
+                              "ppc64"
+                              "ppc"))
+                         (#t (error "meson: unknown architecture"))))
+    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
+                   (substring triplet 0 4))
+                  ((target-x86-64? triplet) "x86_64")
+                  (#t (error "meson: unknown CPU"))))
+    (endian . ,(cond ((string-prefix? "powerpc64le-" triplet) "little")
+                     ((string-prefix? "mips64el-" triplet) "little")
+                     ((target-x86-32? triplet) "little")
+                     ((target-x86-64? triplet) "little")
+                     (#t (error "meson: unknown architecture"))))))
+
+(define (make-binaries-alist triplet)
+  "Make an associatoin list describing what should go into
+the ‘binaries’ section of the cross file when cross-compiling for
+TRIPLET."
+  `((c . ,(cc-for-target triplet))
+    (cpp . ,(cxx-for-target triplet))
+    (pkgconfig . ,(pkg-config-for-target triplet))
+    (objcopy . ,(string-append triplet "-objcopy"))
+    (ar . ,(string-append triplet "-ar"))
+    (ld . ,(string-append triplet "-ld"))
+    (strip . ,(string-append triplet "-strip"))))
+
+(define (make-cross-file triplet)
+  (computed-file "cross-file"
+    (with-imported-modules '((guix build meson-configuration))
+      #~(begin
+          (use-modules (guix build meson-configuration))
+          (call-with-output-file #$output
+            (lambda (f)
+              (parameterize ((configuration-port f))
+                (write-section-header "host_machine")
+                (write-assignments '#$(make-machine-alist triplet))
+                (write-section-header "binaries")
+                (write-assignments '#$(make-binaries-alist triplet)))))))))
+
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
@@ -68,24 +126,34 @@
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    `(#:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
-
-  (and (not target) ;; TODO: add support for cross-compilation.
-       (bag
-         (name name)
-         (system system)
-         (build-inputs `(("meson" ,meson)
-                         ("ninja" ,ninja)
-                         ,@native-inputs
-                         ,@inputs
-                         ;; Keep the standard inputs of 'gnu-build-system'.
-                         ,@(standard-packages)))
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (outputs outputs)
-         (build meson-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:meson #:ninja #:inputs #:native-inputs #:outputs
+      ,@(if target
+            '()
+            '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (build-inputs `(("meson" ,meson)
+                    ("ninja" ,ninja)
+                    ,@native-inputs
+                    ,@(if target '() inputs)
+                    ;; Keep the standard inputs of 'gnu-build-system'.
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages)))
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target inputs '())))
+    ;; Keep the standard inputs of 'gnu-buid-system'.
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target meson-cross-build meson-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (meson-build name inputs
                       #:key
@@ -161,6 +229,97 @@ has a 'meson.build' file."
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (meson-cross-build name
+                            #:key
+                            target
+                            build-inputs host-inputs target-inputs
+                            guile source
+                            (outputs '("out"))
+                            (configure-flags ''())
+                            (search-paths '())
+                            (native-search-paths '())
+
+                            (build-type "debugoptimized")
+                            (tests? #f)
+                            (test-target "test")
+                            (glib-or-gtk? #f)
+                            (parallel-build? #t)
+                            (parallel-tests? #f)
+                            (validate-runpath? #t)
+                            (patch-shebangs? #t)
+                            (strip-binaries? #t)
+                            (strip-flags ''("--strip-debug"))
+                            (strip-directories ''("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                            (elf-directories ''("lib" "lib64" "libexec"
+                                                "bin" "sbin"))
+                            (phases '%standard-phases)
+                            (system (%current-system))
+                            (imported-modules %meson-build-system-modules)
+                            (modules '((guix build meson-build-system)
+                                       (guix build utils)))
+                            allowed-references
+                            disallowed-references)
+  "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that
+SOURCE has a 'meson.build' file."
+  (define cross-file
+    (make-cross-file target))
+  (define inputs
+    (if (null? target-inputs)
+        (input-tuples->gexp host-inputs)
+        #~(append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs))))
+  (define builder
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@(sexp->gexp modules))
+
+          (define build-phases
+            #$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
+                (if glib-or-gtk?
+                    phases
+                    #~(modify-phases #$phases
+                        (delete 'glib-or-gtk-compile-schemas)
+                        (delete 'glib-or-gtk-wrap)))))
+
+          ;; Do not use 'with-build-variables', as there should be
+          ;; no reason to use %build-inputs and friends.
+          (meson-build #:source #+source
+                       #:system #$system
+                       #:outputs #$(outputs->gexp outputs)
+                       #:inputs #$inputs
+                       #:native-inputs #+(input-tuples->gexp build-inputs)
+                       #:search-paths '#$(sexp->gexp
+                                          (map search-path-specification->sexp
+                                                     search-paths))
+                       #:native-search-paths '#$(sexp->gexp
+                                                 (map search-path-specification->sexp
+                                                      native-search-paths))
+                       #:phases build-phases
+                       #:configure-flags `("--cross-file" #+cross-file
+                                           ,@#$(sexp->gexp configure-flags))
+                       #:build-type #$build-type
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:parallel-build? #$parallel-build?
+                       #:parallel-tests? #$parallel-tests?
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$(sexp->gexp strip-flags)
+                       #:strip-directories #$(sexp->gexp strip-directories)
+                       #:elf-directories #$(sexp->gexp elf-directories)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define meson-build-system
   (build-system
     (name 'meson)
diff --git a/guix/build/meson-configuration.scm b/guix/build/meson-configuration.scm
new file mode 100644
index 0000000000..81b4eaa7e1
--- /dev/null
+++ b/guix/build/meson-configuration.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-configuration)
+  #:use-module (ice-9 match)
+  #:export (write-section-header write-assignment
+            write-assignments make-machine-alist
+            configuration-port))
+
+;; Commentary:
+;;
+;; Utilities for generating a ‘Cross build definition file’ for
+;; the Meson build system.  Configuration values are currently
+;; never escaped.  In practice this is unlikely to be a problem
+;; in the build environment.
+;;
+;; Code:
+
+(define configuration-port
+  (fluid->parameter (make-unbound-fluid)))
+
+(define (write-section-header section-name)
+  "Write a section header for section named SECTION-NAME
+to the configuration port."
+  (format (configuration-port) "[~a]~%" section-name))
+
+(define (write-assignment key value)
+  "Write an assignment of VALUE to KEY to the configuration
+port.  VALUE must be a string (without any special characters
+such as quotes), a boolean or an integer.  Lists are currently
+not supported"
+  (define port (configuration-port))
+  (match value
+    ((? string?)
+     (format port "~a = '~a'~%" key value))
+    ((? integer?)
+     (format port "~a = ~a~%" key value))
+    (#f
+     (format port "~a = true~%" key))
+    (#t
+     (format port "~a = false~%" key))))
+
+(define* (write-assignments alist)
+  "Write the assignments in ALIST, an association list,
+to the configuration port."
+  (for-each (match-lambda
+              ((key . value)
+               (write-assignment key value)))
+            alist))
+
+(define* (make-machine-alist #:key system cpu-family cpu endian)
+  "Make an association list for the [host_machine] section."
+  `((system . ,system)
+    (cpu-family . ,cpu-family)
+    (cpu . ,cpu)
+    (endian . ,endian)))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu.
  2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
@ 2021-06-19  7:43     ` Maxime Devos
  0 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19  7:43 UTC (permalink / raw)
  To: 49025; +Cc: othacehe

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

Maxime Devos schreef op vr 18-06-2021 om 19:16 [+0200]:
> GCC doesn't find libgcc_s.so anymore and looks in the wrong
> location.  Fix this (well, more a work-around really).
> [...]

There exists a separate issue for this bug (bug#48913,
https://issues.guix.gnu.org) -- please send comments
there!

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
                   ` (3 preceding siblings ...)
  2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
@ 2021-06-19 15:04 ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate Maxime Devos
                     ` (36 more replies)
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
  6 siblings, 37 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This is the same as v1 (v2 and v3 are the same as v1 but the sending
was messed up), but with merge conflicts resolved. Also, one
patch of v1 is already on core-updates, so it is dropped here.

I'm currently testing whether things still work,
and whether the patch for GCC still works and if it is still
required.

Here is the old description:

This patch series adds cross-compilation support to meson-build-system.
meson-build-system is used by many gtk applications (sometimes directly,
sometimes because a dependency uses meson-build-system).

Meson cross-compilation is implemented by the last patch.
The one-before-last patch works-around the brokenness of
GCC cross-compilers on current core-updates
(see <http://issues.guix.gnu.org/48913>;).

The first two patches define a few utilities target-linux?,
target-x86-32? and target-x86-64? which are used by the last patch,
but could be useful elsewhere as well. The third patch is used
in various cross-compilation fixes.

The other 33 patches are cross-compilation fixes for dependencies
of glib, and follow-up patches making the package definitions
somewhat nicer IMHO (like removing trailing #t from phases,
and computing derivation for some architecture-independent packages
when cross-compiling and compiling natively).

Maxime Devos (36):
  utils: Define target-linux? predicate.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Make #:builder argument a G-expression.
  net-base: Fix cross-compilation, eliminating %build-inputs & friends
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpgerror: Maybe fix a cross-compilation bug.
  libgpg-error: Fix cross-compilation error.
  libgcrypt: Fix cross-compilation build error.
  wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  wrap-python3: Fix cross-compilation.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Find bin/env when cross-compiling.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  readline: Make #:configure-flags a G-expression.
  readline: Fix build error when cross-compiling.
  bash: Make #:configure-flags a G-expression.
  bash: Fix cross-compilation build error.
  fontconfig: Make the #:configure-flags argument a G-expression.
  fontconfig: Fix build error when cross-compiling.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  tk: Make #:configure-flags a G-expression.
  tk: Do not use %build-inputs when cross-compiling.
  libelf: Use the cross-compiler when cross-compiling.
  cross-base: Fix cross-compiler for i686-linux-gnu.
  meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |  44 ++++---
 gnu/packages/base.scm              |   9 ++
 gnu/packages/bash.scm              |  39 +++---
 gnu/packages/cross-base.scm        |  63 ++++++++-
 gnu/packages/elf.scm               |  48 ++++---
 gnu/packages/fontutils.scm         |   8 +-
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  60 ++++++---
 gnu/packages/python.scm            |  51 ++++----
 gnu/packages/readline.scm          |  27 ++--
 gnu/packages/tcl.scm               |  14 +-
 gnu/packages/tls.scm               | 142 +++++++++++----------
 guix/build-system/meson.scm        | 197 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 +++++++++++
 guix/packages.scm                  |  29 +++++
 guix/utils.scm                     |  26 ++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 19 files changed, 724 insertions(+), 213 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm


base-commit: bcdc13454c4afab37b650d4bbfa95e539060619f
-- 
2.32.0





^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 02/36] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
                     ` (35 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-linux?): New predicate.
* tests/utils.scm
  ("target-linux?"): Test it.
  ("target-mingw?"): Also test ‘target-mingw?’.
---
 guix/utils.scm  |  6 ++++++
 tests/utils.scm | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19990ceb8a..4ff2602e23 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,6 +82,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -543,6 +545,10 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  (string-contains target "linux"))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25552..80a0e669a4 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,22 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map (compose ->bool target-linux?)
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map (compose ->bool target-mingw?)
+       '("i686-linux-gnu" "i686-pc-gnu"
+         "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 02/36] utils: Define a target-x86-32? and target-x86-64? predicate.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input Maxime Devos
                     ` (34 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
---
 guix/utils.scm  | 20 ++++++++++++++++++++
 tests/utils.scm | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 4ff2602e23..2256ea2ca6 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -84,6 +84,8 @@
             package-name->name+version
             target-linux?
             target-mingw?
+            target-x86-32?
+            target-x86-64?
             target-arm32?
             target-aarch64?
             target-arm?
@@ -553,6 +555,24 @@ a character other than '@'."
   (and target
        (string-suffix? "-mingw32" target)))
 
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+                                                (%current-system))))
+  "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+  ;; Intel also has a 16-bit architecture in the iN86 series, i286
+  ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+  ;; procedure is not named target-x86?.
+  (or (string-prefix? "i386-" target)
+      (string-prefix? "i486-" target)
+      (string-prefix? "i586-" target)
+      (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+                                                 (%current-system))))
+  "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+  (string-prefix? "x86_64-" target))
+
 (define* (target-arm32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index 80a0e669a4..92439b5587 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
        '("i686-linux-gnu" "i686-pc-gnu"
          "i686-w64-mingw32")))
 
+(test-equal "target-x86-32?"
+  '(#f #f #f #t #t #t #t #f)
+  ;; These are (according to Wikipedia) two RISC architectures
+  ;; by Intel and presumably not compatible with the x86-32 series.
+  (map target-x86-32?
+       '("i860-gnu" "i960-gnu"
+         ;; This is a 16-bit architecture
+         "i286-gnu"
+         ;; These are part of the x86-32 series.
+         "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+         ;; Maybe this one will exist some day, but not yet.
+         "i786-gnu")))
+
+(test-equal "target-x86-64?"
+  '(#t #f #f #f)
+  (map target-x86-64?
+       `("x86_64-linux-gnu" "i386-linux-gnu"
+         ;; Just because it includes "64" doesn't make it 64-bit.
+         "aarch64-linux-gnu"
+         ;; Note that (expt 2 109) in decimal notation starts with 64.
+         ;; However, it isn't 32-bit.
+         ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 02/36] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 04/36] net-base: Make #:builder argument a G-expression Maxime Devos
                     ` (33 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index a66dbea1b7..80c8bbebf0 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47d10af5bc..91ec38e4cc 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1851,6 +1852,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 04/36] net-base: Make #:builder argument a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (2 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 05/36] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
                     ` (32 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp-native and this-package-native-input later.

* gnu/packages/admin.scm (net-base)[arguments]{#:builder}: Make this
  a G-expression.
---
 gnu/packages/admin.scm | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 48b9c8b893..230ba98b41 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -74,6 +74,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages autogen)
@@ -936,25 +937,25 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
-       #:builder (begin
-                   (use-modules (guix build utils)
-                                (srfi srfi-26))
-
-                   (let* ((source (assoc-ref %build-inputs "source"))
-                          (tar    (assoc-ref %build-inputs "tar"))
-                          (xz     (assoc-ref %build-inputs "xz"))
-                          (output (assoc-ref %outputs "out"))
-                          (etc    (string-append output "/etc")))
-                     (setenv "PATH" (string-append xz "/bin"))
-                     (invoke (string-append tar "/bin/tar") "xvf"
-                             source)
-                     (chdir ,(string-append "netbase-" version))
-                     (mkdir-p etc)
-                     (for-each copy-file
-                               '("etc-services" "etc-protocols" "etc-rpc")
-                               (map (cut string-append etc "/" <>)
-                                    '("services" "protocols" "rpc")))
-                     #t))))
+       #:builder ,#~(begin
+                      (use-modules (guix build utils)
+                                   (srfi srfi-26))
+
+                      (let* ((source (assoc-ref %build-inputs "source"))
+                             (tar    (assoc-ref %build-inputs "tar"))
+                             (xz     (assoc-ref %build-inputs "xz"))
+                             (output (assoc-ref %outputs "out"))
+                             (etc    (string-append output "/etc")))
+                        (setenv "PATH" (string-append xz "/bin"))
+                        (invoke (string-append tar "/bin/tar") "xvf"
+                                source)
+                        (chdir #$(string-append "netbase-" version))
+                        (mkdir-p etc)
+                        (for-each copy-file
+                                  '("etc-services" "etc-protocols" "etc-rpc")
+                                  (map (cut string-append etc "/" <>)
+                                       '("services" "protocols" "rpc")))
+                        #t))))
     (native-inputs `(("tar" ,tar)
                      ("xz" ,xz)))
     (synopsis "IANA protocol, port, and RPC number assignments")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 05/36] net-base: Fix cross-compilation, eliminating %build-inputs & friends
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (3 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 04/36] net-base: Make #:builder argument a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 06/36] net-base: Don't cross-compile Maxime Devos
                     ` (31 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"source" is not in %build-inputs when cross-compiling, so another
approach for referring to the package source code is needed.

* gnu/packages/admin.scm (net-base)[arguments]<#:builder>: Eliminate
  %build-inputs and %outputs.
---
 gnu/packages/admin.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 230ba98b41..e54be5a672 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -941,10 +941,10 @@ to allow automatic login and starting any app.")
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
 
-                      (let* ((source (assoc-ref %build-inputs "source"))
-                             (tar    (assoc-ref %build-inputs "tar"))
-                             (xz     (assoc-ref %build-inputs "xz"))
-                             (output (assoc-ref %outputs "out"))
+                      (let* ((source #+(package-source this-package))
+                             (tar    #+(this-package-native-input "tar"))
+                             (xz     #+(this-package-native-input "xz"))
+                             (output #$output)
                              (etc    (string-append output "/etc")))
                         (setenv "PATH" (string-append xz "/bin"))
                         (invoke (string-append tar "/bin/tar") "xvf"
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 06/36] net-base: Don't cross-compile.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (4 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 05/36] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 07/36] tzdata: Don't bother with cross-compiling Maxime Devos
                     ` (30 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

net-base is pure data, so cross-compiling is pointless.

* gnu/packages/admin.scm
  (net-base)[arguments]<#:target>: Set to #f.
  (net-base)[arguments]<#:allowed-references>: Disallow all
  references.
---
 gnu/packages/admin.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index e54be5a672..f8afc3d374 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -937,6 +937,11 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
+       ;; This package consists solely of architecture-independent
+       ;; tables. Cross-compilation is pointless! Make sure we'll
+       ;; always get the same derivation.
+       #:target #f
+       #:allowed-references ()
        #:builder ,#~(begin
                       (use-modules (guix build utils)
                                    (srfi srfi-26))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 07/36] tzdata: Don't bother with cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (5 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 06/36] net-base: Don't cross-compile Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 08/36] libgpg-error: Remove trailing #f from phases Maxime Devos
                     ` (29 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

The time zone database is architecture-independent,
so trying to cross-compile it is pointless!

* gnu/packages/base.scm
  (tzdata)[arguments]<#:target>: Set to #f.
  (tzdata)[allowed-references]: Only include the "out" output itself,
  to make sure no (architecture-dependent) binaries are installed.
---
 gnu/packages/base.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index edc4c4a427..62d6822750 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1255,6 +1256,14 @@ command.")
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f
+       ;; This consists purely of (architecture-independent) data,
+       ;; so ‘cross-compilation’ is pointless here!
+       ;; (The binaries zic, dump, and tzselect are deleted in the post-install
+       ;; phase.)
+       #:target #f
+       ;; share/zoneinfo/posix is a symlink to share/zoneinfo,
+       ;; so include the package itself in #:allowed-references.
+       #:allowed-references ("out")
        #:make-flags (let ((out (assoc-ref %outputs "out"))
                           (tmp (getenv "TMPDIR")))
                       (list (string-append "TOPDIR=" out)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 08/36] libgpg-error: Remove trailing #f from phases.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (6 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 07/36] tzdata: Don't bother with cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 09/36] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
                     ` (28 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

These aren't required anymore.

* gnu/packages/gnupg.scm (libgpgerror)[arguments]{cross-symlinks}:
  Remove trailing #f.
---
 gnu/packages/gnupg.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index cb481b38e1..2f44e6ec6a 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -114,8 +114,7 @@
                            (string-append x "-unknown-linux-gnu")))))
                    (symlink
                     (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))
-                 #t))))
+                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 09/36] libgpg-error: Prevent silent miscompilation some systems.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (7 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 08/36] libgpg-error: Remove trailing #f from phases Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 10/36] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
                     ` (27 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/gpg.scm
  (libgpgerror)[arguments]<#:phases>{cross-symlinks}: Only
  link to src/syscfg/lock-obj-pub.linux-gnu.h if the package
  is being compiled for a Linux target. Do not link either
  if the architecture is unknown, as the headers vary with
  the architecture.
---
 gnu/packages/gnupg.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 2f44e6ec6a..de213d381f 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
 (define-public libgpg-error
@@ -94,27 +96,37 @@
     (build-system gnu-build-system)
     (arguments
      (if (%current-target-system)
-         `(#:modules ((ice-9 match)
-                      (guix build gnu-build-system)
+         `(#:modules ((guix build gnu-build-system)
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
-             ;; file. See Cross-Compiling section at:
+             ;; file if required. Note that these platform files depend on
+             ;; both the operating system and architecture!
+             ;;
+             ;; See Cross-Compiling section at:
              ;; https://github.com/gpg/libgpg-error/blob/master/README
              (add-after 'unpack 'cross-symlinks
-               (lambda* (#:key target inputs #:allow-other-keys)
-                 (let ((triplet
-                        (match (string-take target
-                                            (string-index target #\-))
-                          ("armhf" "arm-unknown-linux-gnueabi")
-                          ("mips64el" "mips-unknown-linux-gnu")
-                          (x
-                           (string-append x "-unknown-linux-gnu")))))
-                   (symlink
-                    (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
+               (lambda _
+                 (define (link triplet source)
+                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                            (string-append "src/syscfg/lock-obj-pub."
+                                           source ".h")))
+                 ,(let* ((target (%current-target-system))
+                         (architecture
+                          (string-take target (string-index target #\-))))
+                    (cond ((target-linux? target)
+                           (match architecture
+                             ("armhf"
+                              `(link "arm-unknown-linux-gnueabi" "linux-gnu"))
+                             ("mips64el"
+                              `(link "mips-unknown-linux-gnu" "linux-gnu"))
+                             ;; Don't always link to the "linux-gnu"
+                             ;; configuration, as this is not correct for
+                             ;; all architectures.
+                             (_ #t)))
+                          (#t #t)))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 10/36] libgpgerror: Maybe fix a cross-compilation bug.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (8 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 09/36] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 11/36] libgpg-error: Fix cross-compilation error Maxime Devos
                     ` (26 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Previously, a symlink was created at
src/syscfg/lock-obj-pub.linux-gnu.h pointing at
lock-obj-pub.MANGLED-TARGET.h. I would think this has
to be the other way around, but I am not really sure.

* gnu/packages/gnupg.scm
  (gnupg)[arguments]<#:phases>{cross-symlinks}(link): Switch
  'triplet' and 'source'.
---
 gnu/packages/gnupg.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index de213d381f..f5d4118af9 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -110,9 +110,9 @@
              (add-after 'unpack 'cross-symlinks
                (lambda _
                  (define (link triplet source)
-                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                   (symlink (string-append "lock-obj-pub." source ".h")
                             (string-append "src/syscfg/lock-obj-pub."
-                                           source ".h")))
+                                           triplet ".h")))
                  ,(let* ((target (%current-target-system))
                          (architecture
                           (string-take target (string-index target #\-))))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 11/36] libgpg-error: Fix cross-compilation error.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (9 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 10/36] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 12/36] libgcrypt: Fix cross-compilation build error Maxime Devos
                     ` (25 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

TODO: inform upstream about the cross-compilation error.

* gnu/packages/gnupg.scm
  (libgpg-error)[arguments]{fix-gen-lock-obj.sh}: Prevent generated
  header files from being sprinkled with ‘\c’.
---
 gnu/packages/gnupg.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index f5d4118af9..1fee30584c 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -100,6 +100,13 @@
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
+             ;; If this is left out, some generated header
+             ;; files will be sprinkled with ‘\c’, which
+             ;; the compiler won't like.
+             (add-after 'unpack 'fix-gen-lock-obj.sh
+               (lambda _
+                 (substitute* "src/gen-lock-obj.sh"
+                   (("if test -n `echo -n`") "if ! test -n `echo -n`"))))
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
              ;; file if required. Note that these platform files depend on
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 12/36] libgcrypt: Fix cross-compilation build error.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (10 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 11/36] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 13/36] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
                     ` (24 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling a package using gnu-build-system,
%build-inputs does not exist. But libgcrypt uses %build-inputs
anyway. Fix it.

* gnu/packages/gnupg.scm
  (libgcrypt)[arguments]<#:configure-flags>: Make this a G-exp
  instead of a raw S-exp. Eliminate %build-inputs and use
  this-package-input instead.
---
 gnu/packages/gnupg.scm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 1fee30584c..35cfdf6f43 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -74,6 +74,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
@@ -169,11 +170,12 @@ Daemon and possibly more in the future.")
      ;; 'configure' uses 'gpg-error-config' to determine the '-L' flag, and
      ;; the 'gpg-error-config' it runs is the native one---i.e., the wrong one.
      `(#:configure-flags
-       (list (string-append "--with-gpg-error-prefix="
-                            (assoc-ref %build-inputs "libgpg-error-host"))
-             ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
-             ,@(if (%current-target-system) '("--disable-asm")
-                   '()))))
+       ,#~(list (string-append "--with-gpg-error-prefix="
+                               #$(this-package-input "libgpg-error-host"))
+                ;; When cross-compiling, _gcry_mpih_lshift etc are undefined
+                #$@(if (%current-target-system)
+                       #~("--disable-asm")
+                       #~()))))
     (outputs '("out" "debug"))
     (home-page "https://gnupg.org/")
     (synopsis "Cryptographic function library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 13/36] wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (11 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 12/36] libgcrypt: Fix cross-compilation build error Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 14/36] wrap-python3: Fix cross-compilation Maxime Devos
                     ` (23 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using ungexp later.

* gnu/packages/python.scm (wrap-python3)<#:builder>: Make this
  a G-expression.
---
 gnu/packages/python.scm | 46 ++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 227c612a68..fe8b93b1ba 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -636,29 +636,29 @@ for more information.")))
     (arguments
      `(#:modules ((guix build utils))
        #:builder
-         (begin
-           (use-modules (guix build utils))
-           (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                 (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
-                (mkdir-p bin)
-                (for-each
-                  (lambda (old new)
-                    (symlink (string-append python old)
-                             (string-append bin "/" new)))
-                  `("python3" ,"pydoc3" ,"pip3")
-                  `("python"  ,"pydoc"  ,"pip"))
-                ;; python-config outputs search paths based upon its location,
-                ;; use a bash wrapper to avoid changing its outputs.
-                (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                           "/bin/bash"))
-                      (old  (string-append python "python3-config"))
-                      (new  (string-append bin "/python-config")))
-                  (with-output-to-file new
-                    (lambda ()
-                      (format #t "#!~a~%" bash)
-                      (format #t "exec \"~a\" \"$@\"~%" old)
-                      (chmod new #o755)
-                      #t)))))))
+       ,#~(begin
+            (use-modules (guix build utils))
+            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
+                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
+                 (mkdir-p bin)
+              (for-each
+                (lambda (old new)
+                  (symlink (string-append python old)
+                           (string-append bin "/" new)))
+                `("python3" ,"pydoc3" ,"idle3" ,"pip3")
+                `("python"  ,"pydoc"  ,"idle"  ,"pip"))
+              ;; python-config outputs search paths based upon its location,
+              ;; use a bash wrapper to avoid changing its outputs.
+              (let ((bash (string-append (assoc-ref %build-inputs "bash")
+                                         "/bin/bash"))
+                    (old  (string-append python "python3-config"))
+                    (new  (string-append bin "/python-config")))
+                (with-output-to-file new
+                  (lambda ()
+                    (format #t "#!~a~%" bash)
+                    (format #t "exec \"~a\" \"$@\"~%" old)
+                    (chmod new #o755)
+                    #t)))))))
     (synopsis "Wrapper for the Python 3 commands")
     (description
      "This package provides wrappers for the commands of Python@tie{}3.x such
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 14/36] wrap-python3: Fix cross-compilation.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (12 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 13/36] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 15/36] python: Fix reference to input when cross-compiling Maxime Devos
                     ` (22 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

When cross-compiling, "bash" is missing from %build-inputs,
leading to a build error. Use this-package-input instead of
%build-inputs to resolve this. While we're at it, eliminate
all uses of %outputs and %build-inputs.

* gnu/packages/python.scm
  (wrap-python3)[arguments]<#:builder>: Eliminate %outputs
  and %build-inputs.
---
 gnu/packages/python.scm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index fe8b93b1ba..8688104463 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -60,6 +60,7 @@
 ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -638,9 +639,9 @@ for more information.")))
        #:builder
        ,#~(begin
             (use-modules (guix build utils))
-            (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
-                  (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
-                 (mkdir-p bin)
+            (let ((bin (string-append #$output "/bin"))
+                  (python #$(file-append (this-package-input "python") "/bin/")))
+              (mkdir-p bin)
               (for-each
                 (lambda (old new)
                   (symlink (string-append python old)
@@ -649,8 +650,7 @@ for more information.")))
                 `("python"  ,"pydoc"  ,"idle"  ,"pip"))
               ;; python-config outputs search paths based upon its location,
               ;; use a bash wrapper to avoid changing its outputs.
-              (let ((bash (string-append (assoc-ref %build-inputs "bash")
-                                         "/bin/bash"))
+              (let ((bash #$(file-append (this-package-input "bash") "/bin/bash"))
                     (old  (string-append python "python3-config"))
                     (new  (string-append bin "/python-config")))
                 (with-output-to-file new
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 15/36] python: Fix reference to input when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (13 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 14/36] wrap-python3: Fix cross-compilation Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 16/36] openssl: Remove trailing #t from phases Maxime Devos
                     ` (21 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

"sitecustomize.py" is a native input, so look it up
in 'native-inputs', not 'inputs'.

* gnu/packages/python.scm (customize-site): Look up "sizecustomize.py"
  in 'native-inputs', not 'inputs'.
---
 gnu/packages/python.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 8688104463..e72f888111 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -111,13 +111,14 @@
 
 (define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
-  `(lambda* (#:key inputs outputs #:allow-other-keys)
+  `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
-            (sitecustomize.py (assoc-ref inputs "sitecustomize.py"))
+            (sitecustomize.py (assoc-ref (or native-inputs inputs)
+                                         "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 16/36] openssl: Remove trailing #t from phases.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (14 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 15/36] python: Fix reference to input when cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 17/36] openssl: Make the #:phases argument a G-expression Maxime Devos
                     ` (20 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Delete trailing #t.
---
 gnu/packages/tls.scm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 31ffdb2a8a..3688449efe 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -363,8 +363,7 @@ required structures.")
                            ((string-prefix? "powerpc64" target)
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
-                            "linux-ppc")))
-                 #t)))
+                            "linux-ppc"))))))
            '())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
@@ -403,8 +402,7 @@ required structures.")
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
-                        (find-files lib "\\.a$"))
-              #t)))
+                        (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda* (#:key outputs #:allow-other-keys)
                ;; Move man3 pages and full HTML documentation to "doc".
@@ -417,8 +415,7 @@ required structures.")
                  (copy-recursively man3 man-target)
                  (delete-file-recursively man3)
                  (copy-recursively html html-target)
-                 (delete-file-recursively html)
-                 #t)))
+                 (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
          (lambda* (#:key outputs #:allow-other-keys)
@@ -427,8 +424,7 @@ required structures.")
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
                                                      ,(package-version this-package)
-                                                     "/misc"))
-             #t))))))
+                                                     "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 17/36] openssl: Make the #:phases argument a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (15 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 16/36] openssl: Remove trailing #t from phases Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 18/36] openssl: Use G-exp machinery for referring to outputs Maxime Devos
                     ` (19 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-native-input later.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Make this a G-expression.
  (openssl-1.0)[arguments]<#:phases>: Likewise.
---
 gnu/packages/tls.scm | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 3688449efe..f561c28251 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -39,6 +39,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -338,9 +339,10 @@ required structures.")
       ;; so we explicitly disallow it here.
       #:disallowed-references ,(list (canonical-package perl))
       #:phases
+      ,#~
       (modify-phases %standard-phases
-       ,@(if (%current-target-system)
-           '((add-before
+       #$@(if (%current-target-system)
+          #~((add-before
                'configure 'set-cross-compile
                (lambda* (#:key target outputs #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
@@ -364,7 +366,7 @@ required structures.")
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
                             "linux-ppc"))))))
-           '())
+             #~())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
@@ -374,9 +376,9 @@ required structures.")
                 (("/usr/bin/env")
                  (string-append (assoc-ref %build-inputs "coreutils")
                                 "/bin/env")))
-              (invoke ,@(if (%current-target-system)
-                          '("./Configure")
-                          '("./config"))
+              (invoke #$@(if (%current-target-system)
+                             #~("./Configure")
+                             #~("./config"))
                       "shared"       ;build shared libraries
                       "--libdir=lib"
 
@@ -385,13 +387,13 @@ required structures.")
                       ;; conventional.
                       (string-append "--openssldir=" out
                                      "/share/openssl-"
-                                     ,(package-version this-package))
+                                     #$(package-version this-package))
 
                       (string-append "--prefix=" out)
                       (string-append "-Wl,-rpath," lib)
-                      ,@(if (%current-target-system)
-                          '((getenv "CONFIGURE_TARGET_ARCH"))
-                          '())))))
+                      #$@(if (%current-target-system)
+                             #~((getenv "CONFIGURE_TARGET_ARCH"))
+                             #~())))))
         (add-after 'install 'move-static-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Move static libraries to the "static" output.
@@ -423,7 +425,7 @@ required structures.")
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
-                                                     ,(package-version this-package)
+                                                     #$(package-version this-package)
                                                      "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
@@ -468,7 +470,7 @@ required structures.")
        ;; Parallel build is not supported in 1.0.x.
        ((#:parallel-build? _ #f) #f)
        ((#:phases phases)
-        `(modify-phases ,phases
+       #~(modify-phases #$phases
            (add-before 'patch-source-shebangs 'patch-tests
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
@@ -491,9 +493,9 @@ required structures.")
 	     ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
 	     (lambda* (#:key outputs #:allow-other-keys)
 	       (let ((out (assoc-ref outputs "out")))
-		 (invoke ,@(if (%current-target-system)
-			       '("./Configure")
-			       '("./config"))
+		 (invoke #$@(if (%current-target-system)
+			        #~("./Configure")
+			        #~("./config"))
 			 "shared"                 ;build shared libraries
 			 "--libdir=lib"
 
@@ -501,12 +503,12 @@ required structures.")
 			 ;; PREFIX/ssl.  Change that to something more
 			 ;; conventional.
 			 (string-append "--openssldir=" out
-					"/share/openssl-" ,version)
+					"/share/openssl-" #$version)
 
 			 (string-append "--prefix=" out)
-			 ,@(if (%current-target-system)
-			       '((getenv "CONFIGURE_TARGET_ARCH"))
-			       '())))))
+			 #$@(if (%current-target-system)
+			        '((getenv "CONFIGURE_TARGET_ARCH"))
+			        '())))))
         (delete 'move-extra-documentation)
         (add-after 'install 'move-man3-pages
           (lambda* (#:key outputs #:allow-other-keys)
@@ -531,7 +533,7 @@ required structures.")
                ;; scripts.  Remove them to avoid retaining a reference on Perl.
                (let ((out (assoc-ref outputs "out")))
                  (delete-file-recursively (string-append out "/share/openssl-"
-                                                         ,version "/misc"))
+                                                         #$version "/misc"))
                  #t)))))))))
 
 (define-public libressl
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 18/36] openssl: Use G-exp machinery for referring to outputs.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (16 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 17/36] openssl: Make the #:phases argument a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 19/36] openssl: Move documentation instead of copying and deleting it Maxime Devos
                     ` (18 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This doesn't fix anything broken, just for simplifying
the code a little while we're rebuilding the world anyway.
IMHO this makes the code a little more readable.

* gnu/packages/tls.scm (openssl)[arguments]<#:phases>: Don't refer
  to the association list 'outputs', use #$output, #$output:doc
  and #$output:static instead.
---
 gnu/packages/tls.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index f561c28251..669d33f8de 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Solene Rapenne <solene@perso.pw>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -344,7 +345,7 @@ required structures.")
        #$@(if (%current-target-system)
           #~((add-before
                'configure 'set-cross-compile
-               (lambda* (#:key target outputs #:allow-other-keys)
+               (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
                          (cond
@@ -368,8 +369,8 @@ required structures.")
                             "linux-ppc"))))))
              #~())
         (replace 'configure
-          (lambda* (#:key outputs #:allow-other-keys)
-            (let* ((out (assoc-ref outputs "out"))
+          (lambda _
+            (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
               (substitute* "config"
@@ -395,23 +396,23 @@ required structures.")
                              #~((getenv "CONFIGURE_TARGET_ARCH"))
                              #~())))))
         (add-after 'install 'move-static-libraries
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
             ;; Move static libraries to the "static" output.
-            (let* ((out    (assoc-ref outputs "out"))
+            (let* ((out    #$output)
                    (lib    (string-append out "/lib"))
-                   (static (assoc-ref outputs "static"))
+                   (static #$output:static)
                    (slib   (string-append static "/lib")))
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
                ;; Move man3 pages and full HTML documentation to "doc".
-               (let* ((out    (assoc-ref outputs "out"))
+               (let* ((out    #$output)
                       (man3   (string-append out "/share/man/man3"))
                       (html (string-append out "/share/doc/openssl"))
-                      (doc    (assoc-ref outputs "doc"))
+                      (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
                  (copy-recursively man3 man-target)
@@ -420,13 +421,12 @@ required structures.")
                  (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
-         (lambda* (#:key outputs #:allow-other-keys)
+         (lambda _
            ;; The 'misc' directory contains random undocumented shell and Perl
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
-           (let ((out (assoc-ref outputs "out")))
-             (delete-file-recursively (string-append out "/share/openssl-"
-                                                     #$(package-version this-package)
-                                                     "/misc"))))))))
+           (delete-file-recursively (string-append #$output "/share/openssl-"
+                                                   #$(package-version this-package)
+                                                   "/misc")))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 19/36] openssl: Move documentation instead of copying and deleting it.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (17 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 18/36] openssl: Use G-exp machinery for referring to outputs Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 20/36] openssl: Move all man pages to separate output, not only man3 Maxime Devos
                     ` (17 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Use
  'rename-file' instead of 'copy-recursively' and
  'delete-file-recursively'.
---
 gnu/packages/tls.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 669d33f8de..4efbb4197f 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -415,10 +415,10 @@ required structures.")
                       (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (copy-recursively man3 man-target)
-                 (delete-file-recursively man3)
-                 (copy-recursively html html-target)
-                 (delete-file-recursively html))))
+                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname html-target))
+                 (rename-file man3 man-target)
+                 (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
          (lambda _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 20/36] openssl: Move all man pages to separate output, not only man3.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (18 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 19/36] openssl: Move documentation instead of copying and deleting it Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 21/36] openssl: Find bin/env when cross-compiling Maxime Devos
                     ` (16 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

There does not seem to be any reason to only move man3 pages.
So, move all man pages to a separate output for documentation.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Move
  all man pages, not only man3.
---
 gnu/packages/tls.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 4efbb4197f..dc9147c1e1 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -408,16 +408,16 @@ required structures.")
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda _
-               ;; Move man3 pages and full HTML documentation to "doc".
+               ;; Move man pages and full HTML documentation to "doc".
                (let* ((out    #$output)
-                      (man3   (string-append out "/share/man/man3"))
-                      (html (string-append out "/share/doc/openssl"))
+                      (man    (string-append out "/share/man"))
+                      (html   (string-append out "/share/doc/openssl"))
                       (doc    #$output:doc)
-                      (man-target (string-append doc "/share/man/man3"))
+                      (man-target (string-append doc "/share/man"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname man-target))
                  (mkdir-p (dirname html-target))
-                 (rename-file man3 man-target)
+                 (rename-file man man-target)
                  (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 21/36] openssl: Find bin/env when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (19 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 20/36] openssl: Move all man pages to separate output, not only man3 Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
                     ` (15 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so find bin/env by another way.

* (openssl)[arguments]<#:phases>{configure}: Don't use '%build-inputs',
  use 'which' instead.
---
 gnu/packages/tls.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index dc9147c1e1..72a1cd8f0c 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -373,10 +373,10 @@ required structures.")
             (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
+              ;; Don't use (assoc-ref %build-inputs "coreutils"), as
+              ;; %build-inputs is not defined when cross-compiling.
               (substitute* "config"
-                (("/usr/bin/env")
-                 (string-append (assoc-ref %build-inputs "coreutils")
-                                "/bin/env")))
+                (("/usr/bin/env") (which "env")))
               (invoke #$@(if (%current-target-system)
                              #~("./Configure")
                              #~("./config"))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (20 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 21/36] openssl: Find bin/env when cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-07-03 15:47     ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 23/36] readline: Make #:configure-flags a G-expression Maxime Devos
                     ` (14 subsequent siblings)
  36 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

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(-)

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 _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 23/36] readline: Make #:configure-flags a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (21 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 24/36] readline: Fix build error when cross-compiling Maxime Devos
                     ` (13 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allos using ungexp and this-package-input later.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Make this a
  G-expression.
---
 gnu/packages/readline.scm | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index ced8471887..7823a4e6ad 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -31,6 +31,7 @@
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (ice-9 format))
 
 (define (patch-url version seqno)
@@ -78,19 +79,19 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                      (assoc-ref %build-inputs "ncurses")
-                                      "/lib")
+                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
+                                         (assoc-ref %build-inputs "ncurses")
+                                         "/lib")
 
-                       ;; This test does an 'AC_TRY_RUN', which aborts when
-                       ;; cross-compiling, so provide the correct answer.
-                       ,@(if (%current-target-system)
-                             '("bash_cv_wcwidth_broken=no")
-                             '())
-                       ;; MinGW: ncurses provides the termcap api.
-                       ,@(if (target-mingw?)
-                             '("bash_cv_termcap_lib=ncurses")
-                             '()))
+                          ;; This test does an 'AC_TRY_RUN', which aborts when
+                          ;; cross-compiling, so provide the correct answer.
+                          #$@(if (%current-target-system)
+                                 '("bash_cv_wcwidth_broken=no")
+                                 '())
+                          ;; MinGW: ncurses provides the termcap api.
+                          #$@(if (target-mingw?)
+                                 '("bash_cv_termcap_lib=ncurses")
+                                 '()))
 
                  ,@(if (target-mingw?)
                        ;; MinGW: termcap in ncurses
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 24/36] readline: Fix build error when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (22 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 23/36] readline: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 25/36] bash: Make #:configure-flags a G-expression Maxime Devos
                     ` (12 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling, so
use this-package-input instead.

* gnu/packages/readline.scm
  (readline)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/readline.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index 7823a4e6ad..94684702b7 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2018, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -79,9 +80,10 @@
     (build-system gnu-build-system)
     (propagated-inputs `(("ncurses" ,ncurses)))
     (arguments `(#:configure-flags
-                 ,#~(list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                         (assoc-ref %build-inputs "ncurses")
-                                         "/lib")
+                 ,#~(list (string-append
+                           "LDFLAGS=-Wl,-rpath -Wl,"
+                           #$(this-package-input "ncurses")
+                           "/lib")
 
                           ;; This test does an 'AC_TRY_RUN', which aborts when
                           ;; cross-compiling, so provide the correct answer.
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 25/36] bash: Make #:configure-flags a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (23 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 24/36] readline: Fix build error when cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 26/36] bash: Fix cross-compilation build error Maxime Devos
                     ` (11 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using this-package-input later.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Make this a G-expression
  instead of a raw S-expression.
---
 gnu/packages/bash.scm | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 7e98367bbb..b3af873a66 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -109,15 +109,15 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
                                   "-DSSH_SOURCE_BASHRC")
                                 " "))
          (configure-flags
-          ``("--with-installed-readline"
-             ,,(string-append "CPPFLAGS=" cppflags)
-             ,(string-append
-               "LDFLAGS=-Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "readline")
-               "/lib"
-               " -Wl,-rpath -Wl,"
-               (assoc-ref %build-inputs "ncurses")
-               "/lib")))
+          #~`("--with-installed-readline"
+              ,#$(string-append "CPPFLAGS=" cppflags)
+              ,(string-append
+                "LDFLAGS=-Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "readline")
+                "/lib"
+                " -Wl,-rpath -Wl,"
+                (assoc-ref %build-inputs "ncurses")
+                "/lib")))
          (version "5.1"))
     (package
      (name "bash")
@@ -143,8 +143,8 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
       `(;; When cross-compiling, `configure' incorrectly guesses that job
         ;; control is missing.
         #:configure-flags ,(if (%current-target-system)
-                               `(cons* "bash_cv_job_control_missing=no"
-                                       ,configure-flags)
+                               #~(cons* "bash_cv_job_control_missing=no"
+                                        #$configure-flags)
                                configure-flags)
 
         ;; Bash is reportedly not parallel-safe.  See, for instance,
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 26/36] bash: Fix cross-compilation build error.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (24 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 25/36] bash: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 27/36] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
                     ` (10 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use this-package-input instead.

* gnu/packages/bash.scm
  (bash)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/bash.scm | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index b3af873a66..d51ab26bc8 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -103,22 +103,25 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
           1))
 
 (define-public bash
-  (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
-                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
-                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
-                                  "-DSSH_SOURCE_BASHRC")
-                                " "))
-         (configure-flags
-          #~`("--with-installed-readline"
-              ,#$(string-append "CPPFLAGS=" cppflags)
-              ,(string-append
-                "LDFLAGS=-Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "readline")
-                "/lib"
-                " -Wl,-rpath -Wl,"
-                (assoc-ref %build-inputs "ncurses")
-                "/lib")))
-         (version "5.1"))
+  (let ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
+                                 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
+                                 "-DNON_INTERACTIVE_LOGIN_SHELLS"
+                                 "-DSSH_SOURCE_BASHRC")
+                               " "))
+        (version "5.1"))
+    ;; Delay expansion to inside a lexical environment
+    ;; where this-package is bound.
+    (define-syntax configure-flags
+      (identifier-syntax
+       #~`("--with-installed-readline"
+           ,#$(string-append "CPPFLAGS=" cppflags)
+           ,(string-append
+             "LDFLAGS=-Wl,-rpath -Wl,"
+             ;; %build-inputs does not exist when cross-compiling,
+             ;; so use this-package-input instead.
+             #$(file-append (this-package-input "readline") "/lib")
+             " -Wl,-rpath -Wl,"
+             #$(file-append (this-package-input "ncurses") "/lib")))))
     (package
      (name "bash")
      (source (origin
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 27/36] fontconfig: Make the #:configure-flags argument a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (25 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 26/36] bash: Fix cross-compilation build error Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 28/36] fontconfig: Fix build error when cross-compiling Maxime Devos
                     ` (9 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Make this a
  G-expression instead of a raw S-expression.
  (fontconfig-with-documentation)[arguments]<#:configure-flags>: Likewise.
---
 gnu/packages/fontutils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index dbce5beba8..234f11129a 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -64,6 +64,7 @@
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages tex)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix svn-download)
@@ -347,6 +348,7 @@ Font Format (WOFF).")
         ("python" ,python-minimal)))    ;to avoid a cycle through tk
      (arguments
       `(#:configure-flags
+        ,#~
         (list "--disable-docs"
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
@@ -400,7 +402,7 @@ high quality, anti-aliased and subpixel rendered text on a display.")
     (arguments
      (substitute-keyword-arguments (package-arguments fontconfig)
        ((#:configure-flags configure-flags)
-        `(delete "--disable-docs" ,configure-flags))
+        #~(delete "--disable-docs" #$configure-flags))
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
            (add-after 'install 'move-man-sections
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 28/36] fontconfig: Fix build error when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (26 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 27/36] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 29/36] glib: Use a correct python in scripts " Maxime Devos
                     ` (8 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exist when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/fontutils.scm
  (fontconfig)[arguments]<#:configure-flags>: Use this-package-input
  instead of %build-inputs.
---
 gnu/packages/fontutils.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 234f11129a..b0d40efeae 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -353,8 +353,8 @@ Font Format (WOFF).")
               "--with-cache-dir=/var/cache/fontconfig"
               ;; register the default fonts
               (string-append "--with-default-fonts="
-                             (assoc-ref %build-inputs "font-dejavu")
-                             "/share/fonts")
+                             #$(file-append (this-package-input "font-dejavu")
+                                            "/share/fonts"))
 
               ;; Register fonts from user and system profiles.
               (string-append "--with-add-fonts="
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 29/36] glib: Use a correct python in scripts when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (27 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 28/36] fontconfig: Fix build error when cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 30/36] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
                     ` (7 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

During the build, a native python should be used as these
scripts will be invoked during the build, but when installed,
they should be a python for the system we're compiling for.

* gnu/packages/glib.scm
  (glib)[arguments]<#:phases>{patch-python-references}: Look up
  "python" in 'native-inputs', not 'inputs'.
  (glib)[inputs]{python,python-wrapper,bash-minimal}: New inputs.
---
 gnu/packages/glib.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index f0be2ddaa4..4f40488df8 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -223,14 +224,19 @@ shared NFS home directories.")
              #t))
          ;; Python references are not being patched in patch-phase of build,
          ;; despite using python-wrapper as input. So we patch them manually.
+         ;;
+         ;; These python scripts are both used during build and installed,
+         ;; so at first, use a python from 'native-inputs', not 'inputs'. When
+         ;; cross-compiling, the 'patch-shebangs' phase will replace
+         ;; the native python with a python from 'inputs'.
          (add-after 'unpack 'patch-python-references
-           (lambda* (#:key inputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
              (substitute* '("gio/gdbus-2.0/codegen/gdbus-codegen.in"
                             "glib/gtester-report.in"
                             "gobject/glib-genmarshal.in"
                             "gobject/glib-mkenums.in")
                (("@PYTHON@")
-                (string-append (assoc-ref inputs "python")
+                (string-append (assoc-ref (or native-inputs inputs) "python")
                                "/bin/python"
                                ,(version-major+minor
                                  (package-version python)))))
@@ -293,6 +299,13 @@ shared NFS home directories.")
        ("xsltproc" ,libxslt)))
     (inputs
      `(("bash-completion" ,bash-completion)
+       ;; "python", "python-wrapper" and "bash-minimal"
+       ;; are for the 'patch-shebangs' phase, to make
+       ;; sure the installed scripts end up with a correct shebang
+       ;; when cross-compiling.
+       ("python" ,python)
+       ("python-wrapper" ,python-wrapper)
+       ("bash-minimal" ,(canonical-package bash-minimal))
        ("dbus" ,dbus)
        ("libelf" ,libelf)))
     (propagated-inputs
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 30/36] glib: Verify the cross-compiled python is used in installed scripts.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (28 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 29/36] glib: Use a correct python in scripts " Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 31/36] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
                     ` (6 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/glib.scm (glib)[arguments]<#:disallowed-references>:
  Disallow the native python when cross-compiling.
---
 gnu/packages/glib.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 4f40488df8..22bd384fa7 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -77,6 +77,8 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-26)
   #:use-module ((srfi srfi-1) #:hide (zip))
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
@@ -200,7 +202,15 @@ shared NFS home directories.")
                "static"                 ;static libraries
                "bin"))                  ;executables; depends on Python
     (arguments
-     `(#:disallowed-references (,tzdata-for-tests)
+     `(#:disallowed-references
+       (,tzdata-for-tests
+        ;; Verify glib-mkenums, gtester, ... use the cross-compiled
+        ;; python.
+        ,@(if (%current-target-system)
+              (map (cut gexp-input <> #:native? #t)
+                   `(,(this-package-native-input "python")
+                     ,(this-package-native-input "python-wrapper")))
+              '()))
        #:configure-flags '("--default-library=both"
                            "-Dman=true"
                            "-Dselinux=disabled")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 31/36] glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (29 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 30/36] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 32/36] tk: Make #:configure-flags a G-expression Maxime Devos
                     ` (5 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

Otherwise, "tzdata" won't be found when cross-compiling
and string-append will complain about types. Alternatively,
"tzdata" could be moved from 'native-inputs' to 'inputs'.

* gnu/packages/glib.scm (glib)[arguments]<#:phases>{pre-check}:
  Look up "tzdata" in 'native-inputs', not 'inputs'.
---
 gnu/packages/glib.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 22bd384fa7..d3879879de 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -252,10 +252,11 @@ shared NFS home directories.")
                                  (package-version python)))))
              #t))
          (add-before 'check 'pre-check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              ;; For tests/gdatetime.c.
              (setenv "TZDIR"
-                     (string-append (assoc-ref inputs "tzdata")
+                     (string-append (assoc-ref (or native-inputs inputs)
+                                               "tzdata")
                                     "/share/zoneinfo"))
              ;; Some tests want write access there.
              (setenv "HOME" (getcwd))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 32/36] tk: Make #:configure-flags a G-expression.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (30 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 31/36] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 33/36] tk: Do not use %build-inputs when cross-compiling Maxime Devos
                     ` (4 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

This allows using #$(this-package-input ...) later.

* gnu/packages/tcl.scm (tk)[arguments]<#:configure-flags>: Make
  this a G-expression instead of an S-expression.
---
 gnu/packages/tcl.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index 5fccfa5da9..c87a8187f2 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -230,15 +230,16 @@ X11 GUIs.")
                                           "/lib -lfontconfig")))))))
 
        #:configure-flags
+       ,#~
        (list (string-append "--with-tcl="
                             (assoc-ref %build-inputs "tcl")
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-             ,@(if (%current-target-system)
-                   '("tcl_cv_strtod_buggy=1"
-                     "ac_cv_func_strtod=yes")
-                   '()))
+             #$@(if (%current-target-system)
+                    #~("tcl_cv_strtod_buggy=1"
+                        "ac_cv_func_strtod=yes")
+                    #~()))
 
        ;; The tests require a running X server, so we just skip them.
        #:tests? #f))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 33/36] tk: Do not use %build-inputs when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (31 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 32/36] tk: Make #:configure-flags a G-expression Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 34/36] libelf: Use the cross-compiler " Maxime Devos
                     ` (3 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

%build-inputs does not exists when cross-compiling,
so use #$(this-package-input ...) instead.

* gnu/packages/tcl.scm
  (tk)[arguments]<#:configure-flags>: Use 'this-package-input'
  instead of '%build-inputs' when cross-compiling.
---
 gnu/packages/tcl.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index c87a8187f2..91ba8bbb3f 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -29,6 +29,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -232,7 +233,9 @@ X11 GUIs.")
        #:configure-flags
        ,#~
        (list (string-append "--with-tcl="
-                            (assoc-ref %build-inputs "tcl")
+                            #$(if (%current-target-system)
+                                  (this-package-input "tcl")
+                                  #~(assoc-ref %build-inputs "tcl"))
                             "/lib")
              ;; This is needed when cross-compiling, see:
              ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719247
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 34/36] libelf: Use the cross-compiler when cross-compiling.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (32 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 33/36] tk: Do not use %build-inputs when cross-compiling Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 35/36] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
                     ` (2 subsequent siblings)
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script when cross-compiling.
  (libelf)[arguments]<#:phases>{configure}: Do not replace
  when cross-compiling.
  (libelf)[native-inputs]: Add autoconf when cross-compiling.
---
 gnu/packages/elf.scm | 48 +++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..66c2334e5c 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,36 @@ static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ,(if (%current-target-system)
+              ;; This old 'configure' script doesn't
+              ;; support cross-compilation well. E.g., it fails
+              ;; to find the cross-compiler.
+              `(add-before 'bootstrap 'delete-configure
+                 (lambda _
+                   (delete-file "configure")))
+              `(replace 'configure
+                 ;; This old `configure' script doesn't support
+                 ;; variables passed as arguments. TODO: would
+                 ;; simply regenerating 'configure' work
+                 ;; well enough, even if compiling natively
+                 ;; on powerpc or aarch64?
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((out (assoc-ref outputs "out")))
+                     (setenv "CONFIG_SHELL" (which "bash"))
+                     (invoke "./configure"
+                             (string-append "--prefix=" out)
+                             ,@(if (string=? "powerpc64le-linux"
+                                             (%current-system))
+                                   '("--host=powerpc64le-unknown-linux-gnu")
+                                   '())
+                             ,@(if (string=? "aarch64-linux"
+                                             (%current-system))
+                                   '("--host=aarch64-unknown-linux-gnu")
+                                   '())))))))))
+    (native-inputs
+     (if (%current-target-system)
+         `(("autoconf" ,autoconf))
+         '()))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 35/36] cross-base: Fix cross-compiler for i686-linux-gnu.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (33 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 34/36] libelf: Use the cross-compiler " Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 36/36] meson: Support cross-compilation Maxime Devos
  2021-07-08 13:07   ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Mathieu Othacehe
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

GCC doesn't find libgcc_s.so anymore and looks in the wrong
location.  Fix this (well, more a work-around really).

* gnu/packages/cross-base.scm
  (cross-gcc-arguments)<#:configure-flags>:
  Add --with-toolexecdir, such that libstdc++ ends up in the right
  place. Add --with-slibdir such that libgcc_s.so end up in the right place.
  (cross-gcc-arguments)<#:phases>{move-shared-libraries}:
  New phase, moving libraries in the correct place.
  Delete .la files, libasan.so and libusan.so to prevent circular
  references. Likewise, fix a reference in libstdc++.so.VERSION-gdb.py.
---
 gnu/packages/cross-base.scm | 63 +++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 926b00ccdf..b037edcc24 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1)
@@ -169,9 +171,26 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                                 ))
 
                        ;; Install cross-built libraries such as libgcc_s.so in
-                       ;; the "lib" output.
+                       ;; the "lib" output. At least for version 8.4.0, GCC
+                       ;; will put libstdc++ in ${toolexecdir}/lib instead.
+                       ;; (A bug?) So set --with-toolexecdir as well.
+
                        ,@(if libc
-                             `((string-append "--with-toolexeclibdir="
+                             `((string-append "--with-toolexecdir="
+                                              (assoc-ref %outputs "lib"))
+                               (string-append "--with-toolexeclibdir="
+                                              (assoc-ref %outputs "lib")
+                                              "/" ,target "/lib"))
+                             '())
+                       ;; At least for GCC 8.0, libgcc_s.so and libstdc++.so
+                       ;; are not installed in the location specified in
+                       ;; --with-toolexeclibdir so GCC will not find it
+                       ;; when cross-compiling, say, GNU Hello.
+                       ;;
+                       ;; Work-around by specifying slibdir. This is not
+                       ;; sufficient, see move-shared-libraries below.
+                       ,@(if (and libc (version>=? (package-version xgcc) "8.0"))
+                             `((string-append "--with-slibdir="
                                               (assoc-ref %outputs "lib")
                                               "/" ,target "/lib"))
                              '())
@@ -193,7 +212,45 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                      ,flags))
             flags))
        ((#:phases phases)
-        `(cross-gcc-build-phases ,target ,phases))))))
+        (if (and libc (version>=? (package-version xgcc) "8.0"))
+            #~(modify-phases (cross-gcc-build-phases #$target #$phases)
+                (add-after 'install 'move-shared-libraries
+                  (lambda _
+                    (let* ((slib (format #f "~a/~a/lib/" #$output:lib #$target))
+                           (badlib (format #f "~a/~a/lib/" #$output #$target))
+                           (libs (map basename (find-files badlib #:fail-on-error? #t))))
+                      (for-each
+                       (lambda (lib)
+                         (let ((from (string-append badlib lib))
+                               (to   (string-append slib lib)))
+                           (when (file-exists? to)
+                             (error "~a was found twice, refusing to overwrite!"
+                                    lib))
+                           ;; The debugging script libstdc++.so.VERSION-gdb.py has
+                           ;; reference to #$output. Correct it.
+                           (when (string-suffix? "-gdb.py" lib)
+                             (substitute* from
+                               (("libdir = '(.*)'")
+                                (string-append "libdir = '" slib "'")))
+                             (system* "cat" from))
+                           ;; The .la files have references to BADLIB,
+                           ;; leading to cyclic references between
+                           ;; the outputs of the package. Remove them
+                           ;; and hope noone notices.
+                           ;;
+                           ;; Likewise, libasan.so.* and libubsan.so.*
+                           ;; have references to #$output.
+                           (if (or (string-suffix? ".la" lib)
+                                   (string-prefix? "libasan.so" lib)
+                                   (string-prefix? "libubsan.so" lib))
+                               (delete-file from)
+                               (rename-file from to))))
+                       libs)
+                      ;; If you have "cyclic references" problems,
+                      ;; uncomment this and use --keep-failed to figure
+                      ;; things out.
+                      (copy-recursively #$output:lib "out-test")))))
+            #~(cross-gcc-build-phases #$target #$phases)))))))
 
 (define (cross-gcc-patches xgcc target)
   "Return GCC patches needed for XGCC and TARGET."
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 36/36] meson: Support cross-compilation.
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (34 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 35/36] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
@ 2021-06-19 15:04   ` Maxime Devos
  2021-07-08 13:07   ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Mathieu Othacehe
  36 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-06-19 15:04 UTC (permalink / raw)
  To: 49025; +Cc: othacehe, Maxime Devos

For cross-compilation, meson needs to be passed a
‘cross file’ with information on the architecture,
CPU type, endianness and operating system, and the
name of the cross-compiler binaries.

The new module (guix build meson-configuration) has
some utilities for writing these cross files, used
by 'make-cross-file' in a G-exp.  The values for
the cross file are generated by 'make-machine-alist'
and 'make-binaries-alist'.

'make-machine-alist' and 'make-binaries-alist' live
on the host side, such that new architectures and operating
systems can be added without causing rebuilds for old
architectures.

Currently, only GNU/Hurd, GNU/Linux, MinGW, x86-32 and
x86-64 are supported by 'make-machine-alist'. For other
architectures, someone needs to figure out what to
use as ‘CPU type’ first.  Only i686-linux-gnu has been
tested.

This has been tested with:

$ ./pre-inst-env guix build glib --target=i686-linux-gnu

on a x86_64-linux system.  ‘If it compiles, it should work.’

* guix/build/meson-configuration.scm
  (configuration-port): New parameter.
  (write-section-header): New procedure.
  (write-assignment): New procedure.
  (write-assignments): New procedure.
* guix/build-system/meson.scm
  (target-hurd?): New predicate.
  (make-machine-alist): New procedure.
  (make-binaries-alist): New procedure.
  (make-cross-file): New procedure.
  (meson-cross-build): New procedure.
  (lower)[build-inputs]: Add standard cross packages when cross-compiling.
  Do not include regular 'inputs' when cross-compiling.
  (lower)[host-inputs]: Include 'inputs' when cross-compiling.
  (lower)[target-inputs]: Add cross packages when cross-compiling.
  (lower)[build]: Call 'meson-cross-build' instead of 'cross-build'
  when cross-compiling.
  (lower)[target]: Set it.
  (lower)[private-keywords]: Do not remove #:target when cross-compiling.
---
 Makefile.am                        |   1 +
 guix/build-system/meson.scm        | 197 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 +++++++++++
 3 files changed, 250 insertions(+), 19 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

diff --git a/Makefile.am b/Makefile.am
index f06b294f28..b9e77fd0b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -234,6 +234,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/java-utils.scm			\
   guix/build/lisp-utils.scm			\
+  guix/build/meson-configuration.scm		\
   guix/build/maven/java.scm			\
   guix/build/maven/plugin.scm			\
   guix/build/maven/pom.scm			\
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 5adc0f92c8..1f763af2aa 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (guix packages)
   #:use-module (ice-9 match)
   #:export (%meson-build-system-modules
-            meson-build-system))
+            meson-build-system
+            make-cross-file))
 
 ;; Commentary:
 ;;
@@ -40,6 +42,62 @@
 ;;
 ;; Code:
 
+(define (target-hurd? triplet)
+  (and (string-suffix? "-gnu" triplet)
+       (not (string-contains triplet "linux"))))
+
+(define (make-machine-alist triplet)
+  "Make an association list describing what should go into
+the ‘host_machine’ section of the cross file when cross-compiling
+for TRIPLET."
+  `((system . ,(cond ((target-hurd? triplet) "gnu")
+                     ((target-linux? triplet) "linux")
+                     ((target-mingw? triplet) "windows")
+                     (#t (error "meson: unknown operating system"))))
+    (cpu_family . ,(cond ((target-x86-32? triplet) "x86")
+                         ((target-x86-64? triplet) "x86_64")
+                         ((target-arm32? triplet) "arm")
+                         ((target-aarch64? triplet) "aarch64")
+                         ((target-powerpc? triplet)
+                          (if (target-64bit? triplet)
+                              "ppc64"
+                              "ppc"))
+                         (#t (error "meson: unknown architecture"))))
+    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
+                   (substring triplet 0 4))
+                  ((target-x86-64? triplet) "x86_64")
+                  (#t (error "meson: unknown CPU"))))
+    (endian . ,(cond ((string-prefix? "powerpc64le-" triplet) "little")
+                     ((string-prefix? "mips64el-" triplet) "little")
+                     ((target-x86-32? triplet) "little")
+                     ((target-x86-64? triplet) "little")
+                     (#t (error "meson: unknown architecture"))))))
+
+(define (make-binaries-alist triplet)
+  "Make an associatoin list describing what should go into
+the ‘binaries’ section of the cross file when cross-compiling for
+TRIPLET."
+  `((c . ,(cc-for-target triplet))
+    (cpp . ,(cxx-for-target triplet))
+    (pkgconfig . ,(pkg-config-for-target triplet))
+    (objcopy . ,(string-append triplet "-objcopy"))
+    (ar . ,(string-append triplet "-ar"))
+    (ld . ,(string-append triplet "-ld"))
+    (strip . ,(string-append triplet "-strip"))))
+
+(define (make-cross-file triplet)
+  (computed-file "cross-file"
+    (with-imported-modules '((guix build meson-configuration))
+      #~(begin
+          (use-modules (guix build meson-configuration))
+          (call-with-output-file #$output
+            (lambda (f)
+              (parameterize ((configuration-port f))
+                (write-section-header "host_machine")
+                (write-assignments '#$(make-machine-alist triplet))
+                (write-section-header "binaries")
+                (write-assignments '#$(make-binaries-alist triplet)))))))))
+
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
@@ -68,24 +126,34 @@
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    `(#:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
-
-  (and (not target) ;; TODO: add support for cross-compilation.
-       (bag
-         (name name)
-         (system system)
-         (build-inputs `(("meson" ,meson)
-                         ("ninja" ,ninja)
-                         ,@native-inputs
-                         ,@inputs
-                         ;; Keep the standard inputs of 'gnu-build-system'.
-                         ,@(standard-packages)))
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (outputs outputs)
-         (build meson-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:meson #:ninja #:inputs #:native-inputs #:outputs
+      ,@(if target
+            '()
+            '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (build-inputs `(("meson" ,meson)
+                    ("ninja" ,ninja)
+                    ,@native-inputs
+                    ,@(if target '() inputs)
+                    ;; Keep the standard inputs of 'gnu-build-system'.
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages)))
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target inputs '())))
+    ;; Keep the standard inputs of 'gnu-buid-system'.
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target meson-cross-build meson-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (meson-build name inputs
                       #:key
@@ -161,6 +229,97 @@ has a 'meson.build' file."
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (meson-cross-build name
+                            #:key
+                            target
+                            build-inputs host-inputs target-inputs
+                            guile source
+                            (outputs '("out"))
+                            (configure-flags ''())
+                            (search-paths '())
+                            (native-search-paths '())
+
+                            (build-type "debugoptimized")
+                            (tests? #f)
+                            (test-target "test")
+                            (glib-or-gtk? #f)
+                            (parallel-build? #t)
+                            (parallel-tests? #f)
+                            (validate-runpath? #t)
+                            (patch-shebangs? #t)
+                            (strip-binaries? #t)
+                            (strip-flags ''("--strip-debug"))
+                            (strip-directories ''("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                            (elf-directories ''("lib" "lib64" "libexec"
+                                                "bin" "sbin"))
+                            (phases '%standard-phases)
+                            (system (%current-system))
+                            (imported-modules %meson-build-system-modules)
+                            (modules '((guix build meson-build-system)
+                                       (guix build utils)))
+                            allowed-references
+                            disallowed-references)
+  "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that
+SOURCE has a 'meson.build' file."
+  (define cross-file
+    (make-cross-file target))
+  (define inputs
+    (if (null? target-inputs)
+        (input-tuples->gexp host-inputs)
+        #~(append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs))))
+  (define builder
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@(sexp->gexp modules))
+
+          (define build-phases
+            #$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
+                (if glib-or-gtk?
+                    phases
+                    #~(modify-phases #$phases
+                        (delete 'glib-or-gtk-compile-schemas)
+                        (delete 'glib-or-gtk-wrap)))))
+
+          ;; Do not use 'with-build-variables', as there should be
+          ;; no reason to use %build-inputs and friends.
+          (meson-build #:source #+source
+                       #:system #$system
+                       #:outputs #$(outputs->gexp outputs)
+                       #:inputs #$inputs
+                       #:native-inputs #+(input-tuples->gexp build-inputs)
+                       #:search-paths '#$(sexp->gexp
+                                          (map search-path-specification->sexp
+                                                     search-paths))
+                       #:native-search-paths '#$(sexp->gexp
+                                                 (map search-path-specification->sexp
+                                                      native-search-paths))
+                       #:phases build-phases
+                       #:configure-flags `("--cross-file" #+cross-file
+                                           ,@#$(sexp->gexp configure-flags))
+                       #:build-type #$build-type
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:parallel-build? #$parallel-build?
+                       #:parallel-tests? #$parallel-tests?
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$(sexp->gexp strip-flags)
+                       #:strip-directories #$(sexp->gexp strip-directories)
+                       #:elf-directories #$(sexp->gexp elf-directories)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define meson-build-system
   (build-system
     (name 'meson)
diff --git a/guix/build/meson-configuration.scm b/guix/build/meson-configuration.scm
new file mode 100644
index 0000000000..81b4eaa7e1
--- /dev/null
+++ b/guix/build/meson-configuration.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-configuration)
+  #:use-module (ice-9 match)
+  #:export (write-section-header write-assignment
+            write-assignments make-machine-alist
+            configuration-port))
+
+;; Commentary:
+;;
+;; Utilities for generating a ‘Cross build definition file’ for
+;; the Meson build system.  Configuration values are currently
+;; never escaped.  In practice this is unlikely to be a problem
+;; in the build environment.
+;;
+;; Code:
+
+(define configuration-port
+  (fluid->parameter (make-unbound-fluid)))
+
+(define (write-section-header section-name)
+  "Write a section header for section named SECTION-NAME
+to the configuration port."
+  (format (configuration-port) "[~a]~%" section-name))
+
+(define (write-assignment key value)
+  "Write an assignment of VALUE to KEY to the configuration
+port.  VALUE must be a string (without any special characters
+such as quotes), a boolean or an integer.  Lists are currently
+not supported"
+  (define port (configuration-port))
+  (match value
+    ((? string?)
+     (format port "~a = '~a'~%" key value))
+    ((? integer?)
+     (format port "~a = ~a~%" key value))
+    (#f
+     (format port "~a = true~%" key))
+    (#t
+     (format port "~a = false~%" key))))
+
+(define* (write-assignments alist)
+  "Write the assignments in ALIST, an association list,
+to the configuration port."
+  (for-each (match-lambda
+              ((key . value)
+               (write-assignment key value)))
+            alist))
+
+(define* (make-machine-alist #:key system cpu-family cpu endian)
+  "Make an association list for the [host_machine] section."
+  `((system . ,system)
+    (cpu-family . ,cpu-family)
+    (cpu . ,cpu)
+    (endian . ,endian)))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-07-03 15:47     ` Maxime Devos
  0 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-03 15:47 UTC (permalink / raw)
  To: 49025; +Cc: othacehe

[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]

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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
                     ` (35 preceding siblings ...)
  2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 36/36] meson: Support cross-compilation Maxime Devos
@ 2021-07-08 13:07   ` Mathieu Othacehe
  36 siblings, 0 replies; 175+ messages in thread
From: Mathieu Othacehe @ 2021-07-08 13:07 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025


Hello Maxime,

> This is the same as v1 (v2 and v3 are the same as v1 but the sending
> was messed up), but with merge conflicts resolved. Also, one
> patch of v1 is already on core-updates, so it is dropped here.

It seems that some patches of this series are a bit outdated since:

- %build-inputs have been re-introduced when cross-compiling with
   8a4830231871c578c80523e973ecd85f1f596ba6.

- Cross-compilation with GCC is in a much better shape since Ludo fix
  avalanche on core-updates.
  
Do you think you could send an updated series?

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
                   ` (4 preceding siblings ...)
  2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
@ 2021-07-11 11:47 ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate Maxime Devos
                     ` (19 more replies)
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
  6 siblings, 20 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

The following changes were made since the v4:

  * As %build-inputs has been re-introduced when cross-compiling,
    I have removed the patches replacing (assoc-ref %build-inputs ...)
    with G-exp machinery.  (Packages: net-base, libgcrypt, wrap-python3,
    openssl, readline, fontconfig, bash)

  * The cross-compilation fixes for libelf were simplified by always
    regenerating the 'configure' script and updating 'config.guess'
    and 'config.sub'.

  * I modified 'make-machine-alist' such that it recognises the
    'aarch64' architecture.  Meson also wants a 'CPU type', so
    I choosed 'armv8-a'.  Not sure if that's always correct,
    but ‘1.2 GNU Distribution’ notes:

    ‘Packages are currently available on the following platforms:
    [...]
    aarch64-linux: little-endian 64 ARMv8-A processors, [..]’

    so it should be good for supported targets in Guix at least.

  * I removed the usage of 'canonical-package' in the inputs of 'glib'.
    Apparently, canonical packages are not supposed to appear in the reference
    graph (<https://lists.gnu.org/archive/html/guix-devel/2020-06/msg00133.html>).

Maxime Devos (20):
  utils: Define target-linux? predicate.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpg-error: Fix cross-compilation error.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  libelf: Update configure script and config.guess and config.sub.
  meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |   5 +
 gnu/packages/base.scm              |   9 ++
 gnu/packages/elf.scm               |  44 ++++---
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  48 ++++---
 gnu/packages/python.scm            |   5 +-
 gnu/packages/tls.scm               | 136 +++++++++----------
 guix/build-system/meson.scm        | 201 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 ++++++++++
 guix/packages.scm                  |  29 +++++
 guix/utils.scm                     |  26 ++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 14 files changed, 561 insertions(+), 122 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

-- 
2.32.0





^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-12 12:35     ` Mathieu Othacehe
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 02/20] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
                     ` (18 subsequent siblings)
  19 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* guix/utils.scm (target-linux?): New predicate.
* tests/utils.scm
  ("target-linux?"): Test it.
  ("target-mingw?"): Also test ‘target-mingw?’.
---
 guix/utils.scm  |  6 ++++++
 tests/utils.scm | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19990ceb8a..4ff2602e23 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,6 +82,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -543,6 +545,10 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  (string-contains target "linux"))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25552..80a0e669a4 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,22 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map (compose ->bool target-linux?)
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map (compose ->bool target-mingw?)
+       '("i686-linux-gnu" "i686-pc-gnu"
+         "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 02/20] utils: Define a target-x86-32? and target-x86-64? predicate.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 03/20] packages: Define this-package-input and this-package-native-input Maxime Devos
                     ` (17 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
---
 guix/utils.scm  | 20 ++++++++++++++++++++
 tests/utils.scm | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 4ff2602e23..2256ea2ca6 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -84,6 +84,8 @@
             package-name->name+version
             target-linux?
             target-mingw?
+            target-x86-32?
+            target-x86-64?
             target-arm32?
             target-aarch64?
             target-arm?
@@ -553,6 +555,24 @@ a character other than '@'."
   (and target
        (string-suffix? "-mingw32" target)))
 
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+                                                (%current-system))))
+  "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+  ;; Intel also has a 16-bit architecture in the iN86 series, i286
+  ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+  ;; procedure is not named target-x86?.
+  (or (string-prefix? "i386-" target)
+      (string-prefix? "i486-" target)
+      (string-prefix? "i586-" target)
+      (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+                                                 (%current-system))))
+  "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+  (string-prefix? "x86_64-" target))
+
 (define* (target-arm32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index 80a0e669a4..92439b5587 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
        '("i686-linux-gnu" "i686-pc-gnu"
          "i686-w64-mingw32")))
 
+(test-equal "target-x86-32?"
+  '(#f #f #f #t #t #t #t #f)
+  ;; These are (according to Wikipedia) two RISC architectures
+  ;; by Intel and presumably not compatible with the x86-32 series.
+  (map target-x86-32?
+       '("i860-gnu" "i960-gnu"
+         ;; This is a 16-bit architecture
+         "i286-gnu"
+         ;; These are part of the x86-32 series.
+         "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+         ;; Maybe this one will exist some day, but not yet.
+         "i786-gnu")))
+
+(test-equal "target-x86-64?"
+  '(#t #f #f #f)
+  (map target-x86-64?
+       `("x86_64-linux-gnu" "i386-linux-gnu"
+         ;; Just because it includes "64" doesn't make it 64-bit.
+         "aarch64-linux-gnu"
+         ;; Note that (expt 2 109) in decimal notation starts with 64.
+         ;; However, it isn't 32-bit.
+         ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 03/20] packages: Define this-package-input and this-package-native-input.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 02/20] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 04/20] net-base: Don't cross-compile Maxime Devos
                     ` (16 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index 3ba61b42c9..56300e6b61 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47fc34d3ce..9814015a05 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1866,6 +1867,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 04/20] net-base: Don't cross-compile.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (2 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 03/20] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 05/20] tzdata: Don't bother with cross-compiling Maxime Devos
                     ` (15 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

net-base is pure data, so cross-compiling is pointless.

* gnu/packages/admin.scm
  (net-base)[arguments]<#:target>: Set to #f.
  (net-base)[arguments]<#:allowed-references>: Disallow all
  references.
---
 gnu/packages/admin.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index aab62331a3..394575ffec 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -937,6 +937,11 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
+       ;; This package consists solely of architecture-independent
+       ;; tables. Cross-compilation is pointless! Make sure we'll
+       ;; always get the same derivation.
+       #:target #f
+       #:allowed-references ()
        #:builder (begin
                    (use-modules (guix build utils)
                                 (srfi srfi-26))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 05/20] tzdata: Don't bother with cross-compiling.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (3 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 04/20] net-base: Don't cross-compile Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 06/20] libgpg-error: Remove trailing #f from phases Maxime Devos
                     ` (14 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

The time zone database is architecture-independent,
so trying to cross-compile it is pointless!

* gnu/packages/base.scm
  (tzdata)[arguments]<#:target>: Set to #f.
  (tzdata)[allowed-references]: Only include the "out" output itself,
  to make sure no (architecture-dependent) binaries are installed.
---
 gnu/packages/base.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 565d2ccab8..88e4ec09a6 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1257,6 +1258,14 @@ command.")
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f
+       ;; This consists purely of (architecture-independent) data,
+       ;; so ‘cross-compilation’ is pointless here!
+       ;; (The binaries zic, dump, and tzselect are deleted in the post-install
+       ;; phase.)
+       #:target #f
+       ;; share/zoneinfo/posix is a symlink to share/zoneinfo,
+       ;; so include the package itself in #:allowed-references.
+       #:allowed-references ("out")
        #:make-flags (let ((out (assoc-ref %outputs "out"))
                           (tmp (getenv "TMPDIR")))
                       (list (string-append "TOPDIR=" out)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 06/20] libgpg-error: Remove trailing #f from phases.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (4 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 05/20] tzdata: Don't bother with cross-compiling Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 07/20] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
                     ` (13 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

These aren't required anymore.

* gnu/packages/gnupg.scm (libgpgerror)[arguments]{cross-symlinks}:
  Remove trailing #f.
---
 gnu/packages/gnupg.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index a6ec75765c..5c0d03927e 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -114,8 +114,7 @@
                            (string-append x "-unknown-linux-gnu")))))
                    (symlink
                     (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))
-                 #t))))
+                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 07/20] libgpg-error: Prevent silent miscompilation some systems.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (5 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 06/20] libgpg-error: Remove trailing #f from phases Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 08/20] libgpg-error: Fix cross-compilation error Maxime Devos
                     ` (12 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* gnu/packages/gpg.scm
  (libgpgerror)[arguments]<#:phases>{cross-symlinks}: Only
  link to src/syscfg/lock-obj-pub.linux-gnu.h if the package
  is being compiled for a Linux target. Do not link either
  if the architecture is unknown, as the headers vary with
  the architecture.
---
 gnu/packages/gnupg.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 5c0d03927e..1a7c682ad6 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
 (define-public libgpg-error
@@ -94,27 +96,37 @@
     (build-system gnu-build-system)
     (arguments
      (if (%current-target-system)
-         `(#:modules ((ice-9 match)
-                      (guix build gnu-build-system)
+         `(#:modules ((guix build gnu-build-system)
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
-             ;; file. See Cross-Compiling section at:
+             ;; file if required. Note that these platform files depend on
+             ;; both the operating system and architecture!
+             ;;
+             ;; See Cross-Compiling section at:
              ;; https://github.com/gpg/libgpg-error/blob/master/README
              (add-after 'unpack 'cross-symlinks
-               (lambda* (#:key target inputs #:allow-other-keys)
-                 (let ((triplet
-                        (match (string-take target
-                                            (string-index target #\-))
-                          ("armhf" "arm-unknown-linux-gnueabi")
-                          ("mips64el" "mips-unknown-linux-gnu")
-                          (x
-                           (string-append x "-unknown-linux-gnu")))))
-                   (symlink
-                    (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
+               (lambda _
+                 (define (link triplet source)
+                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                            (string-append "src/syscfg/lock-obj-pub."
+                                           source ".h")))
+                 ,(let* ((target (%current-target-system))
+                         (architecture
+                          (string-take target (string-index target #\-))))
+                    (cond ((target-linux? target)
+                           (match architecture
+                             ("armhf"
+                              `(link "arm-unknown-linux-gnueabi" "linux-gnu"))
+                             ("mips64el"
+                              `(link "mips-unknown-linux-gnu" "linux-gnu"))
+                             ;; Don't always link to the "linux-gnu"
+                             ;; configuration, as this is not correct for
+                             ;; all architectures.
+                             (_ #t)))
+                          (#t #t)))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 08/20] libgpg-error: Fix cross-compilation error.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (6 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 07/20] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 09/20] python: Fix reference to input when cross-compiling Maxime Devos
                     ` (11 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

TODO: inform upstream about the cross-compilation error.

* gnu/packages/gnupg.scm
  (libgpg-error)[arguments]{fix-gen-lock-obj.sh}: Prevent generated
  header files from being sprinkled with ‘\c’.
---
 gnu/packages/gnupg.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 1a7c682ad6..bb6fa4678b 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -100,6 +100,13 @@
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
+             ;; If this is left out, some generated header
+             ;; files will be sprinkled with ‘\c’, which
+             ;; the compiler won't like.
+             (add-after 'unpack 'fix-gen-lock-obj.sh
+               (lambda _
+                 (substitute* "src/gen-lock-obj.sh"
+                   (("if test -n `echo -n`") "if ! test -n `echo -n`"))))
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
              ;; file if required. Note that these platform files depend on
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 09/20] python: Fix reference to input when cross-compiling.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (7 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 08/20] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 10/20] openssl: Remove trailing #t from phases Maxime Devos
                     ` (10 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

"sitecustomize.py" is a native input, so look it up
in 'native-inputs', not 'inputs'.

* gnu/packages/python.scm (customize-site): Look up "sizecustomize.py"
  in 'native-inputs', not 'inputs'.
---
 gnu/packages/python.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 227c612a68..ef47e79632 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -110,13 +110,14 @@
 
 (define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
-  `(lambda* (#:key inputs outputs #:allow-other-keys)
+  `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
-            (sitecustomize.py (assoc-ref inputs "sitecustomize.py"))
+            (sitecustomize.py (assoc-ref (or native-inputs inputs)
+                                         "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 10/20] openssl: Remove trailing #t from phases.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (8 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 09/20] python: Fix reference to input when cross-compiling Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 11/20] openssl: Make the #:phases argument a G-expression Maxime Devos
                     ` (9 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Delete trailing #t.
---
 gnu/packages/tls.scm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 297e16dd70..8a8fcb59fd 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -364,8 +364,7 @@ required structures.")
                            ((string-prefix? "powerpc64" target)
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
-                            "linux-ppc")))
-                 #t)))
+                            "linux-ppc"))))))
            '())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
@@ -404,8 +403,7 @@ required structures.")
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
-                        (find-files lib "\\.a$"))
-              #t)))
+                        (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda* (#:key outputs #:allow-other-keys)
                ;; Move man3 pages and full HTML documentation to "doc".
@@ -418,8 +416,7 @@ required structures.")
                  (copy-recursively man3 man-target)
                  (delete-file-recursively man3)
                  (copy-recursively html html-target)
-                 (delete-file-recursively html)
-                 #t)))
+                 (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
          (lambda* (#:key outputs #:allow-other-keys)
@@ -428,8 +425,7 @@ required structures.")
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
                                                      ,(package-version this-package)
-                                                     "/misc"))
-             #t))))))
+                                                     "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 11/20] openssl: Make the #:phases argument a G-expression.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (9 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 10/20] openssl: Remove trailing #t from phases Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 12/20] openssl: Use G-exp machinery for referring to outputs Maxime Devos
                     ` (8 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

This allows using this-package-native-input later.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Make this a G-expression.
  (openssl-1.0)[arguments]<#:phases>: Likewise.
---
 gnu/packages/tls.scm | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 8a8fcb59fd..0024709a96 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -40,6 +40,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -339,9 +340,10 @@ required structures.")
       ;; so we explicitly disallow it here.
       #:disallowed-references ,(list (canonical-package perl))
       #:phases
+      ,#~
       (modify-phases %standard-phases
-       ,@(if (%current-target-system)
-           '((add-before
+       #$@(if (%current-target-system)
+          #~((add-before
                'configure 'set-cross-compile
                (lambda* (#:key target outputs #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
@@ -365,7 +367,7 @@ required structures.")
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
                             "linux-ppc"))))))
-           '())
+             #~())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
@@ -375,9 +377,9 @@ required structures.")
                 (("/usr/bin/env")
                  (string-append (assoc-ref %build-inputs "coreutils")
                                 "/bin/env")))
-              (invoke ,@(if (%current-target-system)
-                          '("./Configure")
-                          '("./config"))
+              (invoke #$@(if (%current-target-system)
+                             #~("./Configure")
+                             #~("./config"))
                       "shared"       ;build shared libraries
                       "--libdir=lib"
 
@@ -386,13 +388,13 @@ required structures.")
                       ;; conventional.
                       (string-append "--openssldir=" out
                                      "/share/openssl-"
-                                     ,(package-version this-package))
+                                     #$(package-version this-package))
 
                       (string-append "--prefix=" out)
                       (string-append "-Wl,-rpath," lib)
-                      ,@(if (%current-target-system)
-                          '((getenv "CONFIGURE_TARGET_ARCH"))
-                          '())))))
+                      #$@(if (%current-target-system)
+                             #~((getenv "CONFIGURE_TARGET_ARCH"))
+                             #~())))))
         (add-after 'install 'move-static-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Move static libraries to the "static" output.
@@ -424,7 +426,7 @@ required structures.")
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
-                                                     ,(package-version this-package)
+                                                     #$(package-version this-package)
                                                      "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
@@ -469,7 +471,7 @@ required structures.")
        ;; Parallel build is not supported in 1.0.x.
        ((#:parallel-build? _ #f) #f)
        ((#:phases phases)
-        `(modify-phases ,phases
+       #~(modify-phases #$phases
            (add-before 'patch-source-shebangs 'patch-tests
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
@@ -492,9 +494,9 @@ required structures.")
 	     ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
 	     (lambda* (#:key outputs #:allow-other-keys)
 	       (let ((out (assoc-ref outputs "out")))
-		 (invoke ,@(if (%current-target-system)
-			       '("./Configure")
-			       '("./config"))
+		 (invoke #$@(if (%current-target-system)
+			        #~("./Configure")
+			        #~("./config"))
 			 "shared"                 ;build shared libraries
 			 "--libdir=lib"
 
@@ -502,12 +504,12 @@ required structures.")
 			 ;; PREFIX/ssl.  Change that to something more
 			 ;; conventional.
 			 (string-append "--openssldir=" out
-					"/share/openssl-" ,version)
+					"/share/openssl-" #$version)
 
 			 (string-append "--prefix=" out)
-			 ,@(if (%current-target-system)
-			       '((getenv "CONFIGURE_TARGET_ARCH"))
-			       '())))))
+			 #$@(if (%current-target-system)
+			        '((getenv "CONFIGURE_TARGET_ARCH"))
+			        '())))))
         (delete 'move-extra-documentation)
         (add-after 'install 'move-man3-pages
           (lambda* (#:key outputs #:allow-other-keys)
@@ -532,7 +534,7 @@ required structures.")
                ;; scripts.  Remove them to avoid retaining a reference on Perl.
                (let ((out (assoc-ref outputs "out")))
                  (delete-file-recursively (string-append out "/share/openssl-"
-                                                         ,version "/misc"))
+                                                         #$version "/misc"))
                  #t)))))))))
 
 (define-public libressl
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 12/20] openssl: Use G-exp machinery for referring to outputs.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (10 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 11/20] openssl: Make the #:phases argument a G-expression Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 13/20] openssl: Move documentation instead of copying and deleting it Maxime Devos
                     ` (7 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

This doesn't fix anything broken, just for simplifying
the code a little while we're rebuilding the world anyway.
IMHO this makes the code a little more readable.

* gnu/packages/tls.scm (openssl)[arguments]<#:phases>: Don't refer
  to the association list 'outputs', use #$output, #$output:doc
  and #$output:static instead.
---
 gnu/packages/tls.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 0024709a96..fd4a8b07b2 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Solene Rapenne <solene@perso.pw>
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -345,7 +346,7 @@ required structures.")
        #$@(if (%current-target-system)
           #~((add-before
                'configure 'set-cross-compile
-               (lambda* (#:key target outputs #:allow-other-keys)
+               (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
                          (cond
@@ -369,8 +370,8 @@ required structures.")
                             "linux-ppc"))))))
              #~())
         (replace 'configure
-          (lambda* (#:key outputs #:allow-other-keys)
-            (let* ((out (assoc-ref outputs "out"))
+          (lambda _
+            (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
               (substitute* "config"
@@ -396,23 +397,23 @@ required structures.")
                              #~((getenv "CONFIGURE_TARGET_ARCH"))
                              #~())))))
         (add-after 'install 'move-static-libraries
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
             ;; Move static libraries to the "static" output.
-            (let* ((out    (assoc-ref outputs "out"))
+            (let* ((out    #$output)
                    (lib    (string-append out "/lib"))
-                   (static (assoc-ref outputs "static"))
+                   (static #$output:static)
                    (slib   (string-append static "/lib")))
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
                ;; Move man3 pages and full HTML documentation to "doc".
-               (let* ((out    (assoc-ref outputs "out"))
+               (let* ((out    #$output)
                       (man3   (string-append out "/share/man/man3"))
                       (html (string-append out "/share/doc/openssl"))
-                      (doc    (assoc-ref outputs "doc"))
+                      (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
                  (copy-recursively man3 man-target)
@@ -421,13 +422,12 @@ required structures.")
                  (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
-         (lambda* (#:key outputs #:allow-other-keys)
+         (lambda _
            ;; The 'misc' directory contains random undocumented shell and Perl
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
-           (let ((out (assoc-ref outputs "out")))
-             (delete-file-recursively (string-append out "/share/openssl-"
-                                                     #$(package-version this-package)
-                                                     "/misc"))))))))
+           (delete-file-recursively (string-append #$output "/share/openssl-"
+                                                   #$(package-version this-package)
+                                                   "/misc")))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 13/20] openssl: Move documentation instead of copying and deleting it.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (11 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 12/20] openssl: Use G-exp machinery for referring to outputs Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 14/20] openssl: Move all man pages to separate output, not only man3 Maxime Devos
                     ` (6 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Use
  'rename-file' instead of 'copy-recursively' and
  'delete-file-recursively'.
---
 gnu/packages/tls.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index fd4a8b07b2..fcecc6ba41 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -416,10 +416,10 @@ required structures.")
                       (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (copy-recursively man3 man-target)
-                 (delete-file-recursively man3)
-                 (copy-recursively html html-target)
-                 (delete-file-recursively html))))
+                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname html-target))
+                 (rename-file man3 man-target)
+                 (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
          (lambda _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 14/20] openssl: Move all man pages to separate output, not only man3.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (12 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 13/20] openssl: Move documentation instead of copying and deleting it Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 15/20] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
                     ` (5 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

There does not seem to be any reason to only move man3 pages.
So, move all man pages to a separate output for documentation.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Move
  all man pages, not only man3.
---
 gnu/packages/tls.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index fcecc6ba41..6cebc1d6ed 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -409,16 +409,16 @@ required structures.")
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda _
-               ;; Move man3 pages and full HTML documentation to "doc".
+               ;; Move man pages and full HTML documentation to "doc".
                (let* ((out    #$output)
-                      (man3   (string-append out "/share/man/man3"))
-                      (html (string-append out "/share/doc/openssl"))
+                      (man    (string-append out "/share/man"))
+                      (html   (string-append out "/share/doc/openssl"))
                       (doc    #$output:doc)
-                      (man-target (string-append doc "/share/man/man3"))
+                      (man-target (string-append doc "/share/man"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname man-target))
                  (mkdir-p (dirname html-target))
-                 (rename-file man3 man-target)
+                 (rename-file man man-target)
                  (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 15/20] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (13 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 14/20] openssl: Move all man pages to separate output, not only man3 Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 16/20] glib: Use a correct python in scripts when cross-compiling Maxime Devos
                     ` (4 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

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(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 6cebc1d6ed..8c7bba0b6e 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -311,6 +311,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")
@@ -349,25 +374,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 _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 16/20] glib: Use a correct python in scripts when cross-compiling.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (14 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 15/20] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 17/20] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
                     ` (3 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

During the build, a native python should be used as these
scripts will be invoked during the build, but when installed,
they should be a python for the system we're compiling for.

* gnu/packages/glib.scm
  (glib)[arguments]<#:phases>{patch-python-references}: Look up
  "python" in 'native-inputs', not 'inputs'.
  (glib)[inputs]{python,python-wrapper,bash-minimal}: New inputs.
---
 gnu/packages/glib.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index f0be2ddaa4..99f5c5d450 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -223,14 +224,19 @@ shared NFS home directories.")
              #t))
          ;; Python references are not being patched in patch-phase of build,
          ;; despite using python-wrapper as input. So we patch them manually.
+         ;;
+         ;; These python scripts are both used during build and installed,
+         ;; so at first, use a python from 'native-inputs', not 'inputs'. When
+         ;; cross-compiling, the 'patch-shebangs' phase will replace
+         ;; the native python with a python from 'inputs'.
          (add-after 'unpack 'patch-python-references
-           (lambda* (#:key inputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
              (substitute* '("gio/gdbus-2.0/codegen/gdbus-codegen.in"
                             "glib/gtester-report.in"
                             "gobject/glib-genmarshal.in"
                             "gobject/glib-mkenums.in")
                (("@PYTHON@")
-                (string-append (assoc-ref inputs "python")
+                (string-append (assoc-ref (or native-inputs inputs) "python")
                                "/bin/python"
                                ,(version-major+minor
                                  (package-version python)))))
@@ -293,6 +299,13 @@ shared NFS home directories.")
        ("xsltproc" ,libxslt)))
     (inputs
      `(("bash-completion" ,bash-completion)
+       ;; "python", "python-wrapper" and "bash-minimal"
+       ;; are for the 'patch-shebangs' phase, to make
+       ;; sure the installed scripts end up with a correct shebang
+       ;; when cross-compiling.
+       ("python" ,python)
+       ("python-wrapper" ,python-wrapper)
+       ("bash-minimal" ,bash-minimal)
        ("dbus" ,dbus)
        ("libelf" ,libelf)))
     (propagated-inputs
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 17/20] glib: Verify the cross-compiled python is used in installed scripts.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (15 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 16/20] glib: Use a correct python in scripts when cross-compiling Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 18/20] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
                     ` (2 subsequent siblings)
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

* gnu/packages/glib.scm (glib)[arguments]<#:disallowed-references>:
  Disallow the native python when cross-compiling.
---
 gnu/packages/glib.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 99f5c5d450..e4ebed7e2c 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -77,6 +77,8 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-26)
   #:use-module ((srfi srfi-1) #:hide (zip))
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
@@ -200,7 +202,15 @@ shared NFS home directories.")
                "static"                 ;static libraries
                "bin"))                  ;executables; depends on Python
     (arguments
-     `(#:disallowed-references (,tzdata-for-tests)
+     `(#:disallowed-references
+       (,tzdata-for-tests
+        ;; Verify glib-mkenums, gtester, ... use the cross-compiled
+        ;; python.
+        ,@(if (%current-target-system)
+              (map (cut gexp-input <> #:native? #t)
+                   `(,(this-package-native-input "python")
+                     ,(this-package-native-input "python-wrapper")))
+              '()))
        #:configure-flags '("--default-library=both"
                            "-Dman=true"
                            "-Dselinux=disabled")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 18/20] glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (16 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 17/20] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 19/20] libelf: Update configure script and config.guess and config.sub Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation Maxime Devos
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

Otherwise, "tzdata" won't be found when cross-compiling
and string-append will complain about types. Alternatively,
"tzdata" could be moved from 'native-inputs' to 'inputs'.

* gnu/packages/glib.scm (glib)[arguments]<#:phases>{pre-check}:
  Look up "tzdata" in 'native-inputs', not 'inputs'.
---
 gnu/packages/glib.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index e4ebed7e2c..01683df8c5 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -252,10 +252,11 @@ shared NFS home directories.")
                                  (package-version python)))))
              #t))
          (add-before 'check 'pre-check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              ;; For tests/gdatetime.c.
              (setenv "TZDIR"
-                     (string-append (assoc-ref inputs "tzdata")
+                     (string-append (assoc-ref (or native-inputs inputs)
+                                               "tzdata")
                                     "/share/zoneinfo"))
              ;; Some tests want write access there.
              (setenv "HOME" (getcwd))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 19/20] libelf: Update configure script and config.guess and config.sub.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (17 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 18/20] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation Maxime Devos
  19 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

The current configure script is too old to find the cross-compiler
and support variables passed as arguments. Also, config.guess and
config.sub are too old to recognise powerpc64 and aarch64.  Solve
this by regenerating the 'configure' script and replacing
'config.guess' and 'config.sub'.

* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{configure}: Remove phase.
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script and replace 'config.guess' and 'config.sub'.
---
 gnu/packages/elf.scm | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..2bc1d00048 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,32 @@ static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ;; This old 'configure' script doesn't support cross-compilation
+         ;; well.  I.e., it fails to find the cross-compiler.  Also,
+         ;; the old `configure' script doesn't support variables passed as
+         ;; arguments.  A third problem is that config.sub is too old to
+         ;; recognise aarch64 and powerpc64le.
+         ;;
+         ;; Solve this by regenerating the configure script and letting
+         ;; autoreconf update 'config.sub'.  While 'config.sub' is updated
+         ;; anyway, update 'config.guess' as well.
+         (add-before 'bootstrap 'delete-configure
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
+             (delete-file "configure")
+             (delete-file "config.sub")
+             (delete-file "config.guess")
+             (for-each (lambda (file)
+                         (install-file
+                          (string-append
+                           (assoc-ref (or native-inputs inputs) "automake")
+                           "/share/automake-"
+                           ,(version-major+minor (package-version automake))
+                           "/" file) "."))
+                       '("config.sub" "config.guess")))))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ;; For up-to-date 'config.guess' and 'config.sub'
+       ("automake" ,automake)))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation.
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
                     ` (18 preceding siblings ...)
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 19/20] libelf: Update configure script and config.guess and config.sub Maxime Devos
@ 2021-07-11 11:47   ` Maxime Devos
  2021-07-12 12:42     ` Mathieu Othacehe
  19 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-11 11:47 UTC (permalink / raw)
  To: 49025; +Cc: Maxime Devos

For cross-compilation, meson needs to be passed a
‘cross file’ with information on the architecture,
CPU type, endianness and operating system, and the
name of the cross-compiler binaries.

The new module (guix build meson-configuration) has
some utilities for writing these cross files, used
by 'make-cross-file' in a G-exp.  The values for
the cross file are generated by 'make-machine-alist'
and 'make-binaries-alist'.

'make-machine-alist' and 'make-binaries-alist' live
on the host side, such that new architectures and operating
systems can be added without causing rebuilds for old
architectures.

Currently, only GNU/Hurd, GNU/Linux, MinGW, x86-32 and
x86-64 are supported by 'make-machine-alist'. For other
architectures, someone needs to figure out what to
use as ‘CPU type’ first.  Only i686-linux-gnu and
aarch64-linux-gnu have been tested.  The first target
is only tested in a previous version of this patch
series.

This has been tested with:

$ ./pre-inst-env guix build glib --target=aarch64-linux-gnu

on a x86_64-linux system.  ‘If it compiles, it should work.’

* guix/build/meson-configuration.scm
  (configuration-port): New parameter.
  (write-section-header): New procedure.
  (write-assignment): New procedure.
  (write-assignments): New procedure.
* guix/build-system/meson.scm
  (target-hurd?): New predicate.
  (make-machine-alist): New procedure.
  (make-binaries-alist): New procedure.
  (make-cross-file): New procedure.
  (meson-cross-build): New procedure.
  (lower)[build-inputs]: Add standard cross packages when cross-compiling.
  Do not include regular 'inputs' when cross-compiling.
  (lower)[host-inputs]: Include 'inputs' when cross-compiling.
  (lower)[target-inputs]: Add cross packages when cross-compiling.
  (lower)[build]: Call 'meson-cross-build' instead of 'cross-build'
  when cross-compiling.
  (lower)[target]: Set it.
  (lower)[private-keywords]: Do not remove #:target when cross-compiling.
---
 Makefile.am                        |   1 +
 guix/build-system/meson.scm        | 201 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 ++++++++++
 3 files changed, 254 insertions(+), 19 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

diff --git a/Makefile.am b/Makefile.am
index 05f013e3c2..6c17ab8492 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -234,6 +234,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/java-utils.scm			\
   guix/build/lisp-utils.scm			\
+  guix/build/meson-configuration.scm		\
   guix/build/maven/java.scm			\
   guix/build/maven/plugin.scm			\
   guix/build/maven/pom.scm			\
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 5adc0f92c8..55311f85f0 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (guix packages)
   #:use-module (ice-9 match)
   #:export (%meson-build-system-modules
-            meson-build-system))
+            meson-build-system
+            make-cross-file))
 
 ;; Commentary:
 ;;
@@ -40,6 +42,66 @@
 ;;
 ;; Code:
 
+(define (target-hurd? triplet)
+  (and (string-suffix? "-gnu" triplet)
+       (not (string-contains triplet "linux"))))
+
+(define (make-machine-alist triplet)
+  "Make an association list describing what should go into
+the ‘host_machine’ section of the cross file when cross-compiling
+for TRIPLET."
+  `((system . ,(cond ((target-hurd? triplet) "gnu")
+                     ((target-linux? triplet) "linux")
+                     ((target-mingw? triplet) "windows")
+                     (#t (error "meson: unknown operating system"))))
+    (cpu_family . ,(cond ((target-x86-32? triplet) "x86")
+                         ((target-x86-64? triplet) "x86_64")
+                         ((target-arm32? triplet) "arm")
+                         ((target-aarch64? triplet) "aarch64")
+                         ((target-powerpc? triplet)
+                          (if (target-64bit? triplet)
+                              "ppc64"
+                              "ppc"))
+                         (#t (error "meson: unknown architecture"))))
+    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
+                   (substring triplet 0 4))
+                  ((target-x86-64? triplet) "x86_64")
+                  ((target-aarch64? triplet) "armv8-a")
+                  (#t (error "meson: unknown CPU"))))
+    (endian . ,(cond ((string-prefix? "powerpc64le-" triplet) "little")
+                     ((string-prefix? "mips64el-" triplet) "little")
+                     ((target-x86-32? triplet) "little")
+                     ((target-x86-64? triplet) "little")
+                     ;; At least in Guix.  Aarch64 has a big-endian
+                     ;; mode as well.
+                     ((target-aarch64? triplet) "little")
+                     (#t (error "meson: unknown architecture"))))))
+
+(define (make-binaries-alist triplet)
+  "Make an associatoin list describing what should go into
+the ‘binaries’ section of the cross file when cross-compiling for
+TRIPLET."
+  `((c . ,(cc-for-target triplet))
+    (cpp . ,(cxx-for-target triplet))
+    (pkgconfig . ,(pkg-config-for-target triplet))
+    (objcopy . ,(string-append triplet "-objcopy"))
+    (ar . ,(string-append triplet "-ar"))
+    (ld . ,(string-append triplet "-ld"))
+    (strip . ,(string-append triplet "-strip"))))
+
+(define (make-cross-file triplet)
+  (computed-file "cross-file"
+    (with-imported-modules '((guix build meson-configuration))
+      #~(begin
+          (use-modules (guix build meson-configuration))
+          (call-with-output-file #$output
+            (lambda (f)
+              (parameterize ((configuration-port f))
+                (write-section-header "host_machine")
+                (write-assignments '#$(make-machine-alist triplet))
+                (write-section-header "binaries")
+                (write-assignments '#$(make-binaries-alist triplet)))))))))
+
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
@@ -68,24 +130,34 @@
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    `(#:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
-
-  (and (not target) ;; TODO: add support for cross-compilation.
-       (bag
-         (name name)
-         (system system)
-         (build-inputs `(("meson" ,meson)
-                         ("ninja" ,ninja)
-                         ,@native-inputs
-                         ,@inputs
-                         ;; Keep the standard inputs of 'gnu-build-system'.
-                         ,@(standard-packages)))
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (outputs outputs)
-         (build meson-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:meson #:ninja #:inputs #:native-inputs #:outputs
+      ,@(if target
+            '()
+            '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (build-inputs `(("meson" ,meson)
+                    ("ninja" ,ninja)
+                    ,@native-inputs
+                    ,@(if target '() inputs)
+                    ;; Keep the standard inputs of 'gnu-build-system'.
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages)))
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target inputs '())))
+    ;; Keep the standard inputs of 'gnu-buid-system'.
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target meson-cross-build meson-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (meson-build name inputs
                       #:key
@@ -161,6 +233,97 @@ has a 'meson.build' file."
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (meson-cross-build name
+                            #:key
+                            target
+                            build-inputs host-inputs target-inputs
+                            guile source
+                            (outputs '("out"))
+                            (configure-flags ''())
+                            (search-paths '())
+                            (native-search-paths '())
+
+                            (build-type "debugoptimized")
+                            (tests? #f)
+                            (test-target "test")
+                            (glib-or-gtk? #f)
+                            (parallel-build? #t)
+                            (parallel-tests? #f)
+                            (validate-runpath? #t)
+                            (patch-shebangs? #t)
+                            (strip-binaries? #t)
+                            (strip-flags ''("--strip-debug"))
+                            (strip-directories ''("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                            (elf-directories ''("lib" "lib64" "libexec"
+                                                "bin" "sbin"))
+                            (phases '%standard-phases)
+                            (system (%current-system))
+                            (imported-modules %meson-build-system-modules)
+                            (modules '((guix build meson-build-system)
+                                       (guix build utils)))
+                            allowed-references
+                            disallowed-references)
+  "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that
+SOURCE has a 'meson.build' file."
+  (define cross-file
+    (make-cross-file target))
+  (define inputs
+    (if (null? target-inputs)
+        (input-tuples->gexp host-inputs)
+        #~(append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs))))
+  (define builder
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@(sexp->gexp modules))
+
+          (define build-phases
+            #$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
+                (if glib-or-gtk?
+                    phases
+                    #~(modify-phases #$phases
+                        (delete 'glib-or-gtk-compile-schemas)
+                        (delete 'glib-or-gtk-wrap)))))
+
+          ;; Do not use 'with-build-variables', as there should be
+          ;; no reason to use %build-inputs and friends.
+          (meson-build #:source #+source
+                       #:system #$system
+                       #:outputs #$(outputs->gexp outputs)
+                       #:inputs #$inputs
+                       #:native-inputs #+(input-tuples->gexp build-inputs)
+                       #:search-paths '#$(sexp->gexp
+                                          (map search-path-specification->sexp
+                                                     search-paths))
+                       #:native-search-paths '#$(sexp->gexp
+                                                 (map search-path-specification->sexp
+                                                      native-search-paths))
+                       #:phases build-phases
+                       #:configure-flags `("--cross-file" #+cross-file
+                                           ,@#$(sexp->gexp configure-flags))
+                       #:build-type #$build-type
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:parallel-build? #$parallel-build?
+                       #:parallel-tests? #$parallel-tests?
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$(sexp->gexp strip-flags)
+                       #:strip-directories #$(sexp->gexp strip-directories)
+                       #:elf-directories #$(sexp->gexp elf-directories)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define meson-build-system
   (build-system
     (name 'meson)
diff --git a/guix/build/meson-configuration.scm b/guix/build/meson-configuration.scm
new file mode 100644
index 0000000000..81b4eaa7e1
--- /dev/null
+++ b/guix/build/meson-configuration.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-configuration)
+  #:use-module (ice-9 match)
+  #:export (write-section-header write-assignment
+            write-assignments make-machine-alist
+            configuration-port))
+
+;; Commentary:
+;;
+;; Utilities for generating a ‘Cross build definition file’ for
+;; the Meson build system.  Configuration values are currently
+;; never escaped.  In practice this is unlikely to be a problem
+;; in the build environment.
+;;
+;; Code:
+
+(define configuration-port
+  (fluid->parameter (make-unbound-fluid)))
+
+(define (write-section-header section-name)
+  "Write a section header for section named SECTION-NAME
+to the configuration port."
+  (format (configuration-port) "[~a]~%" section-name))
+
+(define (write-assignment key value)
+  "Write an assignment of VALUE to KEY to the configuration
+port.  VALUE must be a string (without any special characters
+such as quotes), a boolean or an integer.  Lists are currently
+not supported"
+  (define port (configuration-port))
+  (match value
+    ((? string?)
+     (format port "~a = '~a'~%" key value))
+    ((? integer?)
+     (format port "~a = ~a~%" key value))
+    (#f
+     (format port "~a = true~%" key))
+    (#t
+     (format port "~a = false~%" key))))
+
+(define* (write-assignments alist)
+  "Write the assignments in ALIST, an association list,
+to the configuration port."
+  (for-each (match-lambda
+              ((key . value)
+               (write-assignment key value)))
+            alist))
+
+(define* (make-machine-alist #:key system cpu-family cpu endian)
+  "Make an association list for the [host_machine] section."
+  `((system . ,system)
+    (cpu-family . ,cpu-family)
+    (cpu . ,cpu)
+    (endian . ,endian)))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate.
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate Maxime Devos
@ 2021-07-12 12:35     ` Mathieu Othacehe
  2021-07-13 13:33       ` Maxime Devos
  0 siblings, 1 reply; 175+ messages in thread
From: Mathieu Othacehe @ 2021-07-12 12:35 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025


Hey,

> +(define* (target-linux? #:optional (target (or (%current-target-system)
> +                                               (%current-system))))

You can add a docstring here, something like:

  "Is the operating system of TARGET Linux?"

> +  (string-contains target "linux"))

You should use the "->bool" procedure to return a boolean here.

>  (define* (target-mingw? #:optional (target (%current-target-system)))

You can add a docstring, something like:

  "Is the operating system of TARGET Windows 32 bits?"

> +  (map (compose ->bool target-linux?)

target-linux? should return a boolean

> +(test-equal "target-mingw?"
> +  '(#f #f #t)
> +  (map (compose ->bool target-mingw?)

You can write:

--8<---------------cut here---------------start------------->8---
  (map target-mingw?
       '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32")))
--8<---------------cut here---------------end--------------->8---

here.

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation.
  2021-07-11 11:47   ` [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation Maxime Devos
@ 2021-07-12 12:42     ` Mathieu Othacehe
  2021-07-13 13:36       ` Maxime Devos
  0 siblings, 1 reply; 175+ messages in thread
From: Mathieu Othacehe @ 2021-07-12 12:42 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025


Hey,

> This has been tested with:
>
> $ ./pre-inst-env guix build glib --target=aarch64-linux-gnu
>
> on a x86_64-linux system.  ‘If it compiles, it should work.’

Nice you added aarch64 support :).

> +(define (target-hurd? triplet)
> +  (and (string-suffix? "-gnu" triplet)
> +       (not (string-contains triplet "linux"))))

Maybe it should go in the (guix utils) module.

> +    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
> +                   (substring triplet 0 4))
> +                  ((target-x86-64? triplet) "x86_64")
> +                  ((target-aarch64? triplet) "armv8-a")

We could add:

--8<---------------cut here---------------start------------->8---
((target-arm32? triplet) "armv7")
--8<---------------cut here---------------end--------------->8---

for arm32 support.

> +          (call-with-output-file #$output
> +            (lambda (f)
> +              (parameterize ((configuration-port f))

Why don't you pass the port parameter to the build side procedures like
so:

--8<---------------cut here---------------start------------->8---
(call-with-output-file #$output
  (lambda (port)
    (write-section-header port "host_machine")
    ...
--8<---------------cut here---------------end--------------->8---

> +(define* (make-machine-alist #:key system cpu-family cpu endian)
> +  "Make an association list for the [host_machine] section."
> +  `((system . ,system)
> +    (cpu-family . ,cpu-family)
> +    (cpu . ,cpu)
> +    (endian . ,endian)))

This one is unused, right?

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate.
  2021-07-12 12:35     ` Mathieu Othacehe
@ 2021-07-13 13:33       ` Maxime Devos
  2021-07-14 10:46         ` Maxime Devos
  0 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-13 13:33 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 49025

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

Mathieu Othacehe schreef op ma 12-07-2021 om 14:35 [+0200]:
> Hey,
> 
> > +(define* (target-linux? #:optional (target (or (%current-target-system)
> > +                                               (%current-system))))
> 
> You can add a docstring here, something like:
> 
>   "Is the operating system of TARGET Linux?"

The Linux kernel by itself doesn't make an operating system,
as the kernel doesn't have a package manager, display manager,
basic text editors, application to configure network connections ...,
so I made this 

  "Does the operating system of TARGET use the Linux kernel?"

> > +  (string-contains target "linux"))
> 
> You should use the "->bool" procedure to return a boolean here.

Done in v5.

> >  (define* (target-mingw? #:optional (target (%current-target-system)))
> 
> You can add a docstring, something like:
> 
>   "Is the operating system of TARGET Windows 32 bits?"

Done in v5, but I dropped the '32-bits' and added a comment:

       ;; The "-32" doesn't mean TARGET is 32-bit, as "x86_64-w64-mingw32"
       ;; is a valid triplet (see the (gnu ci) module) and 'w64' and 'x86_64'
       ;; are 64-bit.

I wouldn't know what the "32" in "mingw32" refers to.

> > +  (map (compose ->bool target-linux?)
> 
> target-linux? should return a boolean
> 
> > +(test-equal "target-mingw?"
> > +  '(#f #f #t)
> > +  (map (compose ->bool target-mingw?)
> 
> You can write:
> 
> --8<---------------cut here---------------start------------->8---
>   (map target-mingw?
>        '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32")))
> --8<---------------cut here---------------end--------------->8---
> 
> here.

Done in v5.  I'll send the v5 once everything is tested again
and commits have been properly rebased.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation.
  2021-07-12 12:42     ` Mathieu Othacehe
@ 2021-07-13 13:36       ` Maxime Devos
  0 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-13 13:36 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 49025

[-- Attachment #1: Type: text/plain, Size: 2126 bytes --]

Mathieu Othacehe schreef op ma 12-07-2021 om 14:42 [+0200]:
> Hey,
> 
> > This has been tested with:
> > 
> > $ ./pre-inst-env guix build glib --target=aarch64-linux-gnu
> > 
> > on a x86_64-linux system.  ‘If it compiles, it should work.’
> 
> Nice you added aarch64 support :).
> 
> > +(define (target-hurd? triplet)
> > +  (and (string-suffix? "-gnu" triplet)
> > +       (not (string-contains triplet "linux"))))
> 
> Maybe it should go in the (guix utils) module.

I placed it there, and adjusted (gnu packages hurd)
and other modules to use it instead of hurd-triplet?.
> 
> > +    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
> > +                   (substring triplet 0 4))
> > +                  ((target-x86-64? triplet) "x86_64")
> > +                  ((target-aarch64? triplet) "armv8-a")
> 
> We could add:
> 
> --8<---------------cut here---------------start------------->8---
> ((target-arm32? triplet) "armv7")
> --8<---------------cut here---------------end--------------->8---
> 
> for arm32 support.

Added in the v5! I assume arm32 is little-endian in Guix.

> > +          (call-with-output-file #$output
> > +            (lambda (f)
> > +              (parameterize ((configuration-port f))
> 
> Why don't you pass the port parameter to the build side procedures like
> so:
> 
> --8<---------------cut here---------------start------------->8---
> (call-with-output-file #$output
>   (lambda (port)
>     (write-section-header port "host_machine")
>     ...
> --8<---------------cut here---------------end--------------->8---

No reason in particular.  I'll eliminate the 'configuration-port' parameter
in the v5.

> > +(define* (make-machine-alist #:key system cpu-family cpu endian)
> > +  "Make an association list for the [host_machine] section."
> > +  `((system . ,system)
> > +    (cpu-family . ,cpu-family)
> > +    (cpu . ,cpu)
> > +    (endian . ,endian)))
> 
> This one is unused, right?

Yes. I'll remove it in the v5.

I'll send the v5 once it is tested (with --target=armhf-linux-gnu).

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate.
  2021-07-13 13:33       ` Maxime Devos
@ 2021-07-14 10:46         ` Maxime Devos
  0 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 10:46 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 49025

[-- Attachment #1: Type: text/plain, Size: 92 bytes --]

Maxime Devos schreef op di 13-07-2021 om 15:33 [+0200]:
> Done in v5.
I meant v6 here.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson
  2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
                   ` (5 preceding siblings ...)
  2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
@ 2021-07-14 11:12 ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 01/22] utils: Define 'target-linux?' predicate Maxime Devos
                     ` (21 more replies)
  6 siblings, 22 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

The following changes were made since the v5:

  * The 'configuration-port' parameter has been eliminated
  * #:target and #:build is set in meson-cross-build, such that
    'TARGET-strip' is used instead of 'strip'
  * #:dynamic-linker-cache? is set to to #f in meson-cross-build,
    as in gnu-cross-build
  * 'make-machine-alist' now supports 'arm-linux-gnueabihf'.
  * 'make-machine-alist' now has a generic fallback fake ‘CPU type’.
    Apparently, meson doesn't care what the value is and most
    software doesn't.  Now powerpc64le-linux-gnu is supported
    (tested with qemu) and also mips64le is supported (untested).

    All supported cross targets should now be supported by meson.
  * the new target-...? proedures always return booleans
  * added some docstrings
  * target-hurd? is moved to (guix utils)

Maxime Devos (22):
  utils: Define 'target-linux?' predicate.
  utils: Define 'target-hurd?' predicate.
  utils: Give 'target-mingw?' a docstring.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpg-error: Fix cross-compilation error.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  libelf: Update configure script and config.guess and config.sub.
  build-system/meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |   5 +
 gnu/packages/base.scm              |   9 ++
 gnu/packages/bdw-gc.scm            |   4 +-
 gnu/packages/cross-base.scm        |   6 +-
 gnu/packages/elf.scm               |  44 +++---
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  48 ++++---
 gnu/packages/hurd.scm              |  10 +-
 gnu/packages/make-bootstrap.scm    |   2 +-
 gnu/packages/python.scm            |   5 +-
 gnu/packages/tls.scm               | 136 ++++++++++---------
 guix/build-system/meson.scm        | 209 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  56 ++++++++
 guix/packages.scm                  |  29 ++++
 guix/utils.scm                     |  38 ++++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 18 files changed, 575 insertions(+), 135 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

-- 
2.32.0





^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 01/22] utils: Define 'target-linux?' predicate.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 02/22] utils: Define 'target-hurd?' predicate Maxime Devos
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* guix/utils.scm (target-linux?): New predicate.
* tests/utils.scm
  ("target-linux?"): Test it.
  ("target-mingw?"): Also test ‘target-mingw?’.
---
 guix/utils.scm  |  7 +++++++
 tests/utils.scm | 17 +++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19990ceb8a..58bbff2b36 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,6 +82,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -543,6 +545,11 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  "Does the operating system of TARGET use the Linux kernel?"
+  (->bool (string-contains target "linux")))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25552..e170070907 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,22 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map target-linux?
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map target-mingw?
+       '("i686-linux-gnu" "i686-pc-gnu"
+         "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 02/22] utils: Define 'target-hurd?' predicate.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 01/22] utils: Define 'target-linux?' predicate Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 03/22] utils: Give 'target-mingw?' a docstring Maxime Devos
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

It behaves similarily to the other target-...? procedures.
The usage of hurd-triplet? / target-hurd? in libgc appears
incorrect to me, as (%current-system) is normally never false.

* gnu/packages/hurd.scm (hurd-triplet?): Move to ...
* guix/util.scm (target-hurd?): ... here, let its argument
  default to (%current-target-system) or (%current-system),
  and write a docstring.
* gnu/packages/hurd.scm
  (hurd-target?, hurd-system?): Use target-hurd? instead of
  hurd-triplet?.
* gnu/packages/bdw-gc.scm (libgc): Likewise.
* gnu/packages/cross-base.scm
  (cross-libc)[arguments]<#:configure-flags>: Likewise.
  (cross-libc)[arguments]<#:phases>: Likewise.
  (cross-libc)[arguments]<#:native-inputs>: Likewise.
* gnu/packages/make-boostrap.scm
  (%glibc-stripped)[inputs]: Likewise.
---
 gnu/packages/bdw-gc.scm         |  4 ++--
 gnu/packages/cross-base.scm     |  6 +++---
 gnu/packages/hurd.scm           | 10 +++-------
 gnu/packages/make-bootstrap.scm |  2 +-
 guix/utils.scm                  |  7 +++++++
 5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gnu/packages/bdw-gc.scm b/gnu/packages/bdw-gc.scm
index 0d82889bac..5ced11bb64 100644
--- a/gnu/packages/bdw-gc.scm
+++ b/gnu/packages/bdw-gc.scm
@@ -56,8 +56,8 @@
        ;; to configure script. See bug report and discussion:
        ;; <https://lists.opendylan.org/pipermail/bdwgc/2017-April/006275.html>
        ;; <https://lists.gnu.org/archive/html/bug-hurd/2017-01/msg00008.html>
-       ,@(if (hurd-triplet? (or (%current-system)
-                                (%current-target-system)))
+       ,@(if (target-hurd? (or (%current-system)
+                               (%current-target-system)))
              '("--disable-gcj-support")
              '()))))
    (native-inputs `(("pkg-config" ,pkg-config)))
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index ced226ef34..78cbf871ac 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -505,7 +505,7 @@ and the cross tool chain."
                ,@(package-arguments libc))
            ((#:configure-flags flags)
             `(cons ,(string-append "--host=" target)
-                   ,(if (hurd-triplet? target)
+                   ,(if (target-hurd? target)
                         `(cons "--disable-werror" ,flags)
                         flags)))
            ((#:phases phases)
@@ -519,7 +519,7 @@ and the cross tool chain."
                      (setenv "CROSS_LIBRARY_PATH"
                              (string-append kernel "/lib")) ; for Hurd's libihash
                      #t)))
-               ,@(if (hurd-triplet? target)
+               ,@(if (target-hurd? target)
                      '((add-after 'install 'augment-libc.so
                          (lambda* (#:key outputs #:allow-other-keys)
                            (let* ((out (assoc-ref outputs "out")))
@@ -536,7 +536,7 @@ and the cross tool chain."
 
         (native-inputs `(("cross-gcc" ,xgcc)
                          ("cross-binutils" ,xbinutils)
-                         ,@(if (hurd-triplet? target)
+                         ,@(if (target-hurd? target)
                                `(("cross-mig"
                                   ,@(assoc-ref (package-native-inputs xheaders)
                                                "cross-mig")))
diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm
index 59a7b55943..222ddbce65 100644
--- a/gnu/packages/hurd.scm
+++ b/gnu/packages/hurd.scm
@@ -51,20 +51,16 @@
             hurd-target?
             hurd-triplet?))
 
-(define (hurd-triplet? triplet)
-  (and (string-suffix? "-gnu" triplet)
-       (not (string-contains triplet "linux"))))
-
 (define (hurd-target?)
   "Return true if the cross-compilation target or the current system is
 GNU/Hurd."
-  (or (and=> (%current-target-system) hurd-triplet?)
+  (or (and=> (%current-target-system) target-hurd?)
       (and (not (%current-target-system))
-           (and=> (%current-system) hurd-triplet?))))
+           (and=> (%current-system) target-hurd?))))
 
 (define (hurd-system?)
   "Return true if the current system is the Hurd."
-  (and=> (%current-system) hurd-triplet?))
+  (and=> (%current-system) target-hurd?))
 
 (define (hurd-source-url version)
   (string-append "mirror://gnu/hurd/hurd-"
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 265884020e..5c306c145d 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -439,7 +439,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                                (assoc-ref %build-inputs "kernel-headers")))))
       (inputs `(("kernel-headers"
                  ,(if (or (and (%current-target-system)
-                               (hurd-triplet? (%current-target-system)))
+                               (target-hurd? (%current-target-system)))
                           (string-suffix? "-hurd" (%current-system)))
                       gnumach-headers
                       linux-libre-headers))
diff --git a/guix/utils.scm b/guix/utils.scm
index 58bbff2b36..5657a9d025 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -83,6 +83,7 @@
             %current-target-system
             package-name->name+version
             target-linux?
+            target-hurd?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -550,6 +551,12 @@ a character other than '@'."
   "Does the operating system of TARGET use the Linux kernel?"
   (->bool (string-contains target "linux")))
 
+(define* (target-hurd? #:optional (target (or (%current-target-system)
+                                              (%current-system))))
+  "Does TARGET represent the GNU(/Hurd) system?"
+  (and (string-suffix? "-gnu" target)
+       (not (string-contains target "linux"))))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
   (and target
        (string-suffix? "-mingw32" target)))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 03/22] utils: Give 'target-mingw?' a docstring.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 01/22] utils: Define 'target-linux?' predicate Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 02/22] utils: Define 'target-hurd?' predicate Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 04/22] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

target-hurd? and target-linux? have docstrings, but
target-mingw? doesn't.

* guix/utils.scm (target-mingw?): Add a docstring.

Reported-By: Mathieu Othacehe <othacehe@gnu.org>
---
 guix/utils.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 5657a9d025..005c9b2c5f 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -558,7 +558,11 @@ a character other than '@'."
        (not (string-contains target "linux"))))
 
 (define* (target-mingw? #:optional (target (%current-target-system)))
+  "Is the operating system of TARGET Windows?"
   (and target
+       ;; The "-32" doesn't mean TARGET is 32-bit, as "x86_64-w64-mingw32"
+       ;; is a valid triplet (see the (gnu ci) module) and 'w64' and 'x86_64'
+       ;; are 64-bit.
        (string-suffix? "-mingw32" target)))
 
 (define* (target-arm32? #:optional (target (or (%current-target-system)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 04/22] utils: Define a target-x86-32? and target-x86-64? predicate.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (2 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 03/22] utils: Give 'target-mingw?' a docstring Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input Maxime Devos
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates.
* tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests.
---
 guix/utils.scm  | 20 ++++++++++++++++++++
 tests/utils.scm | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 005c9b2c5f..0596f81b8a 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -85,6 +85,8 @@
             target-linux?
             target-hurd?
             target-mingw?
+            target-x86-32?
+            target-x86-64?
             target-arm32?
             target-aarch64?
             target-arm?
@@ -565,6 +567,24 @@ a character other than '@'."
        ;; are 64-bit.
        (string-suffix? "-mingw32" target)))
 
+(define* (target-x86-32? #:optional (target (or (%current-target-system)
+                                                (%current-system))))
+  "Is the architecture of TARGET a variant of Intel's 32-bit architecture
+(IA32)?"
+  ;; Intel also has a 16-bit architecture in the iN86 series, i286
+  ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
+  ;; procedure is not named target-x86?.
+  (or (string-prefix? "i386-" target)
+      (string-prefix? "i486-" target)
+      (string-prefix? "i586-" target)
+      (string-prefix? "i686-" target)))
+
+(define* (target-x86-64? #:optional (target (or (%current-target-system)
+                                                 (%current-system))))
+  "Is the architecture of TARGET a variant of Intel/AMD's 64-bit
+architecture (x86_64)?"
+  (string-prefix? "x86_64-" target))
+
 (define* (target-arm32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "arm" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index e170070907..648e91f242 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -306,6 +306,29 @@ skip these tests."
        '("i686-linux-gnu" "i686-pc-gnu"
          "i686-w64-mingw32")))
 
+(test-equal "target-x86-32?"
+  '(#f #f #f #t #t #t #t #f)
+  ;; These are (according to Wikipedia) two RISC architectures
+  ;; by Intel and presumably not compatible with the x86-32 series.
+  (map target-x86-32?
+       '("i860-gnu" "i960-gnu"
+         ;; This is a 16-bit architecture
+         "i286-gnu"
+         ;; These are part of the x86-32 series.
+         "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
+         ;; Maybe this one will exist some day, but not yet.
+         "i786-gnu")))
+
+(test-equal "target-x86-64?"
+  '(#t #f #f #f)
+  (map target-x86-64?
+       `("x86_64-linux-gnu" "i386-linux-gnu"
+         ;; Just because it includes "64" doesn't make it 64-bit.
+         "aarch64-linux-gnu"
+         ;; Note that (expt 2 109) in decimal notation starts with 64.
+         ;; However, it isn't 32-bit.
+         ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (3 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 04/22] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-18 17:42     ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Ludovic Courtès
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 06/22] net-base: Don't cross-compile Maxime Devos
                     ` (16 subsequent siblings)
  21 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index 3ba61b42c9..56300e6b61 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47fc34d3ce..9814015a05 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1866,6 +1867,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 06/22] net-base: Don't cross-compile.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (4 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 07/22] tzdata: Don't bother with cross-compiling Maxime Devos
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

net-base is pure data, so cross-compiling is pointless.

* gnu/packages/admin.scm
  (net-base)[arguments]<#:target>: Set to #f.
  (net-base)[arguments]<#:allowed-references>: Disallow all
  references.
---
 gnu/packages/admin.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index aab62331a3..394575ffec 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -937,6 +937,11 @@ to allow automatic login and starting any app.")
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
+       ;; This package consists solely of architecture-independent
+       ;; tables. Cross-compilation is pointless! Make sure we'll
+       ;; always get the same derivation.
+       #:target #f
+       #:allowed-references ()
        #:builder (begin
                    (use-modules (guix build utils)
                                 (srfi srfi-26))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 07/22] tzdata: Don't bother with cross-compiling.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (5 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 06/22] net-base: Don't cross-compile Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 08/22] libgpg-error: Remove trailing #f from phases Maxime Devos
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

The time zone database is architecture-independent,
so trying to cross-compile it is pointless!

* gnu/packages/base.scm
  (tzdata)[arguments]<#:target>: Set to #f.
  (tzdata)[allowed-references]: Only include the "out" output itself,
  to make sure no (architecture-dependent) binaries are installed.
---
 gnu/packages/base.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 565d2ccab8..88e4ec09a6 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1257,6 +1258,14 @@ command.")
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f
+       ;; This consists purely of (architecture-independent) data,
+       ;; so ‘cross-compilation’ is pointless here!
+       ;; (The binaries zic, dump, and tzselect are deleted in the post-install
+       ;; phase.)
+       #:target #f
+       ;; share/zoneinfo/posix is a symlink to share/zoneinfo,
+       ;; so include the package itself in #:allowed-references.
+       #:allowed-references ("out")
        #:make-flags (let ((out (assoc-ref %outputs "out"))
                           (tmp (getenv "TMPDIR")))
                       (list (string-append "TOPDIR=" out)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 08/22] libgpg-error: Remove trailing #f from phases.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (6 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 07/22] tzdata: Don't bother with cross-compiling Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 09/22] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

These aren't required anymore.

* gnu/packages/gnupg.scm (libgpgerror)[arguments]{cross-symlinks}:
  Remove trailing #f.
---
 gnu/packages/gnupg.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index a6ec75765c..5c0d03927e 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -114,8 +114,7 @@
                            (string-append x "-unknown-linux-gnu")))))
                    (symlink
                     (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))
-                 #t))))
+                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 09/22] libgpg-error: Prevent silent miscompilation some systems.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (7 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 08/22] libgpg-error: Remove trailing #f from phases Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error Maxime Devos
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* gnu/packages/gpg.scm
  (libgpgerror)[arguments]<#:phases>{cross-symlinks}: Only
  link to src/syscfg/lock-obj-pub.linux-gnu.h if the package
  is being compiled for a Linux target. Do not link either
  if the architecture is unknown, as the headers vary with
  the architecture.
---
 gnu/packages/gnupg.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 5c0d03927e..1a7c682ad6 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
 (define-public libgpg-error
@@ -94,27 +96,37 @@
     (build-system gnu-build-system)
     (arguments
      (if (%current-target-system)
-         `(#:modules ((ice-9 match)
-                      (guix build gnu-build-system)
+         `(#:modules ((guix build gnu-build-system)
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
-             ;; file. See Cross-Compiling section at:
+             ;; file if required. Note that these platform files depend on
+             ;; both the operating system and architecture!
+             ;;
+             ;; See Cross-Compiling section at:
              ;; https://github.com/gpg/libgpg-error/blob/master/README
              (add-after 'unpack 'cross-symlinks
-               (lambda* (#:key target inputs #:allow-other-keys)
-                 (let ((triplet
-                        (match (string-take target
-                                            (string-index target #\-))
-                          ("armhf" "arm-unknown-linux-gnueabi")
-                          ("mips64el" "mips-unknown-linux-gnu")
-                          (x
-                           (string-append x "-unknown-linux-gnu")))))
-                   (symlink
-                    (string-append "lock-obj-pub." triplet ".h")
-                    "src/syscfg/lock-obj-pub.linux-gnu.h"))))))
+               (lambda _
+                 (define (link triplet source)
+                   (symlink (string-append "lock-obj-pub." triplet ".h")
+                            (string-append "src/syscfg/lock-obj-pub."
+                                           source ".h")))
+                 ,(let* ((target (%current-target-system))
+                         (architecture
+                          (string-take target (string-index target #\-))))
+                    (cond ((target-linux? target)
+                           (match architecture
+                             ("armhf"
+                              `(link "arm-unknown-linux-gnueabi" "linux-gnu"))
+                             ("mips64el"
+                              `(link "mips-unknown-linux-gnu" "linux-gnu"))
+                             ;; Don't always link to the "linux-gnu"
+                             ;; configuration, as this is not correct for
+                             ;; all architectures.
+                             (_ #t)))
+                          (#t #t)))))))
          '()))
     (native-inputs `(("gettext" ,gettext-minimal)))
     (home-page "https://gnupg.org")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (8 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 09/22] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:22     ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 11/22] python: Fix reference to input when cross-compiling Maxime Devos
                     ` (11 subsequent siblings)
  21 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

TODO: inform upstream about the cross-compilation error.

* gnu/packages/gnupg.scm
  (libgpg-error)[arguments]{fix-gen-lock-obj.sh}: Prevent generated
  header files from being sprinkled with ‘\c’.
---
 gnu/packages/gnupg.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 1a7c682ad6..bb6fa4678b 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -100,6 +100,13 @@
                       (guix build utils))
            #:phases
            (modify-phases %standard-phases
+             ;; If this is left out, some generated header
+             ;; files will be sprinkled with ‘\c’, which
+             ;; the compiler won't like.
+             (add-after 'unpack 'fix-gen-lock-obj.sh
+               (lambda _
+                 (substitute* "src/gen-lock-obj.sh"
+                   (("if test -n `echo -n`") "if ! test -n `echo -n`"))))
              ;; When cross-compiling, some platform specific properties cannot
              ;; be detected. Create a symlink to the appropriate platform
              ;; file if required. Note that these platform files depend on
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 11/22] python: Fix reference to input when cross-compiling.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (9 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 12/22] openssl: Remove trailing #t from phases Maxime Devos
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

"sitecustomize.py" is a native input, so look it up
in 'native-inputs', not 'inputs'.

* gnu/packages/python.scm (customize-site): Look up "sizecustomize.py"
  in 'native-inputs', not 'inputs'.
---
 gnu/packages/python.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 227c612a68..ef47e79632 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -110,13 +110,14 @@
 
 (define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
-  `(lambda* (#:key inputs outputs #:allow-other-keys)
+  `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
-            (sitecustomize.py (assoc-ref inputs "sitecustomize.py"))
+            (sitecustomize.py (assoc-ref (or native-inputs inputs)
+                                         "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 12/22] openssl: Remove trailing #t from phases.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (10 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 11/22] python: Fix reference to input when cross-compiling Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 13/22] openssl: Make the #:phases argument a G-expression Maxime Devos
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Delete trailing #t.
---
 gnu/packages/tls.scm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 297e16dd70..8a8fcb59fd 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -364,8 +364,7 @@ required structures.")
                            ((string-prefix? "powerpc64" target)
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
-                            "linux-ppc")))
-                 #t)))
+                            "linux-ppc"))))))
            '())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
@@ -404,8 +403,7 @@ required structures.")
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
-                        (find-files lib "\\.a$"))
-              #t)))
+                        (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda* (#:key outputs #:allow-other-keys)
                ;; Move man3 pages and full HTML documentation to "doc".
@@ -418,8 +416,7 @@ required structures.")
                  (copy-recursively man3 man-target)
                  (delete-file-recursively man3)
                  (copy-recursively html html-target)
-                 (delete-file-recursively html)
-                 #t)))
+                 (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
          (lambda* (#:key outputs #:allow-other-keys)
@@ -428,8 +425,7 @@ required structures.")
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
                                                      ,(package-version this-package)
-                                                     "/misc"))
-             #t))))))
+                                                     "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 13/22] openssl: Make the #:phases argument a G-expression.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (11 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 12/22] openssl: Remove trailing #t from phases Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 14/22] openssl: Use G-exp machinery for referring to outputs Maxime Devos
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

This allows using this-package-native-input later.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>: Make this a G-expression.
  (openssl-1.0)[arguments]<#:phases>: Likewise.
---
 gnu/packages/tls.scm | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 8a8fcb59fd..0024709a96 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -40,6 +40,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
@@ -339,9 +340,10 @@ required structures.")
       ;; so we explicitly disallow it here.
       #:disallowed-references ,(list (canonical-package perl))
       #:phases
+      ,#~
       (modify-phases %standard-phases
-       ,@(if (%current-target-system)
-           '((add-before
+       #$@(if (%current-target-system)
+          #~((add-before
                'configure 'set-cross-compile
                (lambda* (#:key target outputs #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
@@ -365,7 +367,7 @@ required structures.")
                             "linux-ppc64")
                            ((string-prefix? "powerpc" target)
                             "linux-ppc"))))))
-           '())
+             #~())
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
@@ -375,9 +377,9 @@ required structures.")
                 (("/usr/bin/env")
                  (string-append (assoc-ref %build-inputs "coreutils")
                                 "/bin/env")))
-              (invoke ,@(if (%current-target-system)
-                          '("./Configure")
-                          '("./config"))
+              (invoke #$@(if (%current-target-system)
+                             #~("./Configure")
+                             #~("./config"))
                       "shared"       ;build shared libraries
                       "--libdir=lib"
 
@@ -386,13 +388,13 @@ required structures.")
                       ;; conventional.
                       (string-append "--openssldir=" out
                                      "/share/openssl-"
-                                     ,(package-version this-package))
+                                     #$(package-version this-package))
 
                       (string-append "--prefix=" out)
                       (string-append "-Wl,-rpath," lib)
-                      ,@(if (%current-target-system)
-                          '((getenv "CONFIGURE_TARGET_ARCH"))
-                          '())))))
+                      #$@(if (%current-target-system)
+                             #~((getenv "CONFIGURE_TARGET_ARCH"))
+                             #~())))))
         (add-after 'install 'move-static-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Move static libraries to the "static" output.
@@ -424,7 +426,7 @@ required structures.")
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
            (let ((out (assoc-ref outputs "out")))
              (delete-file-recursively (string-append out "/share/openssl-"
-                                                     ,(package-version this-package)
+                                                     #$(package-version this-package)
                                                      "/misc"))))))))
    (native-search-paths
     (list (search-path-specification
@@ -469,7 +471,7 @@ required structures.")
        ;; Parallel build is not supported in 1.0.x.
        ((#:parallel-build? _ #f) #f)
        ((#:phases phases)
-        `(modify-phases ,phases
+       #~(modify-phases #$phases
            (add-before 'patch-source-shebangs 'patch-tests
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                (let ((bash (assoc-ref (or native-inputs inputs) "bash")))
@@ -492,9 +494,9 @@ required structures.")
 	     ;; Override this phase because OpenSSL 1.0 does not understand -rpath.
 	     (lambda* (#:key outputs #:allow-other-keys)
 	       (let ((out (assoc-ref outputs "out")))
-		 (invoke ,@(if (%current-target-system)
-			       '("./Configure")
-			       '("./config"))
+		 (invoke #$@(if (%current-target-system)
+			        #~("./Configure")
+			        #~("./config"))
 			 "shared"                 ;build shared libraries
 			 "--libdir=lib"
 
@@ -502,12 +504,12 @@ required structures.")
 			 ;; PREFIX/ssl.  Change that to something more
 			 ;; conventional.
 			 (string-append "--openssldir=" out
-					"/share/openssl-" ,version)
+					"/share/openssl-" #$version)
 
 			 (string-append "--prefix=" out)
-			 ,@(if (%current-target-system)
-			       '((getenv "CONFIGURE_TARGET_ARCH"))
-			       '())))))
+			 #$@(if (%current-target-system)
+			        '((getenv "CONFIGURE_TARGET_ARCH"))
+			        '())))))
         (delete 'move-extra-documentation)
         (add-after 'install 'move-man3-pages
           (lambda* (#:key outputs #:allow-other-keys)
@@ -532,7 +534,7 @@ required structures.")
                ;; scripts.  Remove them to avoid retaining a reference on Perl.
                (let ((out (assoc-ref outputs "out")))
                  (delete-file-recursively (string-append out "/share/openssl-"
-                                                         ,version "/misc"))
+                                                         #$version "/misc"))
                  #t)))))))))
 
 (define-public libressl
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 14/22] openssl: Use G-exp machinery for referring to outputs.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (12 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 13/22] openssl: Make the #:phases argument a G-expression Maxime Devos
@ 2021-07-14 11:12   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 15/22] openssl: Move documentation instead of copying and deleting it Maxime Devos
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:12 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

This doesn't fix anything broken, just for simplifying
the code a little while we're rebuilding the world anyway.
IMHO this makes the code a little more readable.

* gnu/packages/tls.scm (openssl)[arguments]<#:phases>: Don't refer
  to the association list 'outputs', use #$output, #$output:doc
  and #$output:static instead.
---
 gnu/packages/tls.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 0024709a96..fd4a8b07b2 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Solene Rapenne <solene@perso.pw>
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -345,7 +346,7 @@ required structures.")
        #$@(if (%current-target-system)
           #~((add-before
                'configure 'set-cross-compile
-               (lambda* (#:key target outputs #:allow-other-keys)
+               (lambda* (#:key target #:allow-other-keys)
                  (setenv "CROSS_COMPILE" (string-append target "-"))
                  (setenv "CONFIGURE_TARGET_ARCH"
                          (cond
@@ -369,8 +370,8 @@ required structures.")
                             "linux-ppc"))))))
              #~())
         (replace 'configure
-          (lambda* (#:key outputs #:allow-other-keys)
-            (let* ((out (assoc-ref outputs "out"))
+          (lambda _
+            (let* ((out #$output)
                    (lib (string-append out "/lib")))
               ;; It's not a shebang so patch-source-shebangs misses it.
               (substitute* "config"
@@ -396,23 +397,23 @@ required structures.")
                              #~((getenv "CONFIGURE_TARGET_ARCH"))
                              #~())))))
         (add-after 'install 'move-static-libraries
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
             ;; Move static libraries to the "static" output.
-            (let* ((out    (assoc-ref outputs "out"))
+            (let* ((out    #$output)
                    (lib    (string-append out "/lib"))
-                   (static (assoc-ref outputs "static"))
+                   (static #$output:static)
                    (slib   (string-append static "/lib")))
               (for-each (lambda (file)
                           (install-file file slib)
                           (delete-file file))
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
-          (lambda* (#:key outputs #:allow-other-keys)
+          (lambda _
                ;; Move man3 pages and full HTML documentation to "doc".
-               (let* ((out    (assoc-ref outputs "out"))
+               (let* ((out    #$output)
                       (man3   (string-append out "/share/man/man3"))
                       (html (string-append out "/share/doc/openssl"))
-                      (doc    (assoc-ref outputs "doc"))
+                      (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
                  (copy-recursively man3 man-target)
@@ -421,13 +422,12 @@ required structures.")
                  (delete-file-recursively html))))
         (add-after
          'install 'remove-miscellany
-         (lambda* (#:key outputs #:allow-other-keys)
+         (lambda _
            ;; The 'misc' directory contains random undocumented shell and Perl
            ;; scripts.  Remove them to avoid retaining a reference on Perl.
-           (let ((out (assoc-ref outputs "out")))
-             (delete-file-recursively (string-append out "/share/openssl-"
-                                                     #$(package-version this-package)
-                                                     "/misc"))))))))
+           (delete-file-recursively (string-append #$output "/share/openssl-"
+                                                   #$(package-version this-package)
+                                                   "/misc")))))))
    (native-search-paths
     (list (search-path-specification
            (variable "SSL_CERT_DIR")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 15/22] openssl: Move documentation instead of copying and deleting it.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (13 preceding siblings ...)
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 14/22] openssl: Use G-exp machinery for referring to outputs Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 16/22] openssl: Move all man pages to separate output, not only man3 Maxime Devos
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Use
  'rename-file' instead of 'copy-recursively' and
  'delete-file-recursively'.
---
 gnu/packages/tls.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index fd4a8b07b2..fcecc6ba41 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -416,10 +416,10 @@ required structures.")
                       (doc    #$output:doc)
                       (man-target (string-append doc "/share/man/man3"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (copy-recursively man3 man-target)
-                 (delete-file-recursively man3)
-                 (copy-recursively html html-target)
-                 (delete-file-recursively html))))
+                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname html-target))
+                 (rename-file man3 man-target)
+                 (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
          (lambda _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 16/22] openssl: Move all man pages to separate output, not only man3.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (14 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 15/22] openssl: Move documentation instead of copying and deleting it Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 17/22] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

There does not seem to be any reason to only move man3 pages.
So, move all man pages to a separate output for documentation.

* gnu/packages/tls.scm
  (openssl)[arguments]<#:phases>{move-extra-documentation}: Move
  all man pages, not only man3.
---
 gnu/packages/tls.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index fcecc6ba41..6cebc1d6ed 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -409,16 +409,16 @@ required structures.")
                         (find-files lib "\\.a$")))))
         (add-after 'install 'move-extra-documentation
           (lambda _
-               ;; Move man3 pages and full HTML documentation to "doc".
+               ;; Move man pages and full HTML documentation to "doc".
                (let* ((out    #$output)
-                      (man3   (string-append out "/share/man/man3"))
-                      (html (string-append out "/share/doc/openssl"))
+                      (man    (string-append out "/share/man"))
+                      (html   (string-append out "/share/doc/openssl"))
                       (doc    #$output:doc)
-                      (man-target (string-append doc "/share/man/man3"))
+                      (man-target (string-append doc "/share/man"))
                       (html-target (string-append doc "/share/doc/openssl")))
-                 (mkdir-p (dirname man3-target))
+                 (mkdir-p (dirname man-target))
                  (mkdir-p (dirname html-target))
-                 (rename-file man3 man-target)
+                 (rename-file man man-target)
                  (rename-file html html-target))))
         (add-after
          'install 'remove-miscellany
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 17/22] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (15 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 16/22] openssl: Move all man pages to separate output, not only man3 Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 18/22] glib: Use a correct python in scripts when cross-compiling Maxime Devos
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

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(-)

diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index 6cebc1d6ed..8c7bba0b6e 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -311,6 +311,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")
@@ -349,25 +374,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 _
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 18/22] glib: Use a correct python in scripts when cross-compiling.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (16 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 17/22] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 19/22] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

During the build, a native python should be used as these
scripts will be invoked during the build, but when installed,
they should be a python for the system we're compiling for.

* gnu/packages/glib.scm
  (glib)[arguments]<#:phases>{patch-python-references}: Look up
  "python" in 'native-inputs', not 'inputs'.
  (glib)[inputs]{python,python-wrapper,bash-minimal}: New inputs.
---
 gnu/packages/glib.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index f0be2ddaa4..99f5c5d450 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -16,6 +16,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -223,14 +224,19 @@ shared NFS home directories.")
              #t))
          ;; Python references are not being patched in patch-phase of build,
          ;; despite using python-wrapper as input. So we patch them manually.
+         ;;
+         ;; These python scripts are both used during build and installed,
+         ;; so at first, use a python from 'native-inputs', not 'inputs'. When
+         ;; cross-compiling, the 'patch-shebangs' phase will replace
+         ;; the native python with a python from 'inputs'.
          (add-after 'unpack 'patch-python-references
-           (lambda* (#:key inputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
              (substitute* '("gio/gdbus-2.0/codegen/gdbus-codegen.in"
                             "glib/gtester-report.in"
                             "gobject/glib-genmarshal.in"
                             "gobject/glib-mkenums.in")
                (("@PYTHON@")
-                (string-append (assoc-ref inputs "python")
+                (string-append (assoc-ref (or native-inputs inputs) "python")
                                "/bin/python"
                                ,(version-major+minor
                                  (package-version python)))))
@@ -293,6 +299,13 @@ shared NFS home directories.")
        ("xsltproc" ,libxslt)))
     (inputs
      `(("bash-completion" ,bash-completion)
+       ;; "python", "python-wrapper" and "bash-minimal"
+       ;; are for the 'patch-shebangs' phase, to make
+       ;; sure the installed scripts end up with a correct shebang
+       ;; when cross-compiling.
+       ("python" ,python)
+       ("python-wrapper" ,python-wrapper)
+       ("bash-minimal" ,bash-minimal)
        ("dbus" ,dbus)
        ("libelf" ,libelf)))
     (propagated-inputs
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 19/22] glib: Verify the cross-compiled python is used in installed scripts.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (17 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 18/22] glib: Use a correct python in scripts when cross-compiling Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 20/22] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

* gnu/packages/glib.scm (glib)[arguments]<#:disallowed-references>:
  Disallow the native python when cross-compiling.
---
 gnu/packages/glib.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 99f5c5d450..e4ebed7e2c 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -77,6 +77,8 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-26)
   #:use-module ((srfi srfi-1) #:hide (zip))
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
@@ -200,7 +202,15 @@ shared NFS home directories.")
                "static"                 ;static libraries
                "bin"))                  ;executables; depends on Python
     (arguments
-     `(#:disallowed-references (,tzdata-for-tests)
+     `(#:disallowed-references
+       (,tzdata-for-tests
+        ;; Verify glib-mkenums, gtester, ... use the cross-compiled
+        ;; python.
+        ,@(if (%current-target-system)
+              (map (cut gexp-input <> #:native? #t)
+                   `(,(this-package-native-input "python")
+                     ,(this-package-native-input "python-wrapper")))
+              '()))
        #:configure-flags '("--default-library=both"
                            "-Dman=true"
                            "-Dselinux=disabled")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 20/22] glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (18 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 19/22] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 21/22] libelf: Update configure script and config.guess and config.sub Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 22/22] build-system/meson: Support cross-compilation Maxime Devos
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

Otherwise, "tzdata" won't be found when cross-compiling
and string-append will complain about types. Alternatively,
"tzdata" could be moved from 'native-inputs' to 'inputs'.

* gnu/packages/glib.scm (glib)[arguments]<#:phases>{pre-check}:
  Look up "tzdata" in 'native-inputs', not 'inputs'.
---
 gnu/packages/glib.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index e4ebed7e2c..01683df8c5 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -252,10 +252,11 @@ shared NFS home directories.")
                                  (package-version python)))))
              #t))
          (add-before 'check 'pre-check
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              ;; For tests/gdatetime.c.
              (setenv "TZDIR"
-                     (string-append (assoc-ref inputs "tzdata")
+                     (string-append (assoc-ref (or native-inputs inputs)
+                                               "tzdata")
                                     "/share/zoneinfo"))
              ;; Some tests want write access there.
              (setenv "HOME" (getcwd))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 21/22] libelf: Update configure script and config.guess and config.sub.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (19 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 20/22] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 22/22] build-system/meson: Support cross-compilation Maxime Devos
  21 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

The current configure script is too old to find the cross-compiler
and support variables passed as arguments. Also, config.guess and
config.sub are too old to recognise powerpc64 and aarch64.  Solve
this by regenerating the 'configure' script and replacing
'config.guess' and 'config.sub'.

* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{configure}: Remove phase.
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script and replace 'config.guess' and 'config.sub'.
---
 gnu/packages/elf.scm | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..2bc1d00048 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,32 @@ static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ;; This old 'configure' script doesn't support cross-compilation
+         ;; well.  I.e., it fails to find the cross-compiler.  Also,
+         ;; the old `configure' script doesn't support variables passed as
+         ;; arguments.  A third problem is that config.sub is too old to
+         ;; recognise aarch64 and powerpc64le.
+         ;;
+         ;; Solve this by regenerating the configure script and letting
+         ;; autoreconf update 'config.sub'.  While 'config.sub' is updated
+         ;; anyway, update 'config.guess' as well.
+         (add-before 'bootstrap 'delete-configure
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
+             (delete-file "configure")
+             (delete-file "config.sub")
+             (delete-file "config.guess")
+             (for-each (lambda (file)
+                         (install-file
+                          (string-append
+                           (assoc-ref (or native-inputs inputs) "automake")
+                           "/share/automake-"
+                           ,(version-major+minor (package-version automake))
+                           "/" file) "."))
+                       '("config.sub" "config.guess")))))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ;; For up-to-date 'config.guess' and 'config.sub'
+       ("automake" ,automake)))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 22/22] build-system/meson: Support cross-compilation.
  2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
                     ` (20 preceding siblings ...)
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 21/22] libelf: Update configure script and config.guess and config.sub Maxime Devos
@ 2021-07-14 11:13   ` Maxime Devos
  2021-07-14 17:28     ` bug#49025: " Mathieu Othacehe
  21 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:13 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe, Maxime Devos

For cross-compilation, meson needs to be passed a
‘cross file’ with information on the architecture,
CPU type, endianness and operating system, and the
name of the cross-compiler binaries.

The new module (guix build meson-configuration) has
some utilities for writing these cross files, used
by 'make-cross-file' in a G-exp.  The values for
the cross file are generated by 'make-machine-alist'
and 'make-binaries-alist'.

'make-machine-alist' and 'make-binaries-alist' live
on the host side, such that new architectures and operating
systems can be added without causing rebuilds for old
architectures.

All operating systems and targets supported by Guix are
theoretically supported, but only aarch64-linux-gnu,
powerpc64le-linux-gnu and arm-linux-gnueabihf have been
tested.  i686-linux-gnu has also been tested with a previous
version of this patch series but required some changes
to 'cross-base.scm'.

This has been tested with:

$ ./pre-inst-env guix build glib --target=TARGET

* guix/build/meson-configuration.scm
  (write-section-header): New procedure.
  (write-assignment): New procedure.
  (write-assignments): New procedure.
* guix/build-system/meson.scm
  (target-hurd?): New predicate.
  (make-machine-alist): New procedure.
  (make-binaries-alist): New procedure.
  (make-cross-file): New procedure.
  (meson-cross-build): New procedure.
  (lower)[build-inputs]: Add standard cross packages when cross-compiling.
  Do not include regular 'inputs' when cross-compiling.
  (lower)[host-inputs]: Include 'inputs' when cross-compiling.
  (lower)[target-inputs]: Add cross packages when cross-compiling.
  (lower)[build]: Call 'meson-cross-build' instead of 'cross-build'
  when cross-compiling.
  (lower)[target]: Set it.
  (lower)[private-keywords]: Do not remove #:target when cross-compiling.
---
 Makefile.am                        |   1 +
 guix/build-system/meson.scm        | 209 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  56 ++++++++
 3 files changed, 247 insertions(+), 19 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm

diff --git a/Makefile.am b/Makefile.am
index 05f013e3c2..6c17ab8492 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -234,6 +234,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/java-utils.scm			\
   guix/build/lisp-utils.scm			\
+  guix/build/meson-configuration.scm		\
   guix/build/maven/java.scm			\
   guix/build/maven/plugin.scm			\
   guix/build/maven/pom.scm			\
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 5adc0f92c8..dae0abde94 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (guix packages)
   #:use-module (ice-9 match)
   #:export (%meson-build-system-modules
-            meson-build-system))
+            meson-build-system
+            make-cross-file))
 
 ;; Commentary:
 ;;
@@ -40,6 +42,68 @@
 ;;
 ;; Code:
 
+(define (make-machine-alist triplet)
+  "Make an association list describing what should go into
+the ‘host_machine’ section of the cross file when cross-compiling
+for TRIPLET."
+  `((system . ,(cond ((target-hurd? triplet) "gnu")
+                     ((target-linux? triplet) "linux")
+                     ((target-mingw? triplet) "windows")
+                     (#t (error "meson: unknown operating system"))))
+    (cpu_family . ,(cond ((target-x86-32? triplet) "x86")
+                         ((target-x86-64? triplet) "x86_64")
+                         ((target-arm32? triplet) "arm")
+                         ((target-aarch64? triplet) "aarch64")
+                         ((target-powerpc? triplet)
+                          (if (target-64bit? triplet)
+                              "ppc64"
+                              "ppc"))
+                         (#t (error "meson: unknown architecture"))))
+    (cpu . ,(cond ((target-x86-32? triplet) ; i386, ..., i686
+                   (substring triplet 0 4))
+                  ((target-x86-64? triplet) "x86_64")
+                  ((target-aarch64? triplet) "armv8-a")
+                  ((target-arm32? triplet) "armv7")
+                  ;; According to #mesonbuild on OFTC, there does not appear
+                  ;; to be an official-ish list of CPU types recognised by
+                  ;; Meson, the "cpu" field is not used by Meson itself and
+                  ;; most software doesn't look at this field, except perhaps
+                  ;; for selecting optimisations, so set it to something
+                  ;; arbitrary.
+                  (#t "strawberries")))
+    (endian . ,(cond ((string-prefix? "powerpc64le-" triplet) "little")
+                     ((string-prefix? "mips64el-" triplet) "little")
+                     ((target-x86-32? triplet) "little")
+                     ((target-x86-64? triplet) "little")
+                     ;; At least in Guix.  Aarch64 and 32-bit arm
+                     ;; have a big-endian mode as well.
+                     ((target-arm? triplet) "little")
+                     (#t (error "meson: unknown architecture"))))))
+
+(define (make-binaries-alist triplet)
+  "Make an associatoin list describing what should go into
+the ‘binaries’ section of the cross file when cross-compiling for
+TRIPLET."
+  `((c . ,(cc-for-target triplet))
+    (cpp . ,(cxx-for-target triplet))
+    (pkgconfig . ,(pkg-config-for-target triplet))
+    (objcopy . ,(string-append triplet "-objcopy"))
+    (ar . ,(string-append triplet "-ar"))
+    (ld . ,(string-append triplet "-ld"))
+    (strip . ,(string-append triplet "-strip"))))
+
+(define (make-cross-file triplet)
+  (computed-file "cross-file"
+    (with-imported-modules '((guix build meson-configuration))
+      #~(begin
+          (use-modules (guix build meson-configuration))
+          (call-with-output-file #$output
+            (lambda (port)
+              (write-section-header port "host_machine")
+              (write-assignments port '#$(make-machine-alist triplet))
+              (write-section-header port "binaries")
+              (write-assignments port '#$(make-binaries-alist triplet))))))))
+
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
@@ -68,24 +132,34 @@
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    `(#:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
-
-  (and (not target) ;; TODO: add support for cross-compilation.
-       (bag
-         (name name)
-         (system system)
-         (build-inputs `(("meson" ,meson)
-                         ("ninja" ,ninja)
-                         ,@native-inputs
-                         ,@inputs
-                         ;; Keep the standard inputs of 'gnu-build-system'.
-                         ,@(standard-packages)))
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (outputs outputs)
-         (build meson-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:meson #:ninja #:inputs #:native-inputs #:outputs
+      ,@(if target
+            '()
+            '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (build-inputs `(("meson" ,meson)
+                    ("ninja" ,ninja)
+                    ,@native-inputs
+                    ,@(if target '() inputs)
+                    ;; Keep the standard inputs of 'gnu-build-system'.
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages)))
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target inputs '())))
+    ;; Keep the standard inputs of 'gnu-buid-system'.
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target meson-cross-build meson-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (meson-build name inputs
                       #:key
@@ -161,6 +235,103 @@ has a 'meson.build' file."
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (meson-cross-build name
+                            #:key
+                            target
+                            build-inputs host-inputs target-inputs
+                            guile source
+                            (outputs '("out"))
+                            (configure-flags ''())
+                            (search-paths '())
+                            (native-search-paths '())
+
+                            (build-type "debugoptimized")
+                            (tests? #f)
+                            (test-target "test")
+                            (glib-or-gtk? #f)
+                            (parallel-build? #t)
+                            (parallel-tests? #f)
+                            (validate-runpath? #t)
+                            (patch-shebangs? #t)
+                            (strip-binaries? #t)
+                            (strip-flags ''("--strip-debug"))
+                            (strip-directories ''("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                            (elf-directories ''("lib" "lib64" "libexec"
+                                                "bin" "sbin"))
+                            ;; See 'gnu-cross-build' for why this needs to be
+                            ;; disabled when cross-compiling.
+                            (make-dynamic-linker-cache? #f)
+                            (phases '%standard-phases)
+                            (system (%current-system))
+                            (imported-modules %meson-build-system-modules)
+                            (modules '((guix build meson-build-system)
+                                       (guix build utils)))
+                            allowed-references
+                            disallowed-references)
+  "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that
+SOURCE has a 'meson.build' file."
+  (define cross-file
+    (make-cross-file target))
+  (define inputs
+    (if (null? target-inputs)
+        (input-tuples->gexp host-inputs)
+        #~(append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs))))
+  (define builder
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@(sexp->gexp modules))
+
+          (define build-phases
+            #$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
+                (if glib-or-gtk?
+                    phases
+                    #~(modify-phases #$phases
+                        (delete 'glib-or-gtk-compile-schemas)
+                        (delete 'glib-or-gtk-wrap)))))
+
+          ;; Do not use 'with-build-variables', as there should be
+          ;; no reason to use %build-inputs and friends.
+          (meson-build #:source #+source
+                       #:system #$system
+                       #:build #$(nix-system->gnu-triplet system)
+                       #:target #$target
+                       #:outputs #$(outputs->gexp outputs)
+                       #:inputs #$inputs
+                       #:native-inputs #+(input-tuples->gexp build-inputs)
+                       #:search-paths '#$(sexp->gexp
+                                          (map search-path-specification->sexp
+                                                     search-paths))
+                       #:native-search-paths '#$(sexp->gexp
+                                                 (map search-path-specification->sexp
+                                                      native-search-paths))
+                       #:phases build-phases
+                       #:make-dynamic-linker-cache? #$make-dynamic-linker-cache?
+                       #:configure-flags `("--cross-file" #+cross-file
+                                           ,@#$(sexp->gexp configure-flags))
+                       #:build-type #$build-type
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:parallel-build? #$parallel-build?
+                       #:parallel-tests? #$parallel-tests?
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$(sexp->gexp strip-flags)
+                       #:strip-directories #$(sexp->gexp strip-directories)
+                       #:elf-directories #$(sexp->gexp elf-directories)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define meson-build-system
   (build-system
     (name 'meson)
diff --git a/guix/build/meson-configuration.scm b/guix/build/meson-configuration.scm
new file mode 100644
index 0000000000..1aac5f8f0a
--- /dev/null
+++ b/guix/build/meson-configuration.scm
@@ -0,0 +1,56 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-configuration)
+  #:use-module (ice-9 match)
+  #:export (write-section-header write-assignment write-assignments))
+
+;; Commentary:
+;;
+;; Utilities for generating a ‘Cross build definition file’ for
+;; the Meson build system.  Configuration values are currently
+;; never escaped.  In practice this is unlikely to be a problem
+;; in the build environment.
+;;
+;; Code:
+
+(define (write-section-header port section-name)
+  "Write a section header for a section named SECTION-NAME to PORT."
+  (format port "[~a]~%" section-name))
+
+(define (write-assignment port key value)
+  "Write an assignment of VALUE to KEY to PORT.
+
+VALUE must be a string (without any special characters such as quotes),
+a boolean or an integer.  Lists are currently not supported"
+  (match value
+    ((? string?)
+     (format port "~a = '~a'~%" key value))
+    ((? integer?)
+     (format port "~a = ~a~%" key value))
+    (#f
+     (format port "~a = true~%" key))
+    (#t
+     (format port "~a = false~%" key))))
+
+(define* (write-assignments port alist)
+  "Write the assignments in ALIST, an association list, to PORT."
+  (for-each (match-lambda
+              ((key . value)
+               (write-assignment port key value)))
+            alist))
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error.
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error Maxime Devos
@ 2021-07-14 11:22     ` Maxime Devos
  0 siblings, 0 replies; 175+ messages in thread
From: Maxime Devos @ 2021-07-14 11:22 UTC (permalink / raw)
  To: 49025; +Cc: Mathieu Othacehe

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

Maxime Devos schreef op wo 14-07-2021 om 13:12 [+0200]:
> TODO: inform upstream about the cross-compilation error.

It appears that upstream is already informed:
<https://marc.info/?l=gnupg-devel&m=161670998014699&w=2>
<https://marc.info/?l=gnupg-devel&m=161674277725612&w=2>.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 175+ messages in thread

* bug#49025: [PATCH v6 22/22] build-system/meson: Support cross-compilation.
  2021-07-14 11:13   ` [bug#49025] [PATCH v6 22/22] build-system/meson: Support cross-compilation Maxime Devos
@ 2021-07-14 17:28     ` Mathieu Othacehe
  0 siblings, 0 replies; 175+ messages in thread
From: Mathieu Othacehe @ 2021-07-14 17:28 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 49025-done


Hey Maxime,

> All operating systems and targets supported by Guix are
> theoretically supported, but only aarch64-linux-gnu,
> powerpc64le-linux-gnu and arm-linux-gnueabihf have been
> tested.  i686-linux-gnu has also been tested with a previous
> version of this patch series but required some changes
> to 'cross-base.scm'.

That's great, I pushed the whole series on core-updates. Now let's see
if we can get more packages to cross-compile :)!

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-07-14 11:12   ` [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input Maxime Devos
@ 2021-07-18 17:42     ` Ludovic Courtès
  2021-07-19  9:40       ` Maxime Devos
  0 siblings, 1 reply; 175+ messages in thread
From: Ludovic Courtès @ 2021-07-18 17:42 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Mathieu Othacehe, 49025

Hello!

Maxime Devos <maximedevos@telenet.be> writes:

> These macros are intended to be used in build phases.
> More precisely, (assoc-ref %build-inputs "input") can be
> replaced by #$(this-package-input "input") or #+(this-package-native-input
> "native-input") as appropriate.
>
> * guix/packages.scm
>   (package-input, package-native-input): New (unexported) procedures.
>   (this-package-input, this-package-native-input): New macros.

As discussed some time ago on IRC, I think it would be good to
homogenize this with ‘lookup-package-input’ and related procedures
introduced in ba32f6363878165b3ca53113f6c95b8677b8537b (we both had the
same idea :-)).

What about keeping the ‘this-’ macros above, rewriting them in terms of
‘lookup-’, and removing ‘package-input’ and ‘package-native-input’?

Anyhow, I’m glad this series made it into the repo, thumbs up comrades!

Ludo’.




^ permalink raw reply	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-07-18 17:42     ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Ludovic Courtès
@ 2021-07-19  9:40       ` Maxime Devos
  2021-07-23  8:53         ` Ludovic Courtès
  0 siblings, 1 reply; 175+ messages in thread
From: Maxime Devos @ 2021-07-19  9:40 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Mathieu Othacehe, 49025


[-- Attachment #1.1: Type: text/plain, Size: 539 bytes --]

Ludovic Courtès schreef op zo 18-07-2021 om 19:42 [+0200]:
> As discussed some time ago on IRC, I think it would be good to
> homogenize this with ‘lookup-package-input’ and related procedures
> introduced in ba32f6363878165b3ca53113f6c95b8677b8537b (we both had the
> same idea :-)).
> 
> What about keeping the ‘this-’ macros above, rewriting them in terms of
> ‘lookup-’, and removing ‘package-input’ and ‘package-native-input’?

I've written a patch (see attachement) to do this.

Greetings,
MMaxime.

[-- Attachment #1.2: 0001-packages-Use-lookup-package-input-and-friends-instea.patch --]
[-- Type: text/x-patch, Size: 2281 bytes --]

From f9803aa77f348214b6295d363585282a2b2f35e6 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Mon, 19 Jul 2021 11:08:40 +0200
Subject: [PATCH] packages: Use 'lookup-package-input' and friends instead of
 'package-input'.

* guix/packages.scm
  (package-input, package-native-input): Remove.
  (this-package-input): Use 'lookup-package-input' and
  'lookup-package-propagated-input' instead of 'package-input'.
  (this-package-native-input): Use 'lookup-package-native-input'
  instead of 'package-input'.
---
 guix/packages.scm | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index d3fa72fd09..2349bb4340 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -550,32 +550,18 @@ object."
         #f)))
     (_ #f)))
 
-(define (package-input package name)
-  "Return the package input NAME of PACKAGE--i.e., an input
-from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
-considered.  If this input does not exist, return #f instead."
-  (and=> (or (assoc-ref (package-inputs package) name)
-             (assoc-ref (package-propagated-inputs package) name))
-         car))
-
-(define (package-native-input package name)
-  "Return the native package input NAME of PACKAGE--i.e., an input
-from the ‘native-inputs’ field. If this native input does not exist,
-return #f instead."
-  (and=> (assoc-ref (package-native-inputs package) name)
-         car))
-
 (define-syntax-rule (this-package-input name)
   "Return the input NAME of the package being defined--i.e., an input
 from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
 considered.  If this input does not exist, return #f instead."
-  (package-input this-package name))
+  (or (lookup-package-input this-package name)
+      (lookup-package-propagated-input this-package name)))
 
 (define-syntax-rule (this-package-native-input name)
   "Return the native package input NAME of the package being defined--i.e.,
 an input from the ‘native-inputs’ field.  If this native input does not
 exist, return #f instead."
-  (package-native-input this-package name))
+  (lookup-package-native-input this-package name))
 
 ;; Error conditions.
 
-- 
2.32.0


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply related	[flat|nested] 175+ messages in thread

* [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson
  2021-07-19  9:40       ` Maxime Devos
@ 2021-07-23  8:53         ` Ludovic Courtès
  0 siblings, 0 replies; 175+ messages in thread
From: Ludovic Courtès @ 2021-07-23  8:53 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Mathieu Othacehe, 49025

Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> From f9803aa77f348214b6295d363585282a2b2f35e6 Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Mon, 19 Jul 2021 11:08:40 +0200
> Subject: [PATCH] packages: Use 'lookup-package-input' and friends instead of
>  'package-input'.
>
> * guix/packages.scm
>   (package-input, package-native-input): Remove.
>   (this-package-input): Use 'lookup-package-input' and
>   'lookup-package-propagated-input' instead of 'package-input'.
>   (this-package-native-input): Use 'lookup-package-native-input'
>   instead of 'package-input'.

Pushed, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 175+ messages in thread

end of thread, other threads:[~2021-07-23  8:54 UTC | newest]

Thread overview: 175+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 15:22 [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Maxime Devos
2021-06-14 16:04 ` Maxime Devos
2021-06-18  7:55 ` Mathieu Othacehe
2021-06-18  8:01   ` Mathieu Othacehe
2021-06-18 12:32   ` Ludovic Courtès
2021-06-18 14:58   ` Maxime Devos
2021-06-18 16:09 ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 06/37] net-base: Don't cross-compile Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 14/37] wrap-python3: Fix cross-compilation Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 15/37] python: Fix reference to input when cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 16/37] openssl: Remove trailing #t from phases Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 24/37] readline: Fix build error when cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 26/37] bash: Fix cross-compilation build error Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 29/37] glib: Use a correct python in scripts " Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 34/37] libelf: Use the cross-compiler " Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
2021-06-18 16:09   ` [bug#49025] [[PATCH v2 core-updates] 37/37] meson: Support cross-compilation Maxime Devos
2021-06-18 16:18   ` [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate Maxime Devos
2021-06-18 17:15 ` [bug#49025] [PATCH v3 core-updates " Maxime Devos
2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 03/37] packages: Define this-package-input and this-package-native-input Maxime Devos
2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
2021-06-18 17:15   ` [bug#49025] [PATCH v3 core-updates 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 06/37] net-base: Don't cross-compile Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 14/37] wrap-python3: Fix cross-compilation Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 15/37] python: Fix reference to input when cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 16/37] openssl: Remove trailing #t from phases Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 24/37] readline: Fix build error when cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 26/37] bash: Fix cross-compilation build error Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 29/37] glib: Use a correct python in scripts " Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 33/37] tk: Do not use %build-inputs when cross-compiling Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 34/37] libelf: Use the cross-compiler " Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
2021-06-19  7:43     ` Maxime Devos
2021-06-18 17:16   ` [bug#49025] [PATCH v3 core-updates 37/37] meson: Support cross-compilation Maxime Devos
2021-06-19 15:04 ` [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 02/36] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 04/36] net-base: Make #:builder argument a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 05/36] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 06/36] net-base: Don't cross-compile Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 07/36] tzdata: Don't bother with cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 08/36] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 09/36] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 10/36] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 11/36] libgpg-error: Fix cross-compilation error Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 12/36] libgcrypt: Fix cross-compilation build error Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 13/36] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 14/36] wrap-python3: Fix cross-compilation Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 15/36] python: Fix reference to input when cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 16/36] openssl: Remove trailing #t from phases Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 17/36] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 18/36] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 19/36] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 20/36] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 21/36] openssl: Find bin/env when cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 22/36] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-07-03 15:47     ` Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 23/36] readline: Make #:configure-flags a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 24/36] readline: Fix build error when cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 25/36] bash: Make #:configure-flags a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 26/36] bash: Fix cross-compilation build error Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 27/36] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 28/36] fontconfig: Fix build error when cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 29/36] glib: Use a correct python in scripts " Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 30/36] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 31/36] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 32/36] tk: Make #:configure-flags a G-expression Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 33/36] tk: Do not use %build-inputs when cross-compiling Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 34/36] libelf: Use the cross-compiler " Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 35/36] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
2021-06-19 15:04   ` [bug#49025] [PATCH v4 core-updates 36/36] meson: Support cross-compilation Maxime Devos
2021-07-08 13:07   ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Mathieu Othacehe
2021-07-11 11:47 ` [bug#49025] [PATCH v5 00/20] Support cross-compilation with Meson Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 01/20] utils: Define target-linux? predicate Maxime Devos
2021-07-12 12:35     ` Mathieu Othacehe
2021-07-13 13:33       ` Maxime Devos
2021-07-14 10:46         ` Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 02/20] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 03/20] packages: Define this-package-input and this-package-native-input Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 04/20] net-base: Don't cross-compile Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 05/20] tzdata: Don't bother with cross-compiling Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 06/20] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 07/20] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 08/20] libgpg-error: Fix cross-compilation error Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 09/20] python: Fix reference to input when cross-compiling Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 10/20] openssl: Remove trailing #t from phases Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 11/20] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 12/20] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 13/20] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 14/20] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 15/20] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 16/20] glib: Use a correct python in scripts when cross-compiling Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 17/20] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 18/20] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 19/20] libelf: Update configure script and config.guess and config.sub Maxime Devos
2021-07-11 11:47   ` [bug#49025] [PATCH v5 20/20] meson: Support cross-compilation Maxime Devos
2021-07-12 12:42     ` Mathieu Othacehe
2021-07-13 13:36       ` Maxime Devos
2021-07-14 11:12 ` [bug#49025] [PATCH v6 00/22] Support cross-compilation with meson Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 01/22] utils: Define 'target-linux?' predicate Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 02/22] utils: Define 'target-hurd?' predicate Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 03/22] utils: Give 'target-mingw?' a docstring Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 04/22] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input Maxime Devos
2021-07-18 17:42     ` [bug#49025] [PATCH core-updates 00/37] Support cross-compilation with meson Ludovic Courtès
2021-07-19  9:40       ` Maxime Devos
2021-07-23  8:53         ` Ludovic Courtès
2021-07-14 11:12   ` [bug#49025] [PATCH v6 06/22] net-base: Don't cross-compile Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 07/22] tzdata: Don't bother with cross-compiling Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 08/22] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 09/22] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 10/22] libgpg-error: Fix cross-compilation error Maxime Devos
2021-07-14 11:22     ` Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 11/22] python: Fix reference to input when cross-compiling Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 12/22] openssl: Remove trailing #t from phases Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 13/22] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-07-14 11:12   ` [bug#49025] [PATCH v6 14/22] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 15/22] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 16/22] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 17/22] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 18/22] glib: Use a correct python in scripts when cross-compiling Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 19/22] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 20/22] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 21/22] libelf: Update configure script and config.guess and config.sub Maxime Devos
2021-07-14 11:13   ` [bug#49025] [PATCH v6 22/22] build-system/meson: Support cross-compilation Maxime Devos
2021-07-14 17:28     ` bug#49025: " Mathieu Othacehe

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.