Cross-compiling glib failure

  • Done
  • quality assurance status badge
Details
4 participants
  • L p R n d n
  • Ludovic Courtès
  • Maxim Cournoyer
  • Maxime Devos
Owner
unassigned
Submitted by
L p R n d n
Severity
normal
L
L
L p R n d n wrote on 17 Dec 2021 13:51
(address . bug-guix@gnu.org)
87k0g3fl7c.fsf@lprndn.info
Hello guix,

Trying to cross-compile glib to aarch64with:

guix build --target=aarch64-linux-gnu glib

I get this error:

`Unbound variable: %outputs

I suppose the glib’s definition needs to be adapted to Guix’s new style
which was merged a few days ago?

Thanks,

L p R n d n
M
M
Maxime Devos wrote on 17 Dec 2021 22:40
befb94870e8bf96380d1ee690e0c36912e90b327.camel@telenet.be
L p R n d n schreef op vr 17-12-2021 om 12:51 [+0000]:
Toggle quote (16 lines)
>
> Hello guix,
>
> Trying to cross-compile glib to aarch64with:
>
> guix build --target=aarch64-linux-gnu glib
>
> I get this error:
>
> `Unbound variable: %outputs
>
> I suppose the glib’s definition needs to be adapted to Guix’s new
> style
> which was merged a few days ago?
>

Actually, glib's build system (meson-build-system) did not support
cross-compilation at all before the merge. Cross-compilation support
was added on that branch, but glib's package broke later, presumably in

The fix would be to replace to wrap the configure flags in a #~,
instead of a ´,replace (assoc-ref %outputs "bin") by #$output:bin and
adjust the configure flags of glib-with-documentation to use #~ and #$
instead of ´ and ,.

To avoid rebuilds, some
(if (%current-target-system) #~#$output:bin #~(assoc-ref %outputs
"bin"))
may be needed.

