Subject: bug#48759: closed (Re: bug#48759: [PATCH]: Replace '%build-inputs' with 'inputs' in some places and fix 'smalltalk' cross-compilation somewhat)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 04 Jun 2021 11:48:05 +0000

Your bug report

#48759: [PATCH]: Replace '%build-inputs' with 'inputs' in some places and fix 'smalltalk' cross-compilation somewhat

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
48759: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48759
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#48759: [PATCH]: Replace '%build-inputs' with 'inputs' in some places and fix 'smalltalk' cross-compilation somewhat
From: Mathieu Othacehe <[email-masked]>
To: Maxime Devos <[email-masked]>
Cc: [email-masked]
Date: Fri, 04 Jun 2021 13:46:58 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Maxime,

Pushed as 8190f5bb97be4696b7ab6a88ff8397d5a28299e8 to
f50a88c1fa2e07a668ee87402a5462267d1baf12.

Thanks,

Mathieu

Subject: [PATCH]: Replace '%build-inputs' with 'inputs' in some places and fix 'smalltalk' cross-compilation somewhat
From: Maxime Devos <[email-masked]>
To: [email-masked]
Date: Mon, 31 May 2021 14:30:31 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi guix,

Overview:
  (%build-inputs --> inputs, native-inputs)
  #1: gnu: ci: Use 'inputs' in build phases instead of '%build-inputs'.
  #2: gnu: smalltalk: Use 'inputs' in phases instead of '%build-inputs'.
  #3: gnu: neovim: Use 'inputs' in phases instead of '%build-inputs'.
  #4: gnu: qemacs: Use 'native-inputs' instead of '%build-inputs'.
  #5: gnu: ding: Use 'inputs' in build phases instead of '%build-inputs'.

  (more smalltalk fixes)
  #6: gnu: smalltalk: Move 'zip' from 'inputs' to 'native-inputs'.
  #7: gnu: smalltalk: Find glibc even when cross-compiling.

See patch descriptions for details.

This would cause 5 rebuilds:
  ./pre-inst-env guix refresh --list-dependents ding qemacs neovim smalltalk cuirass
  No dependents other than themselves: [email-masked] [email-masked] [email-masked] [email-masked] [email-masked]

Building succeeds:

  ./pre-inst-env guix build ding qemacs neovim smalltalk cuirass

Cross-compilation: somewhat improved

  # ding: ok, refers to binaries of correct architecture
  # qemacs: cannot cross-compile, because its dependency libxv
  #  tries to run a test program (even when cross-compiling)
  #  (during configuration, "checking whether malloc(0) returns NULL...")
  # neovim: cannot cross-compile, because its dependency "libtermkey" is not cross-compilable
  # cuirass: the meson build system does not support cross-compilaion
  # smalltalk: still some failures, even after patches (#6 and #7)
  #
  #  ./gst --no-user-files --kernel-dir "./kernel" --image gst.im -iQ /dev/null
  #  ./gst: line 117: /tmp/guix-build-smalltalk-3.2.91.drv-0/smalltalk-3.2.91/.libs/gst: cannot execute binary file: Exec format error
  #  ./gst: line 117: /tmp/guix-build-smalltalk-3.2.91.drv-0/smalltalk-3.2.91/.libs/gst: Success
  ./pre-inst-env guix build ding --target=aarch64-linux-gnu

Greetings,
Maxime.
From 303aa5a27188bdb2df534b4ca3f063125684a752 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 25 May 2021 15:20:34 +0200
Subject: [PATCH 1/7] gnu: ci: Use 'inputs' in build phases instead of
 '%build-inputs'.

In build phases, the former is preferred.

* gnu/packages/ci.scm
  (cuirass)[arguments]<#:phases>{wrap-program}: Use 'inputs'
  argument instead of '%build-inputs'.
---
 gnu/packages/ci.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/ci.scm b/gnu/packages/ci.scm
index c850d37b47..c85c3e5927 100644
--- a/gnu/packages/ci.scm
+++ b/gnu/packages/ci.scm
@@ -141,7 +141,7 @@
                       (guix   (assoc-ref inputs "guix"))
                       (deps   (list avahi gcrypt json zmq squee git bytes
                                     fibers zlib matd tls mail guix))
