Subject: [PATCH 0/3] Use native qemu to build vm-image.
From: Jan Nieuwenhuizen <[email-masked]>
To: [email-masked]
Date: Sun, 17 May 2020 12:01:10 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi!

Cross-building a vm-image used to be done using a cross-qemu, e.g, qemu-ARM.
That does not work for the Hurd, as there is no qemu-HURD.

This patch switches to cross building vm-images using a native qemu vm.  If
there a reason for using qemu-TARGET we may want to make this switch
conditional for cross building to the Hurd?

There is a tricky aspect to this: the "user-builder" includes all the
cross-built packages for TARGET, but we need to hard the native qemu a
native #+LOADER, loading native #+LINUX and #+INITRD.

To accomplish this NATIVE/CROSS mixt, the builder is then run with a native
guile, like so

--8<---------------cut here---------------start------------->8---
(system* #+(file-append (default-guile) "/bin/guile")
         "--no-auto-compile"
         #$(preserve-target user-builder))
--8<---------------cut here---------------end--------------->8---

while the packages in USER-BUILDER will still be cross-built.  However,
because the builder has

    (with-extensions gcrypt-sqlite3&co
         (use-modules (gnu store database))
      ...)

this makes the native guile "see" the cross-built .GO files.  That would
"only" be a secondary problem except that loading (sqlite3) throws an
exception when dynamic-loading the .SO fails.  Seeing it like this I am not so
sure anymore this is a bug, WDYT?  ...so instead

...the problem is now avoided by removing the sqlite dependency when
cross-building by not registering closures and postponing the loading of (gnu
store database) and thus (sqlite3).

I have reset wip-hurd-vm onto these changes, so you can also look there.
Doing

    ./pre-inst-env guix system vm-image --target=i586-pc-gnu --no-grafts \
        gnu/system/examples/bare-hurd.tmpl

now produces a pretty nice hurd VM :-)

Greetings,
Janneke

Jan (janneke) Nieuwenhuizen (3):
  utils: Move 'reset-timestamps' out of database.
  system: vm: Do not register-closures when cross-building.
  system: vm: Build vm-image using native qemu.

 gnu/bootloader/grub.scm |  4 +--
 gnu/build/vm.scm        |  3 ++-
 gnu/system/vm.scm       | 54 ++++++++++++++++++++++++++---------------
 guix/store/database.scm | 41 +++----------------------------
 guix/utils.scm          | 41 ++++++++++++++++++++++++++++---
 5 files changed, 79 insertions(+), 64 deletions(-)

-- 
2.26.0

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