diff mbox series

[bug#46725] gnu: guile-lib: Fix cross compilation.

Message ID 20210223200755.29532-1-mail@cbaines.net
State Accepted
Headers show
Series [bug#46725] gnu: guile-lib: Fix cross compilation. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Christopher Baines Feb. 23, 2021, 8:07 p.m. UTC
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(-)

Comments

Leo Prikler Feb. 24, 2021, 7:58 a.m. UTC | #1
Hello,

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")?
> +             #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
Christopher Baines Feb. 24, 2021, 8:45 a.m. UTC | #2
Leo Prikler <leo.prikler@student.tugraz.at> writes:

> 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.

>> +             #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.
diff mbox series

Patch

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)))