Subject: [bug#55343] [PATCH 2/2] image: Add new efi32-raw format for 32bit UEFI on 64bit systems

From: Denis 'GNUtoo' Carikli <[email-masked]>
Date: Wed, 11 May 2022 19:00:23 +0200

Hi,

On Tue, 10 May 2022 11:32:52 +0200
Maxime Devos <[email-masked]> wrote:
>   (list #:target "i386")

I've tried that I get the following error:
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> dynamic linker name not known for this system "i386"

This means that I have to use "i686-linux" because only "i686-linux" is
in the list of allowed values.

I've tried and this adds a cross toolchain to the list of
dependencies[1] and this doesn't work because efibootmgr which is a
dependency doesn't compile anymore as it doesn't find some of the
headers like efivar.h and efiboot.h. This could probably be fixed
somehow though.

In addition I've found the following issues with that approach:
- It hardcode the kernel (Linux or HURD) so we'd probably
  need extra logic to handle it well. With --target=i386 that is
  transparent. Note that I didn't test grub-efi32 with HURD in either
  cases.

- It doesn't support "canadian" cross compilation where the builder
  (for instance x86) builds a cross compiler to run on another
  architecture (for instance ARM) to then compile programs for another
  architecture (for instance riscv). With --target=i386 we can in
  theory do that (though I've not tested it).

And with it, I see the following advantage: since it's wrapped somehow
Guix can probably do things automatically (like checks or change
things) on all the packages that are cross compiled.

What approach do you think is best (I don't know the implementation of
(list #:target "i686-linux") so you probably know way better than me
which one is the best) ?.

If (list #:target "i686-linux") is the way to go, do you have any
pointers to make it find the headers it needs? I've attached its build
log in case it is useful.

References:
-----------
[1] Here's the output when trying to build grub-efi32 with
    (list #:target "i686-linux"):
> $ ./pre-inst-env guix package -i grub-efi32
> The following package will be upgraded:
>    grub-efi32 (dependencies or package changed)
> 
> The following derivations will be built:
>   /gnu/store/j4divh7pf1bxr11ivzddqhsihan6ij4p-util-linux-2.37.2.drv
>   /gnu/store/h86glf6qlyfmf214qj6xsqbj8vmrfss9-zlib-1.2.11.drv
>   /gnu/store/hy4x62rrx3gqdnn476dja6im74pxzkpk-glibc-cross-i686-linux-2.33.drv
>   /gnu/store/1qynvffnfnf7dlzmrkrkx7nzxq6mkz1k-gcc-cross-sans-libc-i686-linux-10.3.0.drv
>   /gnu/store/kyr74wyvikyldkx9a0zd55fmxjs6862c-binutils-cross-i686-linux-2.37.drv
>   /gnu/store/wc7zhlgnzrg9z5w5wqyvkwlg0ninavs1-ld-wrapper-i686-linux-0.drv
>   /gnu/store/i4h82qxwyaj3i97rgcvh6khfibbj4x3p-linux-libre-headers-cross-i686-linux-5.10.35.drv
>   /gnu/store/j4w5c2iqvm9ylfnc2gsadipngl00labp-gcc-cross-i686-linux-10.3.0.drv
>   /gnu/store/y15y0pici7yhgycjv13a4hm9jjshdzzm-ncurses-6.2.20210619.drv
>   /gnu/store/l5jdw7k9mdm0af4gyklhixw447fgsnxn-pkg-config-i686-linux-0.29.2.drv
>   /gnu/store/zg2fyiwc4i4vwarbk8imi9wsgzp8z90h-file-5.39.drv

Denis.