Greetings,
Maxime.
M
M
Maxim Cournoyer wrote on 18 Dec 2021 05:34
(name . Maxime Devos)(address . maximedevos@telenet.be)
87r1aa4jko.fsf@gmail.com
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (32 lines)
> L p R n d n schreef op vr 17-12-2021 om 12:51 [+0000]:
>>
>> Hello guix,
>>
>> Trying to cross-compile glib to aarch64with:
>>
>> guix build --target=aarch64-linux-gnu glib
>>
>> I get this error:
>>
>> `Unbound variable: %outputs
>>
>> I suppose the glib’s definition needs to be adapted to Guix’s new
>> style
>> which was merged a few days ago?
>>
>
> Actually, glib's build system (meson-build-system) did not support
> cross-compilation at all before the merge. Cross-compilation support
> was added on that branch, but glib's package broke later, presumably in
> <https://git.savannah.gnu.org/cgit/guix.git/commit/?id=f22f6fc3b6cc6382df3246d192a40a3951b48c37>.
>
> The fix would be to replace to wrap the configure flags in a #~,
> instead of a ´,replace (assoc-ref %outputs "bin") by #$output:bin and
> adjust the configure flags of glib-with-documentation to use #~ and #$
> instead of ´ and ,.
>
> To avoid rebuilds, some
> (if (%current-target-system) #~#$output:bin #~(assoc-ref %outputs
> "bin"))
> may be needed.

Thanks for the hints. I'm trying the following fix on my (local for
now) version-1.4.0 branch:

Toggle snippet (32 lines)
modified gnu/packages/glib.scm
@@ -212,12 +212,11 @@ (define glib
`(,(this-package-native-input "python")
,(this-package-native-input "python-wrapper")))
'()))
- #:configure-flags (list "--default-library=both"
- "-Dman=false"
- "-Dselinux=disabled"
- (string-append "--bindir="
- (assoc-ref %outputs "bin")
- "/bin"))
+ #:configure-flags #~(list "--default-library=both"
+ "-Dman=false"
+ "-Dselinux=disabled"
+ (string-append "--bindir="
+ #$output:bin "/bin"))
#:phases
(modify-phases %standard-phases
;; Needed to pass the test phase on slower ARM and i686 machines.
@@ -365,8 +364,8 @@ (define-public glib-with-documentation
(arguments
(substitute-keyword-arguments (package-arguments glib)
((#:configure-flags flags ''())
- `(cons "-Dgtk_doc=true"
- (delete "-Dman=false" ,flags)))
+ #~(cons "-Dgtk_doc=true"
+ (delete "-Dman=false" #$flags)))
((#:phases phases)
`(modify-phases ,phases
(add-after 'unpack 'patch-docbook-xml

Thanks,

Maxim
L
L
Ludovic Courtès wrote on 19 Dec 2021 23:12
(name . Maxime Devos)(address . maximedevos@telenet.be)
87sfuomefw.fsf@gnu.org
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (15 lines)
> Actually, glib's build system (meson-build-system) did not support
> cross-compilation at all before the merge. Cross-compilation support
> was added on that branch, but glib's package broke later, presumably in
> <https://git.savannah.gnu.org/cgit/guix.git/commit/?id=f22f6fc3b6cc6382df3246d192a40a3951b48c37>.
>
> The fix would be to replace to wrap the configure flags in a #~,
> instead of a ´,replace (assoc-ref %outputs "bin") by #$output:bin and
> adjust the configure flags of glib-with-documentation to use #~ and #$
> instead of ´ and ,.
>
> To avoid rebuilds, some
> (if (%current-target-system) #~#$output:bin #~(assoc-ref %outputs
> "bin"))
> may be needed.

In the case of ‘meson-build-system’, the logical fix IMO would be to
define ‘%build-inputs‘, ‘%outputs’, etc. when cross-compiling, with the
patch below.

This would be consistent with the fact that ‘meson-build-system’ defines
those variables for native builds already.

Thoughts?

Longer-term we can move away from ‘%outputs’, ‘%build-inputs’, & co.,
but that’s another story.

Ludo’.
Toggle diff (24 lines)
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index ba7441a3eb..ad604f8871 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -287,6 +287,19 @@ (define builder
#~(begin
(use-modules #$@(sexp->gexp modules))
+ (define %build-host-inputs
+ #+(input-tuples->gexp build-inputs))
+
+ (define %build-target-inputs
+ (append #$(input-tuples->gexp host-inputs)
+ #+(input-tuples->gexp target-inputs)))
+
+ (define %build-inputs
+ (append %build-host-inputs %build-target-inputs))
+
+ (define %outputs
+ #$(outputs->gexp outputs))
+
(define build-phases
#$(let ((phases (if (pair? phases) (sexp->gexp phases) phases)))
(if glib-or-gtk?
M
M
Maxim Cournoyer wrote on 20 Dec 2021 05:55
(name . Ludovic Courtès)(address . ludo@gnu.org)
87fsqn3mer.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (31 lines)
> Hi,
>
> Maxime Devos <maximedevos@telenet.be> skribis:
>
>> Actually, glib's build system (meson-build-system) did not support
>> cross-compilation at all before the merge. Cross-compilation support
>> was added on that branch, but glib's package broke later, presumably in
>> <https://git.savannah.gnu.org/cgit/guix.git/commit/?id=f22f6fc3b6cc6382df3246d192a40a3951b48c37>.
>>
>> The fix would be to replace to wrap the configure flags in a #~,
>> instead of a ´,replace (assoc-ref %outputs "bin") by #$output:bin and
>> adjust the configure flags of glib-with-documentation to use #~ and #$
>> instead of ´ and ,.
>>
>> To avoid rebuilds, some
>> (if (%current-target-system) #~#$output:bin #~(assoc-ref %outputs
>> "bin"))
>> may be needed.
>
> In the case of ‘meson-build-system’, the logical fix IMO would be to
> define ‘%build-inputs‘, ‘%outputs’, etc. when cross-compiling, with the
> patch below.
>
> This would be consistent with the fact that ‘meson-build-system’ defines
> those variables for native builds already.
>
> Thoughts?
>
> Longer-term we can move away from ‘%outputs’, ‘%build-inputs’, & co.,
> but that’s another story.

Seems the proper fix; I'm just wondering; could there be other build
systems that were overlooked needing the same fix? If so, we should fix
them now too.
L
L
Ludovic Courtès wrote on 21 Dec 2021 10:04
(name . Maxime Devos)(address . maximedevos@telenet.be)
87k0fyba78.fsf@gnu.org
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (7 lines)
> When compiling natively, we have the convenient 'with-build-variables'
> procedure. Maybe we can have a 'with-cross-build-variables' for when
> cross-compiling?
>
> That could be used in the 'gnu', etc. build systems as well, reducing
> some duplication between build systems.

Yes, that’s a good idea.

Ludo’.
M
M
Maxim Cournoyer wrote on 17 Jan 2022 18:14
(name . Ludovic Courtès)(address . ludo@gnu.org)
87pmoqi8t1.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (13 lines)
> Hi,
>
> Maxime Devos <maximedevos@telenet.be> skribis:
>
>> When compiling natively, we have the convenient 'with-build-variables'
>> procedure. Maybe we can have a 'with-cross-build-variables' for when
>> cross-compiling?
>>
>> That could be used in the 'gnu', etc. build systems as well, reducing
>> some duplication between build systems.
>
> Yes, that’s a good idea.

Agreed!

In other news, closing this bug, now resolved on master via
8faa04c316fd2318708f2fcfaeea402615aafef9.

Thanks!

Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 52574@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 52574
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch