Subject: bug#40574: closed (Re: bug#40574: [wip-hurd-vm]: cross-build of `guix' fails)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 23 Apr 2020 22:15:02 +0000

Your bug report

#40574: [wip-hurd-vm]: cross-build of `guix' fails

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

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

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

Subject: Re: bug#40574: [wip-hurd-vm]: cross-build of `guix' fails
From: Ludovic Courtès <[email-masked]>
To: Jan Nieuwenhuizen <[email-masked]>
Cc: [email-masked]
Date: Fri, 24 Apr 2020 00:14:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

Ludovic Courtès <[email-masked]> skribis:

> (A good opportunity to learn about THAANA LETTER RAA!
> <https://en.wikipedia.org/wiki/Thaana#Alphabet>)

I believe these commits on ‘master’ solve remaining cross-compilation
issues:

  62bc3c5b04 build: Don't build man pages when cross-compiling.
  12da5162e4 compile: Pre-load the compiler outside 'with-target'.

The way I tested it is by running this command from current
‘core-updates’:

  guix build --target=i586-pc-gnu guix --with-branch=guix=master

There’s another thing that needs to be done: in the ‘guix’ package, the
‘copy-bootstrap-guile’ phase must be skipped when cross-compiling (it’s
useless since tests aren’t run and it crashes).

When these commits are cherry-picked or merged on ‘core-updates’,
someone can run “make update-guix-package” there and it should be all
fine.

I’m optimistically closing the bug, but let me know if I was
over-optimistic!  :-)

Ludo’.

Subject: [wip-hurd-vm]: cross-build of `guix' fails
From: Jan Nieuwenhuizen <[email-masked]>
To: [email-masked]
Date: Sun, 12 Apr 2020 16:03:05 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Ludo',

As discussed on IRC: current wip-hurd-vm
c757307ed5aa563225e1ab880681006fe42fce62 contains all preperations
necessary to cross-build `guix' itself (and add it to the hurd system).

However, running

    ./pre-inst-env guix build --target=i586-pc-gnu

fails with (full log attached)

--8<---------------cut here---------------start------------->8---
[ 14%] LOAD     gnu/bootloader/depthcharge.scm
[ 14%] LOAD     gnu/ci.scm
WARNING: Use of `load' in declarative module (guix ui).  Add #:declarative? #f to your define-module invocation.
WARNING: (guix build emacs-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build ant-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build download-nar): `dump-port*' imported from both (guix serialization) and (guix progress)
WARNING: (guix build cargo-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build cmake-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build dub-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build ocaml-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build dune-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build meson-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build minify-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build font-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build go-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build asdf-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build copy-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build gnu-dist): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build guile-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build node-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build perl-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build python-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build r-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build rakudo-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build ruby-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build scons-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build texlive-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build waf-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build haskell-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: (guix build julia-build-system): imported module (guix build utils) overrides core binding `delete'
WARNING: Use of `load' in declarative module (guix scripts repl).  Add #:declarative? #f to your define-module invocation.
;;; Failed to autoload make-page-map in (charting):
;;; no code for module (charting)
;;; Failed to autoload make-page-map in (charting):
;;; no code for module (charting)
WARNING: Use of `load' in declarative module (gnu system install).  Add #:declarative? #f to your define-module invocation.
error: failed to load 'gnu/system/install.scm': No such file or directory
make[2]: *** [Makefile:5887: make-go] Error 1
make[2]: Leaving directory '/tmp/guix-build-guix-1.0.1-16.0c53d35.drv-0/source'
make[1]: *** [Makefile:4952: all-recursive] Error 1
make[1]: Leaving directory '/tmp/guix-build-guix-1.0.1-16.0c53d35.drv-0/source'
make: *** [Makefile:3373: all] Error 2
command "make" "-j" "8" failed with status 2
--8<---------------cut here---------------end--------------->8---

What I found that when entering a cross-build environment that created by

    ./pre-inst-env guix build --target=i586-pc-gnu guix --keep-failed --no-offload

doing

    GUILE_LOAD_COMPILED_PATH= guild compile --target=i586-pc-gnu -L . gnu/ci.scm -o foo.go
    GUILE_LOAD_COMPILED_PATH= guild compile --target=i586-pc-gnu -L . gnu/tests/install.scm -o bar.go

gives something like

--8<---------------cut here---------------start------------->8---
WARNING: Use of `load' in declarative module (guix ui).  Add #:declarative? #f to your define-module invocation.
WARNING: (guix build emacs-build-system): imported module (guix build utils) overrides core binding `delete'
Backtrace:
In ice-9/boot-9.scm:
  3297:17 19 (resolve-interface (gnu system install) #:select _ #:hide _ #:prefix _ #:renamer _ #:version _)
In ice-9/threads.scm:
    390:8 18 (_ _)
In ice-9/boot-9.scm:
  3223:13 17 (_)
In ice-9/threads.scm:
    390:8 16 (_ _)
In ice-9/boot-9.scm:
  3507:20 15 (_)
   2806:4 14 (save-module-excursion #<procedure 7f6220dc7cc0 at ice-9/boot-9.scm:3508:21 ()>)
  3527:26 13 (_)
In unknown file:
          12 (primitive-load-path "gnu/system/install" #<procedure 7f622318f7c0 at ice-9/boot-9.scm:3514:37 ()>)
In ice-9/eval.scm:
   626:19 11 (_ #<directory (gnu system install) 7f6229b65780>)
   173:47 10 (_ #(#(#<directory (gnu system install) 7f6229b65780> #<<plain-file> name: "motd" content: "…>) …))
   196:43  9 (_ #(#(#<directory (gnu system install) 7f6229b65780> #<<plain-file> name: "motd" content: "…>) …))
   293:34  8 (_ #(#(#(#<directory (gnu system install) 7f6229b65780> #<<plain-file> name: "motd" conte…>) …) #))
    619:8  7 (_ #(#(#(#<directory (gnu installer) 7f62248f3dc0>)) #<variable 7f621d5d75b0 value: #<gexp (be…> …))
   626:19  6 (_ #(#(#(#<directory (gnu installer) 7f62248f3dc0>)) #<variable 7f621d5d75b0 value: #<gexp (be…> …))
    159:9  5 (_ #(#(#(#<directory (guix discovery) 7f62339ee280>) "/tmp/guix-build-guix-1.0.1-18.11fc384…" …) …))
In srfi/srfi-1.scm:
   495:18  4 (fold-right #<procedure 7f621d786ca0 at ice-9/eval.scm:336:13 (a b)> () _ . _)
In ice-9/eval.scm:
   293:34  3 (_ #(#(#(#(#(#(#(#<directory (guix discovery) 7f62339ee280> ("~^m\x18 " (. #) …) …)) …) …) …) …) …))
    155:9  2 (_ #(#(#(#(#<directory (guix discovery) 7f62339ee280>) "/tmp/guix-build-guix-1.0.1-18.11…" …) …) …))
In unknown file:
           1 (lstat "/tmp/guix-build-guix-1.0.1-18.11fc384.drv-0/source/gnu/../gnu/installer/~^m\x18 ")
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure lstat: No such file or directory: "/tmp/guix-build-guix-1.0.1-18.11fc384.drv-0/source/gnu/../gnu/installer/~^m\x18 "
--8<---------------cut here---------------end--------------->8---

That inspired me to add this substitution to the guix cross build recipe

--8<---------------cut here---------------start------------->8---
gnu: guix: Avoid loading (gnu installer) when cross compiling.

* gnu/packages/package-management.scm (guix)[arguments]: When cross-compiling,
add `disable-loading-gnu-installer' stage.