-                      (guile  (assoc-ref %build-inputs "guile"))
+                      (guile  (assoc-ref inputs "guile"))
                       (effective
                        (read-line
                         (open-pipe* OPEN_READ
-- 
2.31.1

From 336811809316cfa365a6a0f29f63eac5c737f187 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 25 May 2021 15:22:24 +0200
Subject: [PATCH 2/7] gnu: smalltalk: Use 'inputs' in phases instead of
 '%build-inputs'.

In build phases, the former is preferred.

* gnu/packages/smalltalk.scm
  (smalltalk)[arguments]<#:phases>{fix-libc}: Use 'inputs'
  argument instead of '%build-inputs'.
---
 gnu/packages/smalltalk.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/smalltalk.scm b/gnu/packages/smalltalk.scm
index ea1798ac13..a572570b13 100644
--- a/gnu/packages/smalltalk.scm
+++ b/gnu/packages/smalltalk.scm
@@ -102,8 +102,8 @@
                        (find-files "doc" "\\.info"))
              #t))
          (add-before 'configure 'fix-libc
-           (lambda _
-             (let ((libc (assoc-ref %build-inputs "libc")))
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((libc (assoc-ref inputs "libc")))
                (substitute* "libc.la.in"
                  (("@LIBC_SO_NAME@") "libc.so")
                  (("@LIBC_SO_DIR@")  (string-append libc "/lib"))))
-- 
2.31.1

From adb0d0483fbf0f51d038042afc7801069d25c6a3 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 25 May 2021 15:41:15 +0200
Subject: [PATCH 3/7] gnu: neovim: Use 'inputs' in phases instead of
 '%build-inputs'.

In build phases, the former is preferred.

* gnu/packages/vim.scm
  (neovim)[arguments]<#:phases>{set-lua-path}: Use 'inputs'
  argument instead of '%build-inputs'.
---
 gnu/packages/vim.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/vim.scm b/gnu/packages/vim.scm
index 47ac984fc7..24c51b84c3 100644
--- a/gnu/packages/vim.scm
+++ b/gnu/packages/vim.scm
@@ -657,7 +657,7 @@ are detected, the user is notified.")))
                      (lambda (prefix)
                        (let ((path (string-append prefix "/share/lua/" lua-version)))
                          (string-append path "/?.lua;" path "/?/?.lua"))))
-                    (lua-inputs (map (cute assoc-ref %build-inputs <>)
+                    (lua-inputs (map (cute assoc-ref inputs <>)
                                      '("lua"
                                        "lua-luv"
                                        "lua-lpeg"
-- 
2.31.1

From 5d7c38e0604d9df70b9dabab99f9ba8c3fd1ee39 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 25 May 2021 15:49:05 +0200
Subject: [PATCH 4/7] gnu: qemacs: Use 'native-inputs' instead of
 '%build-inputs'.

In build phases, the former (or 'inputs', as appropriate) is preferred.

* gnu/packages/text-editors.scm
  (qemacs)[arguments]<#:phases>{install-extra-documentation}: Use
  'native-inputs' argument instead of '%build-inputs'.
---
 gnu/packages/text-editors.scm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/text-editors.scm b/gnu/packages/text-editors.scm
index 47b6e93f29..f7e589e414 100644
--- a/gnu/packages/text-editors.scm
+++ b/gnu/packages/text-editors.scm
@@ -524,13 +524,14 @@ OpenBSD team.")
                #t)))
          (add-after 'install 'install-extra-documentation
            ;; Install sample configuration file, Info, and HTML manual.
-           (lambda* (#:key outputs #:allow-other-keys)
+           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
              (let* ((share (string-append (assoc-ref outputs "out") "/share"))
                     (doc (string-append share "/doc/" ,name "-" ,version))
                     (html (string-append share "/html"))
                     (info (string-append share "/info"))
-                    (makeinfo (string-append (assoc-ref %build-inputs "texinfo")
-                                             "/bin/makeinfo")))
+                    (makeinfo (string-append
+                               (assoc-ref (or native-inputs inputs) "texinfo")
+                               "/bin/makeinfo")))
                ;; First fix Texinfo documentation, create appropriate
                ;; directories, then generate Info and HTML files there.
                (substitute* "qe-doc.texi"
-- 
2.31.1

From 6162b2c51b3e2f084c3a536fd4f4cabbdca89d59 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 25 May 2021 15:58:33 +0200
Subject: [PATCH 5/7] gnu: ding: Use 'inputs' in build phases instead of
 '%build-inputs'.

In build phases, the former is preferred.

* gnu/packages/dictionaries.scm
  (ding)[arguments]<#:phases>{install}: Use 'inputs' argument instead
  of '%build-inputs'.
---
 gnu/packages/dictionaries.scm | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/dictionaries.scm b/gnu/packages/dictionaries.scm
index c4c377580c..db99f9d32f 100644
--- a/gnu/packages/dictionaries.scm
+++ b/gnu/packages/dictionaries.scm
@@ -175,11 +175,10 @@ work, such as sentence length and other readability measures.")
          (delete 'build)
          (delete 'check)
          (replace 'install
-           (lambda _
+           (lambda* (#:key inputs #:allow-other-keys)
              (let ((bindir (string-append
                             (assoc-ref %outputs "out") "/bin"))
-                   (wish (string-append
-                          (assoc-ref %build-inputs "tk")
+                   (wish (string-append (assoc-ref inputs "tk")
                           "/bin/wish8.6"))
                    (sharedir (string-append
                               (assoc-ref %outputs "out")
-- 
2.31.1

From 008c8e429d6707139d2f67360e01348e2fa16b9d Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Mon, 31 May 2021 13:54:17 +0200
Subject: [PATCH 6/7] gnu: smalltalk: Move 'zip' from 'inputs' to
 'native-inputs'.

The 'zip' package is not in the references of 'smalltalk'.
As such, it probably should be a native input, not a regular
input. This can be confirmed by trying to cross-compile
the 'smalltalk' package, without this commit. The configure
script will ask to install InfoZIP.

* gnu/packages/smalltalk.scm
  (smalltalk)[inputs]{zip}: Move to ...
  (smalltalk)[native-inputs]{zip} ... here.
---
 gnu/packages/smalltalk.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/smalltalk.scm b/gnu/packages/smalltalk.scm
index a572570b13..af4b7642ff 100644
--- a/gnu/packages/smalltalk.scm
+++ b/gnu/packages/smalltalk.scm
@@ -64,7 +64,8 @@
        ;; XXX: To be removed with the next release of Smalltalk.
        ("autoconf" ,autoconf)
        ("automake" ,automake)
-       ("libtool" ,libtool)))
+       ("libtool" ,libtool)
+       ("zip" ,zip)))
     ;; TODO: These optional dependencies raise the closure size to ~1 GiB
     ;; from the current ~100 MiB, although some of them might be very
     ;; useful for end users:
@@ -81,8 +82,7 @@
        ("libffi" ,libffi)
        ("libltdl" ,libltdl)
        ("libsigsegv" ,libsigsegv)
-       ("lightning" ,lightning)
-       ("zip" ,zip)))
+       ("lightning" ,lightning)))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-- 
2.31.1

From dcd7d16b8b89defcedefb4b8a71977d376d04273 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Mon, 31 May 2021 14:07:50 +0200
Subject: [PATCH 7/7] gnu: smalltalk: Find glibc even when cross-compiling.

Curiously, glibc is named "cross-libc" instead of "libc"
when cross-compiling. I don't know why. Anyway, here
is a fix. Smalltalk still fails to cross-compile though.

* gnu/packages/smalltalk.scm
  (smalltalk)[arguments]{phases}<#:fix-libc>: Also search for
  "cross-libc" instead of only "libc" in 'inputs'.
---
 gnu/packages/smalltalk.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/smalltalk.scm b/gnu/packages/smalltalk.scm
index af4b7642ff..20ecc19881 100644
--- a/gnu/packages/smalltalk.scm
+++ b/gnu/packages/smalltalk.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2016 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <[email-masked]>
+;;; Copyright © 2021 Maxime Devos <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -103,7 +104,11 @@
              #t))
          (add-before 'configure 'fix-libc
            (lambda* (#:key inputs #:allow-other-keys)
-             (let ((libc (assoc-ref inputs "libc")))
+             (let ((libc (or (assoc-ref inputs "libc")
+                             ;; When cross-compiling, the input
+                             ;; is named "cross-libc" instead of
+                             ;; simply "libc". I don't know why.
+                             (assoc-ref inputs "cross-libc"))))
                (substitute* "libc.la.in"
                  (("@LIBC_SO_NAME@") "libc.so")
                  (("@LIBC_SO_DIR@")  (string-append libc "/lib"))))
-- 
2.31.1