unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / Atom feed
* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
@ 2021-02-23 20:07 Christopher Baines
  2021-02-24  7:58 ` Leo Prikler
  2021-02-24  8:37 ` Christopher Baines
  0 siblings, 2 replies; 6+ messages in thread
From: Christopher Baines @ 2021-02-23 20:07 UTC (permalink / raw)
  To: 46725

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
  2021-02-23 20:07 [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation Christopher Baines
@ 2021-02-24  7:58 ` Leo Prikler
  2021-02-24  8:45   ` Christopher Baines
  2021-02-24  8:37 ` Christopher Baines
  1 sibling, 1 reply; 6+ messages in thread
From: Leo Prikler @ 2021-02-24  7:58 UTC (permalink / raw)
  To: Christopher Baines, 46725

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
  2021-02-23 20:07 [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation Christopher Baines
  2021-02-24  7:58 ` Leo Prikler
@ 2021-02-24  8:37 ` Christopher Baines
  2021-03-02 19:20   ` Ludovic Courtès
  1 sibling, 1 reply; 6+ messages in thread
From: Christopher Baines @ 2021-02-24  8:37 UTC (permalink / raw)
  To: 46725

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.
---
 gnu/packages/guile-xyz.scm | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
  2021-02-24  7:58 ` Leo Prikler
@ 2021-02-24  8:45   ` Christopher Baines
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Baines @ 2021-02-24  8:45 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 46725

[-- Attachment #1: Type: text/plain, Size: 2659 bytes --]


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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
  2021-02-24  8:37 ` Christopher Baines
@ 2021-03-02 19:20   ` Ludovic Courtès
  2021-03-04 13:16     ` Maxim Cournoyer
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-03-02 19:20 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 46725

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.

Otherwise LGTM.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation.
  2021-03-02 19:20   ` Ludovic Courtès
@ 2021-03-04 13:16     ` Maxim Cournoyer
  0 siblings, 0 replies; 6+ messages in thread
From: Maxim Cournoyer @ 2021-03-04 13:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 46725, Christopher Baines

Hi Ludovic,

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.

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-04 13:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 20:07 [bug#46725] [PATCH] gnu: guile-lib: Fix cross compilation Christopher Baines
2021-02-24  7:58 ` Leo Prikler
2021-02-24  8:45   ` Christopher Baines
2021-02-24  8:37 ` Christopher Baines
2021-03-02 19:20   ` Ludovic Courtès
2021-03-04 13:16     ` Maxim Cournoyer

unofficial mirror of guix-patches@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-patches/1 guix-patches/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-patches guix-patches/ https://yhetil.org/guix-patches \
		guix-patches@gnu.org
	public-inbox-index guix-patches

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.patches


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git