[PATCH] gnu: guile-lib: Fix cross compilation.

  • Done
  • quality assurance status badge
Details
4 participants
  • Leo Prikler
  • Ludovic Courtès
  • Christopher Baines
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal
C
C
Christopher Baines wrote on 23 Feb 2021 21:07
(address . guix-patches@gnu.org)
20210223200755.29532-1-mail@cbaines.net
These changes were sent upstream as

Without this change, the .go files are built for the host architecture, rather
than the target. I noticed this when cross building the
guix-build-coordinator (for which guile-lib is an input) to the Hurd.

* gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
'patch-for-cross-compilation phase.
[native-inputs]: Add autoconf, automake and gettext.
---
gnu/packages/guile-xyz.scm | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

Toggle diff (39 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index ce5aad8ec7..e9dfc6cc8d 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -2194,6 +2194,20 @@ library.")
'("GUILE_AUTO_COMPILE=0") ; to prevent guild errors
#:phases
(modify-phases %standard-phases
+ (add-after 'unpack 'patch-for-cross-compilation
+ (lambda _
+ (substitute* "configure.ac"
+ (("GUILE_FLAGS")
+ "GUILE_FLAGS
+if test \"$cross_compiling\" != no; then
+ GUILE_TARGET=\"--target=$host_alias\"
+ AC_SUBST([GUILE_TARGET])
+fi
+"))
+ (substitute* "am/guile.mk"
+ (("guild compile") "guild compile $(GUILE_TARGET)"))
+ (invoke "autoreconf" "-vif")
+ #t))
(add-before 'configure 'patch-module-dir
(lambda _
(substitute* "src/Makefile.in"
@@ -2204,7 +2218,10 @@ library.")
$(libdir)/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache\n"))
#t)))))
(native-inputs
- `(("guile" ,guile-3.0)
+ `(("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("gettext" ,gettext-minimal)
+ ("guile" ,guile-3.0)
("pkg-config" ,pkg-config)))
(inputs
`(("guile" ,guile-3.0)))
--
2.30.0
L
L
Leo Prikler wrote on 24 Feb 2021 08:58
d3ce8a30601c3601a08d6a10b17628ef368d9f75.camel@student.tugraz.at
Hello,

Am Dienstag, den 23.02.2021, 20:07 +0000 schrieb Christopher Baines:
Toggle quote (36 lines)
> These changes were sent upstream as
> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>
> Without this change, the .go files are built for the host
> architecture, rather
> than the target. I noticed this when cross building the
> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>
> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
> 'patch-for-cross-compilation phase.
> [native-inputs]: Add autoconf, automake and gettext.
> ---
> gnu/packages/guile-xyz.scm | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
> index ce5aad8ec7..e9dfc6cc8d 100644
> --- a/gnu/packages/guile-xyz.scm
> +++ b/gnu/packages/guile-xyz.scm
> @@ -2194,6 +2194,20 @@ library.")
> '("GUILE_AUTO_COMPILE=0") ; to prevent guild errors
> #:phases
> (modify-phases %standard-phases
> + (add-after 'unpack 'patch-for-cross-compilation
> + (lambda _
> + (substitute* "configure.ac"
> + (("GUILE_FLAGS")
> + "GUILE_FLAGS
> +if test \"$cross_compiling\" != no; then
> + GUILE_TARGET=\"--target=$host_alias\"
> + AC_SUBST([GUILE_TARGET])
> +fi
> +"))
> + (substitute* "am/guile.mk"
> + (("guild compile") "guild compile $(GUILE_TARGET)"))
> + (invoke "autoreconf" "-vif")
Invoking autoreconf seems a bit overkill for a "patch-<something>"
phase. Wouldn't it be regenerated in bootstrap if you (delete-file
"configure")?
Toggle quote (16 lines)
> + #t))
> (add-before 'configure 'patch-module-dir
> (lambda _
> (substitute* "src/Makefile.in"
> @@ -2204,7 +2218,10 @@ library.")
> $(libdir)/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache\n"))
> #t)))))
> (native-inputs
> - `(("guile" ,guile-3.0)
> + `(("autoconf" ,autoconf)
> + ("automake" ,automake)
> + ("gettext" ,gettext-minimal)
> + ("guile" ,guile-3.0)
> ("pkg-config" ,pkg-config)))
> (inputs
> `(("guile" ,guile-3.0)))
Otherwise LGTM, but I haven't checked cross-compiling. From your
message I'll assume you did.

Regards,
Leo
C
C
Christopher Baines wrote on 24 Feb 2021 09:37
[PATCH] gnu: guile-lib: Fix cross compilation.
(address . 46725@debbugs.gnu.org)
20210224083709.9342-1-mail@cbaines.net
These changes were sent upstream as

Without this change, the .go files are built for the host architecture, rather
than the target. I noticed this when cross building the
guix-build-coordinator (for which guile-lib is an input) to the Hurd.

* gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
'patch-for-cross-compilation phase.
[native-inputs]: Add autoconf, automake and gettext.
(guile2.0-lib): Adjust to use alist-replace.
(guile2.2-lib): Adjust to use alist-replace.
---
gnu/packages/guile-xyz.scm | 37 ++++++++++++++++++++++++++++++++-----
1 file changed, 32 insertions(+), 5 deletions(-)

Toggle diff (76 lines)
diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index ce5aad8ec7..07f81bcc1b 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -116,6 +116,7 @@
#:use-module (guix build-system gnu)
#:use-module (guix build-system guile)
#:use-module (guix utils)
+ #:use-module ((guix build utils) #:select (alist-replace))
#:use-module (ice-9 match)
#:use-module ((srfi srfi-1) #:select (alist-delete)))
@@ -2194,6 +2195,21 @@ library.")
'("GUILE_AUTO_COMPILE=0") ; to prevent guild errors
#:phases
(modify-phases %standard-phases
+ (add-after 'unpack 'patch-for-cross-compilation
+ (lambda _
+ (substitute* "configure.ac"
+ (("GUILE_FLAGS")
+ "GUILE_FLAGS
+if test \"$cross_compiling\" != no; then
+ GUILE_TARGET=\"--target=$host_alias\"
+ AC_SUBST([GUILE_TARGET])
+fi
+"))
+ (substitute* "am/guile.mk"
+ (("guild compile") "guild compile $(GUILE_TARGET)"))
+ (delete-file "configure") ; trigger the bootstrap phase to run
+ ; autoreconf
+ #t))
(add-before 'configure 'patch-module-dir
(lambda _
(substitute* "src/Makefile.in"
@@ -2204,7 +2220,10 @@ library.")
$(libdir)/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache\n"))
#t)))))
(native-inputs
- `(("guile" ,guile-3.0)
+ `(("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("gettext" ,gettext-minimal)
+ ("guile" ,guile-3.0)
("pkg-config" ,pkg-config)))
(inputs
`(("guile" ,guile-3.0)))
@@ -2225,15 +2244,23 @@ for Guile\".")
(package
(inherit guile-lib)
(name "guile2.0-lib")
- (native-inputs `(("pkg-config" ,pkg-config)))
- (inputs `(("guile" ,guile-2.0)))))
+ (native-inputs
+ (alist-replace "guile" (list guile-2.0)
+ (package-native-inputs guile-lib)))
+ (inputs
+ (alist-replace "guile" (list guile-2.0)
+ (package-inputs guile-lib)))))
(define-public guile2.2-lib
(package
(inherit guile-lib)
(name "guile2.2-lib")
- (native-inputs `(("pkg-config" ,pkg-config)))
- (inputs `(("guile" ,guile-2.2)))))
+ (native-inputs
+ (alist-replace "guile" (list guile-2.2)
+ (package-native-inputs guile-lib)))
+ (inputs
+ (alist-replace "guile" (list guile-2.2)
+ (package-inputs guile-lib)))))
(define-public guile3.0-lib
(deprecated-package "guile3.0-lib" guile-lib))
--
2.30.0
C
C
Christopher Baines wrote on 24 Feb 2021 09:45
(name . Leo Prikler)(address . leo.prikler@student.tugraz.at)(address . 46725@debbugs.gnu.org)
87czwplupv.fsf@cbaines.net
Leo Prikler <leo.prikler@student.tugraz.at> writes:

Toggle quote (42 lines)
> Am Dienstag, den 23.02.2021, 20:07 +0000 schrieb Christopher Baines:
>> These changes were sent upstream as
>> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>>
>> Without this change, the .go files are built for the host
>> architecture, rather
>> than the target. I noticed this when cross building the
>> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>>
>> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
>> 'patch-for-cross-compilation phase.
>> [native-inputs]: Add autoconf, automake and gettext.
>> ---
>> gnu/packages/guile-xyz.scm | 19 ++++++++++++++++++-
>> 1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
>> index ce5aad8ec7..e9dfc6cc8d 100644
>> --- a/gnu/packages/guile-xyz.scm
>> +++ b/gnu/packages/guile-xyz.scm
>> @@ -2194,6 +2194,20 @@ library.")
>> '("GUILE_AUTO_COMPILE=0") ; to prevent guild errors
>> #:phases
>> (modify-phases %standard-phases
>> + (add-after 'unpack 'patch-for-cross-compilation
>> + (lambda _
>> + (substitute* "configure.ac"
>> + (("GUILE_FLAGS")
>> + "GUILE_FLAGS
>> +if test \"$cross_compiling\" != no; then
>> + GUILE_TARGET=\"--target=$host_alias\"
>> + AC_SUBST([GUILE_TARGET])
>> +fi
>> +"))
>> + (substitute* "am/guile.mk"
>> + (("guild compile") "guild compile $(GUILE_TARGET)"))
>> + (invoke "autoreconf" "-vif")
>
> Invoking autoreconf seems a bit overkill for a "patch-<something>"
> phase. Wouldn't it be regenerated in bootstrap if you (delete-file
> "configure")?

Yeah, this works as well. I've changed this phase to delete the
configure file instead.

Toggle quote (20 lines)
>> + #t))
>> (add-before 'configure 'patch-module-dir
>> (lambda _
>> (substitute* "src/Makefile.in"
>> @@ -2204,7 +2218,10 @@ library.")
>> $(libdir)/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache\n"))
>> #t)))))
>> (native-inputs
>> - `(("guile" ,guile-3.0)
>> + `(("autoconf" ,autoconf)
>> + ("automake" ,automake)
>> + ("gettext" ,gettext-minimal)
>> + ("guile" ,guile-3.0)
>> ("pkg-config" ,pkg-config)))
>> (inputs
>> `(("guile" ,guile-3.0)))
>
> Otherwise LGTM, but I haven't checked cross-compiling. From your
> message I'll assume you did.

Turns out I broke guile2.0-lib and guile2.2-lib, so I've sent another
patch which fixes that.
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmA2EjxfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9Xd9kw//W39lz1VavsgfbgwDJjo+kvCVJaRoQFIc
LAUwb9qo0WeBymz4dii67jCk6Xmm+6TjbBVQzv6p8oace5us6dcLlB0RFG6AgV+u
d26KFh5OpOggDGlksH4jPDFpHSVli/km/oolHss4MX2YhTPHD9yy8C3sS+NK6/9e
KHFvZBktVFSQzucgbhYJxrEhkf7cDXVi+R97GwyKG8HBbUGrOuyg+TzjEd3Rxm4S
FxvHABBWMwoi5yk8zJHnmgifcJKpK7+4ePW7LJREGOyKXWHq2qnZi7p4ekPvoobG
079kafkxhd9zjpiELWf66GGFpDfsJab5LiiSmotdekWyQV5+bUI0UQ91SJQqVurI
d4Xru4RbDenUoIFP95oH+zEU389wmvNOXkC84psINFXk+KIB81WxnY4CJ0IXrps/
kdtuQD563Z5KEWPzJEWdp3OxBHphf5n1zzoSLpkl9SLXBJV+x64Dbb9uzQZU8hPO
TuNlQQ0o450a3IGu+SFgb4jf5g0c+JgYIOa8UHi/vb1NkR8bOHg2LyKUY584RuCZ
xZQFMMVwX9JgjV133O3oLJ/+bIOhf2kIHRUWpPLq0TbURa7lBeGgWuXRvscuVwka
zZJMkEZOKtWcbnveqVS28N/WtfDp52H55EoxqyXHTBrBiaE7TwqaKcB6F5quTtc9
OTj+Mbjaxlw=
=0ICu
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 2 Mar 2021 20:20
Re: bug#46725: [PATCH] gnu: guile-lib: Fix cross compilation.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 46725@debbugs.gnu.org)
87v9a9uzub.fsf_-_@gnu.org
Hi!

Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (13 lines)
> These changes were sent upstream as
> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>
> Without this change, the .go files are built for the host architecture, rather
> than the target. I noticed this when cross building the
> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>
> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
> 'patch-for-cross-compilation phase.
> [native-inputs]: Add autoconf, automake and gettext.
> (guile2.0-lib): Adjust to use alist-replace.
> (guile2.2-lib): Adjust to use alist-replace.

[...]

Toggle quote (8 lines)
> + (substitute* "configure.ac"
> + (("GUILE_FLAGS")
> + "GUILE_FLAGS
> +if test \"$cross_compiling\" != no; then
> + GUILE_TARGET=\"--target=$host_alias\"
> + AC_SUBST([GUILE_TARGET])
> +fi

You could even set ‘GUILE_TARGET’ unconditionally.

Otherwise LGTM.

Thanks,
Ludo’.
M
M
Maxim Cournoyer wrote on 4 Mar 2021 14:16
(name . Ludovic Courtès)(address . ludo@gnu.org)
87zgzjoy7y.fsf_-_@gmail.com
Hi Ludovic,

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

Toggle quote (29 lines)
> Hi!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> These changes were sent upstream as
>> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>>
>> Without this change, the .go files are built for the host architecture, rather
>> than the target. I noticed this when cross building the
>> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>>
>> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
>> 'patch-for-cross-compilation phase.
>> [native-inputs]: Add autoconf, automake and gettext.
>> (guile2.0-lib): Adjust to use alist-replace.
>> (guile2.2-lib): Adjust to use alist-replace.
>
> [...]
>
>> + (substitute* "configure.ac"
>> + (("GUILE_FLAGS")
>> + "GUILE_FLAGS
>> +if test \"$cross_compiling\" != no; then
>> + GUILE_TARGET=\"--target=$host_alias\"
>> + AC_SUBST([GUILE_TARGET])
>> +fi
>
> You could even set ‘GUILE_TARGET’ unconditionally.

It seems a conditional is needed, because info
'(autoconf)Canonicalizing' says:

The variables ‘build_alias’, ‘host_alias’, and ‘target_alias’ are
always exactly the arguments of ‘--build’, ‘--host’, and ‘--target’; in
particular, they are left empty if the user did not use them, even if
the corresponding ‘AC_CANONICAL’ macro was run.

I.e. without the condition '--target=' could be passed to guild, which
probably wouldn't work.

But in another part of the autoconf manual (Hosts and
Cross-Compilation), it says:

The relationship between build, host, and target have been cleaned
up: the chain of default is now simply: target defaults to host, host to
build, and build to the result of ‘config.guess’. Nevertheless, in
order to ease the transition from 2.13 to 2.50, the following transition
scheme is implemented. _Do not rely on it_, as it will be completely
disabled in a couple of releases (we cannot keep it, as it proves to
cause more problems than it cures).

They all default to the result of running ‘config.guess’, unless you
specify either ‘--build’ or ‘--host’. In this case, the default becomes
the system type you specified. If you specify both, and they’re
different, ‘configure’ enters cross compilation mode, so it doesn’t run
any tests that require execution.

Hint: if you mean to override the result of ‘config.guess’, prefer
‘--build’ over ‘--host’.

So it seems that nowadays the build, host, and target would take default
values as guessed by config.guess, and that the earlier section of the
manual should be updated?

Maxim
L
L
Ludovic Courtès wrote on 8 Mar 2021 15:22
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
874khld8to.fsf@gnu.org
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (42 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hi!
>>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>>> These changes were sent upstream as
>>> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>>>
>>> Without this change, the .go files are built for the host architecture, rather
>>> than the target. I noticed this when cross building the
>>> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>>>
>>> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
>>> 'patch-for-cross-compilation phase.
>>> [native-inputs]: Add autoconf, automake and gettext.
>>> (guile2.0-lib): Adjust to use alist-replace.
>>> (guile2.2-lib): Adjust to use alist-replace.
>>
>> [...]
>>
>>> + (substitute* "configure.ac"
>>> + (("GUILE_FLAGS")
>>> + "GUILE_FLAGS
>>> +if test \"$cross_compiling\" != no; then
>>> + GUILE_TARGET=\"--target=$host_alias\"
>>> + AC_SUBST([GUILE_TARGET])
>>> +fi
>>
>> You could even set ‘GUILE_TARGET’ unconditionally.
>
> It seems a conditional is needed, because info
> '(autoconf)Canonicalizing' says:
>
> The variables ‘build_alias’, ‘host_alias’, and ‘target_alias’ are
> always exactly the arguments of ‘--build’, ‘--host’, and ‘--target’; in
> particular, they are left empty if the user did not use them, even if
> the corresponding ‘AC_CANONICAL’ macro was run.
>
> I.e. without the condition '--target=' could be passed to guild, which
> probably wouldn't work.

Ah true. In Guile-{Gcrypt,zlib,…}, ‘--target’ is passed conditionally.
Apologies for the confusion!

Toggle quote (4 lines)
> So it seems that nowadays the build, host, and target would take default
> values as guessed by config.guess, and that the earlier section of the
> manual should be updated?

Dunno; but in hindsight, what Chris did seemed right.

Thanks,
Ludo’.
C
C
Christopher Baines wrote on 8 Mar 2021 23:11
(address . 46725-done@debbugs.gnu.org)
87k0qhb8jt.fsf@cbaines.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (55 lines)
> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> Hi!
>>>
>>> Christopher Baines <mail@cbaines.net> skribis:
>>>
>>>> These changes were sent upstream as
>>>> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>>>>
>>>> Without this change, the .go files are built for the host architecture, rather
>>>> than the target. I noticed this when cross building the
>>>> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>>>>
>>>> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
>>>> 'patch-for-cross-compilation phase.
>>>> [native-inputs]: Add autoconf, automake and gettext.
>>>> (guile2.0-lib): Adjust to use alist-replace.
>>>> (guile2.2-lib): Adjust to use alist-replace.
>>>
>>> [...]
>>>
>>>> + (substitute* "configure.ac"
>>>> + (("GUILE_FLAGS")
>>>> + "GUILE_FLAGS
>>>> +if test \"$cross_compiling\" != no; then
>>>> + GUILE_TARGET=\"--target=$host_alias\"
>>>> + AC_SUBST([GUILE_TARGET])
>>>> +fi
>>>
>>> You could even set ‘GUILE_TARGET’ unconditionally.
>>
>> It seems a conditional is needed, because info
>> '(autoconf)Canonicalizing' says:
>>
>> The variables ‘build_alias’, ‘host_alias’, and ‘target_alias’ are
>> always exactly the arguments of ‘--build’, ‘--host’, and ‘--target’; in
>> particular, they are left empty if the user did not use them, even if
>> the corresponding ‘AC_CANONICAL’ macro was run.
>>
>> I.e. without the condition '--target=' could be passed to guild, which
>> probably wouldn't work.
>
> Ah true. In Guile-{Gcrypt,zlib,…}, ‘--target’ is passed conditionally.
> Apologies for the confusion!
>
>> So it seems that nowadays the build, host, and target would take default
>> values as guessed by config.guess, and that the earlier section of the
>> manual should be updated?
>
> Dunno; but in hindsight, what Chris did seemed right.

I don't really get the change I'm making, but I'm confident it has the
desired effect, I just copied it other Guile libraries. Anyway, I think
this is still useful, so I've gone ahead and pushed as
a0b24d5f8c5813329986b1bd690ed50b5308cc78.

If there are better ways to get the cross compiling to work, then that
can be put in place upstream, and then these changes removed.

Thanks,

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmBGoPZfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XcTgxAAjASYFcHjqa87R5RGSif/4hTYct+/wekh
VnUSLa/UEXT4T+4i33HXm3PIix9xrFUSetYNpwqq3s64oP0A8CbBYs0irqOWYb3h
vY+MkhA/H1hpicaDmkTJ5vKazUz1z9PaB2b/nCqxJs9KDG6opvhcAXyRTrkjixUq
45BqpdK6wl8WY7KJgQa5HGvQY68Demx2k9cQw7fgPlekuv/IeDamrQzrBp6Oafpw
+zrwxXaZcBVfwnN7Rv5/L96tugesvXXkcOqvfCtuUDTgaf95m+am09TRIoVj8PD9
ePEGGuAaFjv1szvPsP+lj1eedpaLUyDZyUatjtu6FRhAWSDZTU/9Xy4XvQ+nN6FC
OO+YbHN6pA+1Ko0xsQA0Kq3GkBACHHqDxjPe68UfvSRPIIxyvGhZZrBKVPDyA77+
FzGstVv5ByXPh36NykkXrVuFAKl0tislbbIR8oda6bgOazNbFvw5V2q6MekyuMZf
P46KR/O5yrTMIdaqGJCzOk0wbBOiqMoEZtQQuC870cMWB4w7RgjaaEkEla9vLPLL
iUP03lKIY0oyFFioXoOOlf4bFNVixgvANBCHkvEfRaKF5rKIN32GEgiuJXMw4pTL
v6o7d/XwIZ4lL9XfqsgtdzlYXoelAUD2kyv6x9d1wb0D0k4M4VkVj495B8Pgbp8o
X7kLNehtsHg=
=AiNU
-----END PGP SIGNATURE-----

Closed
M
M
Maxim Cournoyer wrote on 11 Mar 2021 22:01
(name . Christopher Baines)(address . mail@cbaines.net)
87wnudtneq.fsf@gmail.com
Hi Chris,

Christopher Baines <mail@cbaines.net> writes:

Toggle quote (69 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hi,
>>
>> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>>
>>> Ludovic Courtès <ludo@gnu.org> writes:
>>>
>>>> Hi!
>>>>
>>>> Christopher Baines <mail@cbaines.net> skribis:
>>>>
>>>>> These changes were sent upstream as
>>>>> https://lists.gnu.org/archive/html/guile-devel/2021-02/msg00004.html
>>>>>
>>>>> Without this change, the .go files are built for the host architecture, rather
>>>>> than the target. I noticed this when cross building the
>>>>> guix-build-coordinator (for which guile-lib is an input) to the Hurd.
>>>>>
>>>>> * gnu/packages/guile-xyz.scm (guile-lib)[arguments]: Add
>>>>> 'patch-for-cross-compilation phase.
>>>>> [native-inputs]: Add autoconf, automake and gettext.
>>>>> (guile2.0-lib): Adjust to use alist-replace.
>>>>> (guile2.2-lib): Adjust to use alist-replace.
>>>>
>>>> [...]
>>>>
>>>>> + (substitute* "configure.ac"
>>>>> + (("GUILE_FLAGS")
>>>>> + "GUILE_FLAGS
>>>>> +if test \"$cross_compiling\" != no; then
>>>>> + GUILE_TARGET=\"--target=$host_alias\"
>>>>> + AC_SUBST([GUILE_TARGET])
>>>>> +fi
>>>>
>>>> You could even set ‘GUILE_TARGET’ unconditionally.
>>>
>>> It seems a conditional is needed, because info
>>> '(autoconf)Canonicalizing' says:
>>>
>>> The variables ‘build_alias’, ‘host_alias’, and ‘target_alias’ are
>>> always exactly the arguments of ‘--build’, ‘--host’, and ‘--target’; in
>>> particular, they are left empty if the user did not use them, even if
>>> the corresponding ‘AC_CANONICAL’ macro was run.
>>>
>>> I.e. without the condition '--target=' could be passed to guild, which
>>> probably wouldn't work.
>>
>> Ah true. In Guile-{Gcrypt,zlib,…}, ‘--target’ is passed conditionally.
>> Apologies for the confusion!
>>
>>> So it seems that nowadays the build, host, and target would take default
>>> values as guessed by config.guess, and that the earlier section of the
>>> manual should be updated?
>>
>> Dunno; but in hindsight, what Chris did seemed right.
>
> I don't really get the change I'm making, but I'm confident it has the
> desired effect, I just copied it other Guile libraries. Anyway, I think
> this is still useful, so I've gone ahead and pushed as
> a0b24d5f8c5813329986b1bd690ed50b5308cc78.
>
> If there are better ways to get the cross compiling to work, then that
> can be put in place upstream, and then these changes removed.
>
> Thanks,
>
> Chris

FYI, I have sent to the Guile patches tracker commits (keeping original
authorship) of all the Guix-specific changes to guile-lib; the version
of your patch is slightly modified to test the value about to be used,
but otherwise it behaves the same.

Maxim
Closed
?