--- Begin Message ---
Subject: |
[PATCH] gnu: guile-lib: Fix cross compilation. |
Date: |
Tue, 23 Feb 2021 20:07:55 +0000 |
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")
+ #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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#46725: [PATCH] gnu: guile-lib: Fix cross compilation. |
Date: |
Mon, 08 Mar 2021 22:11:02 +0000 |
User-agent: |
mu4e 1.4.15; emacs 27.1 |
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
signature.asc
Description: PGP signature
--- End Message ---