Subject: Re: [bug#36477] [PATCH v3 46/48] system: vm: Support cross-compilation.

From: Ludovic Courtès <[email-masked]>
Date: Wed, 04 Sep 2019 14:46:35 +0200

Mathieu Othacehe <[email-masked]> skribis:

> * gnu/system.scm (system-linux-image-file-name): Add support for cross-built
> systems. Remove system argument that was ignored,
> (operating-system-kernel-file): adapt by removing ignored os argument.
> * gnu/system/vm.scm (expression->derivation-in-linux-vm): Add target argument,
> move qemu from inputs list to a new native-inputs list and adapt
> set-path-environment-variable call accordingly. Pass target to qemu-command
> and gexp->derivation calls.
> (iso9660-image): Move qemu from inputs to a new native-inputs list and adapt
> set-path-environment-variable accordingly.
> (qemu-image): Add target argument, move qemu from inputs list to a new
> native-inputs list and adapt set-path-environment-variable call
> accordingly. Pass target argument to expression->derivation-in-linux-vm call.

[...]

>  (define (operating-system-kernel-file os)
>    "Return an object representing the absolute file name of the kernel image of
>  OS."
>    (file-append (operating-system-kernel os)
> -               "/" (system-linux-image-file-name os)))
> +               "/" (system-linux-image-file-name)))

Uh, passing ‘os’ to ‘system-linux-image-file-name’ never worked, right?

[...]

> -              (let* ((inputs  '#$(list qemu (canonical-package coreutils)))
> +              (let* ((inputs  '#$(list (canonical-package coreutils)))
> +                     (native-inputs '#+(list qemu))

All these inputs are added to $PATH just after, which shows that we run
them natively.  Thus, they must all be native.

IOW, all we have to do is replace #$ by #+.

(Also, make sure to test all this without a qemu-binfmt service set up.)

>             (let ((inputs
> -                  '#$(append (list qemu parted e2fsprogs dosfstools xorriso)
> +                  '#$(append (list parted e2fsprogs dosfstools xorriso)
>                               (map canonical-package
>                                    (list sed grep coreutils findutils gawk))))
> +                 (native-inputs '#+(list qemu))

Same here: this is added to $PATH so it must be native.

>             (let ((inputs
> -                  '#$(append (list qemu parted e2fsprogs dosfstools)
> +                  '#$(append (list util-linux parted e2fsprogs dosfstools)
>                               (map canonical-package
>                                    (list sed grep coreutils findutils gawk))))
> +                 (native-inputs '#+(list qemu))

Likewise.

Thanks,
Ludo’.