unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Jan Nieuwenhuizen <janneke@gnu.org>
To: Mathieu Othacehe <m.othacehe@gmail.com>
Cc: 40839@debbugs.gnu.org
Subject: bug#40839: Shepherd activation .GO files are not cross-compiled ... and the Hurd
Date: Sat, 25 Apr 2020 15:28:23 +0200	[thread overview]
Message-ID: <87eesbu22w.fsf@gnu.org> (raw)
In-Reply-To: <87wo63u5j6.fsf@gmail.com> (Mathieu Othacehe's message of "Sat, 25 Apr 2020 14:13:49 +0200")

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

Mathieu Othacehe writes:

Hello Mathieu,

> I strongly suspect this is because we would need to wrap the
> "compile-file" call in "scm->go" procedure of (gnu services shepherd)
> inside a "with-target".

> That would look like:
>
> (if target
>     (with-target target
>                  (compile-file #$file #:output-file #$output
>                                #:env env))
>   (compile-file #$file #:output-file #$output
>                 #:env env))

Thank you!  I have tried this in the attached patch, and it seems to
work for me.

I was so puzzled why wrapping scm->go

--8<---------------cut here---------------start------------->8---
(use-modules (system base target))
(define (scm->go file)
  (with-target "i586-pc-gnu"
    (lambda _
     ((@@ (gnu services shepherd) scm->go) file))))
--8<---------------cut here---------------end--------------->8---

did not work; actually reading scm->go makes that pretty clear :-)

> Now, the tricky part is the value of target, because
> #$(%current-target-system) might not be correct in that context.

I did read this, but wanted to try it first anyway.  So, what are you
seeing here, when would this not be OK?  Any other ideas of how to
address this further?

Greetings,
janneke


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-services-shepherd-Cross-compilation-fix.patch --]
[-- Type: text/x-patch, Size: 3452 bytes --]

From cc9259a87c46cfa0dc2c59dc425b3656c9eecb13 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Sat, 25 Apr 2020 15:20:04 +0200
Subject: [PATCH] services: shepherd: Cross-compilation fix.

Fixes <https://bugs.gnu.org/40839>.
Reported by Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Fix suggested by Mathieu Othacehe <m.othacehe@gmail.com>

* gnu/services/shepherd.scm (scm->go): Use `with-target' when cross-compiling.
---
 gnu/services/shepherd.scm | 40 +++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 2f30c6c907..ca4edd80ab 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -25,6 +25,7 @@
   #:use-module (guix store)
   #:use-module (guix records)
   #:use-module (guix derivations)                 ;imported-modules, etc.
+  #:use-module (guix utils)
   #:use-module (gnu services)
   #:use-module (gnu services herd)
   #:use-module (gnu packages admin)
@@ -260,22 +261,29 @@ stored."
 (define (scm->go file)
   "Compile FILE, which contains code to be loaded by shepherd's config file,
 and return the resulting '.go' file."
-  (with-extensions (list shepherd)
-    (computed-file (string-append (basename (scheme-file-name file) ".scm")
-                                  ".go")
-                   #~(begin
-                       (use-modules (system base compile))
-
-                       ;; Do the same as the Shepherd's 'load-in-user-module'.
-                       (let ((env (make-fresh-user-module)))
-                         (module-use! env (resolve-interface '(oop goops)))
-                         (module-use! env (resolve-interface '(shepherd service)))
-                         (compile-file #$file #:output-file #$output
-                                       #:env env)))
-
-                   ;; It's faster to build locally than to download.
-                   #:options '(#:local-build? #t
-                               #:substitutable? #f))))
+  (let ((target (%current-target-system)))
+    (with-extensions (list shepherd)
+      (computed-file (string-append (basename (scheme-file-name file) ".scm")
+                                    ".go")
+                     #~(begin
+                         (use-modules (system base compile)
+                                      (system base target))
+
+                         ;; Do the same as the Shepherd's 'load-in-user-module'.
+                         (let ((env (make-fresh-user-module)))
+                           (module-use! env (resolve-interface '(oop goops)))
+                           (module-use! env (resolve-interface '(shepherd service)))
+                           (if #$target
+                               (with-target #$target
+                                 (lambda _
+                                   (compile-file #$file #:output-file #$output
+                                                 #:env env)))
+                               (compile-file #$file #:output-file #$output
+                                             #:env env))))
+
+                     ;; It's faster to build locally than to download.
+                     #:options '(#:local-build? #t
+                                 #:substitutable? #f)))))
 
 (define (shepherd-configuration-file services)
   "Return the shepherd configuration file for SERVICES."
-- 
2.26.0


[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

  reply	other threads:[~2020-04-25 13:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25  9:49 bug#40839: Shepherd activation .GO files are not cross-compiled ... and the Hurd Jan Nieuwenhuizen
2020-04-25 12:13 ` Mathieu Othacehe
2020-04-25 13:28   ` Jan Nieuwenhuizen [this message]
2020-04-25 15:53   ` Ludovic Courtès
2020-04-25 17:38     ` Jan Nieuwenhuizen
2020-05-02 13:15       ` Ludovic Courtès
2020-04-25 12:32 ` Mathieu Othacehe
2020-04-25 17:59   ` Jan Nieuwenhuizen
2020-04-27 12:35     ` Mathieu Othacehe
2020-04-28 17:20       ` Jan Nieuwenhuizen
2020-04-29  8:48         ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eesbu22w.fsf@gnu.org \
    --to=janneke@gnu.org \
    --cc=40839@debbugs.gnu.org \
    --cc=m.othacehe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).