GNU bug report logs - #58576
[PATCH] system: image: Define correct docker image arch when cross building

Previous Next

Package: guix-patches;

Reported by: Thiago Jung Bauermann <bauermann <at> kolabnow.com>

Date: Mon, 17 Oct 2022 01:30:02 UTC

Severity: normal

Tags: moreinfo, patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 58576 <at> debbugs.gnu.org (full text, mbox):

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: Thiago Jung Bauermann <thiago.bauermann <at> linaro.org>, 58576 <at> debbugs.gnu.org
Subject: Re: bug#58576: [PATCH] system: image: Define correct docker image
 arch when cross building
Date: Wed, 26 Oct 2022 20:47:15 -0300
Hello Mathieu,

Thank you for reviewing my patch! Sorry for the delay, I've been
traveling.

Mathieu Othacehe <othacehe <at> gnu.org> writes:

> Hello Thiago,
>
> Thanks for this patch!
>
>> +         (image-target (or (%current-target-system)
>> +                           (and=> (image-platform image) platform-target)
>> +                           (nix-system->gnu-triplet)))
>
> There's the following snippet in "system-image" that is trying to do the
> right thing (and it is not easy) with the "target" value.
>
>   ;; The image platform definition may provide the appropriate "system"
>   ;; architecture for the image.  If we are already running on this system,
>   ;; the image can be built natively.  If we are running on a different
>   ;; system, then we need to cross-compile, using the "target" provided by the
>   ;; image definition.
>   (define system (and=> platform platform-system))
>   (define target (cond
>                   ;; No defined platform, let's use the user defined
>                   ;; system/target parameters.
>                   ((not platform)
>                    (%current-target-system))
>                   ;; The current system is the same as the platform system, no
>                   ;; need to cross-compile.
>                   ((and system
>                         (string=? system (%current-system)))
>                    #f)
>                   ;; If there is a user defined target let's override the
>                   ;; platform target. Otherwise, we can cross-compile to the
>                   ;; platform target.
>                   (else
>                    (or (%current-target-system)
>                        (and=> platform platform-target)))))
>
> The rationale is that the user supplied %current-target-system is always
> overriding the image platform field. Then, %current-target-system is set
> to the "target" value defined above.
>
> It makes me think that you could use %current-target-system directly as
> the "image-target" value. WDYT?

I don't think “%current-target-system” can be used directly as the
“image-target” value because for native builds it will be #f and my
understanding is that “build-docker-image” would throw an error when
receiving #f for the “#:system” argument.

So I still need the or expression above, but I can drop the middle
expression that calls “platform-target” because it's redundant with the
snippet you posted above. Thank you for pointing it out.

I'll send a v2 with the change.

-- 
Thanks
Thiago




This bug report was last modified 2 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.