1 file changed, 9 insertions(+), 1 deletion(-)
gnu/packages/package-management.scm | 10 +++++++++-

modified   gnu/packages/package-management.scm
@@ -216,7 +216,15 @@ $(prefix)/etc/init.d\n")))
                                      (string-append gzip "/bin/gzip"))
                                     (("/gnu/store/.*/xz")
                                      (string-append xz "/bin/xz")))
-                                  #t))))
+                                  #t)))
+                            ;; XXX Avoid: In procedure lstat: No such file or directory: ".../source/gnu/../gnu/installer/~^m\x18 "
+                            (add-before 'build 'disable-loading-gnu-installer
+                              (lambda _
+                                  (substitute* "gnu/system/install.scm"
+                                    (("#:use-module \\(gnu installer\\)" all)
+                                     (string-append ";;" all))
+                                    (("\\(installer-program\\)" all)
+                                     (string-append "'" all))))))
                           '())
                     (add-before 'check 'copy-bootstrap-guile
                       (lambda* (#:key system inputs #:allow-other-keys)

--8<---------------cut here---------------end--------------->8---

because it will allow the manual guild invocations to succeed.  However,
the cross build still fails (or creates 64-bit .go files) unless I revert

    a05ad01122 records: Have ABI check work well for cross-compilation.
    041c3c22dc compile: Run the load phase within 'with-target'.

and instead, use the prior hack

--8<---------------cut here---------------start------------->8---
ce136711e0 REMOVEME gnu: guix: Bugfix for cross compiling to the Hurd.

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 7165edf5d2..66c71a3fa5 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -226,6 +226,16 @@ $(prefix)/etc/init.d\n")))
                                     (("\\(installer-program\\)" all)
                                      (string-append "'" all))))))
                           '())
+                    ,@(if (hurd-target?)
+                          ;; (with-target "i586-pc-gnu" target-most-positive-fixnum)
+                          ;;   => 2305843009213693951
+                          `((add-before 'build 'patch-guix/records.scm
+                              (lambda _
+                                (substitute* "guix/records.scm"
+                                  ((" most-positive-fixnum")
+                                   " 536870911"))
+                                #t)))
+                          '())
                     (add-before 'check 'copy-bootstrap-guile
                       (lambda* (#:key system inputs #:allow-other-keys)
                         ;; Copy the bootstrap guile tarball in the store used

--8<---------------cut here---------------end--------------->8---

Greetings,
janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com