guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#58576] [PATCH] system: image: Define correct docker image arch when


From: Thiago Jung Bauermann
Subject: [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@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]