Subject: Re: bug#47908: Cross building disk image for ARM Asus C201 fails

From: Maxime Devos <[email-masked]>
Date: Tue, 20 Apr 2021 21:23:17 +0200

Martin via Bug reports for GNU Guix schreef op di 20-04-2021 om 11:37 [+0000]:
> Hello,
> I'm trying to create a disk image for an Asus C201 chromebook using the 
> command 'guix system image test.scm' where test.scm based on 
> https://github.com/guix-mirror/guix/blob/master/gnu/system/examples/asus-c201.tmpl 
> but unfortunately this operation fails on my x86 dev machine (guix 53ed3e4):
> 
> ---
> [...]
> View build log at 
> '/var/log/guix/drvs/z2/diqxmpr8zkiyk2d5vma4flwvd3bzk6-vboot-utils-R63-10032.B.drv.bz2'.
> guix system: error: build of 
> `/gnu/store/z2diqxmpr8zkiyk2d5vma4flwvd3bzk6-vboot-utils-R63-10032.B.drv' 
> failed
> ---
> 
> the logs:
> [...]
> In unknown file:
>             2 (string-append #f "/bin/cmp")
> In ice-9/boot-9.scm:
>    1669:16  1 (raise-exception _ #:continuable? _)
>    1669:16  0 (raise-exception _ #:continuable? _)
> 
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> In procedure string-append: Wrong type (expecting string): #f
> ---

> Any ideas how to fix it

Some issues I see in the definition of the "vboot-utils" package:

    (arguments
     `(#:make-flags (list "CC=gcc"
                          ;; On ARM, we must pass "HOST_ARCH=arm" so that the

The "CC=gcc" should be ,(string-append "CC=" (cc-for-target)), such that the
cross-compiler is used.  (cc-for-target) also works when not cross-compiling.

                    (lambda* (#:key inputs outputs #:allow-other-keys)
                      (let ((coreutils (assoc-ref inputs "coreutils"))
                            (diffutils (assoc-ref inputs "diffutils")))
                    [...]
                        (substitute* "tests/bitmaps/TestBmpBlock.py"
                          (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))

"diffutils" should be looked up in 'native-inputs', not 'inputs', as "cmp" is run
when building the package.  (And not when this package is actually used at run-time).

So that should be

                    (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
                      (let ((coreutils (assoc-ref inputs "coreutils"))
                            (diffutils (assoc-
ref (or native-inputs inputs) "diffutils")))
                    [...]
                        (substitute* "tests/bitmaps/TestBmpBlock.py"
                          (("/usr/bin/cmp") (string-append
diffutils "/bin/cmp")))

p.s.  I began replacing "CC=gcc" with ,(string-append "CC=" (cc-for-target)) where it seemed
necessary in the patch series at <https://issues.guix.gnu.org/47693>

Greetings,
Maxime.