all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Johann <t1m@phrogstar.de>
To: 62231@debbugs.gnu.org
Subject: [bug#62231] Chez Scheme for Racket build on aarch64 (patch attached)
Date: Fri, 17 Mar 2023 00:23:46 +0100	[thread overview]
Message-ID: <87h6ukntrg.fsf@phrogstar.de> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 4542 bytes --]

Hi Guix Team,

tl;dr;

The recipe for package 'chez-scheme-for-racket-bootstrap-bootfiles' (a
dependency for racket-8.*) needs to use the --machine flag to build on aarch64
(and possibly also ppc32, the other non-x86 architectures supported by the
Racket fork of Chez Scheme).  I therefore suggest the attached patch to make
building and using Racket possible on aarch64 Guix.

End of tl;dr;

A few weeks ago I wanted to use Racket on Guix on aarch64, but was made aware,
that Racket was not available as a substitute and it did not build.  On the
other hand, recent versions of Racket were available on Raspberry Pi OS which is
explicitly running on aarch64.  The machine I am running Guix on actually is a
Raspberry Pi 4B.

So, I dug deeper to find that the problem is that the package
  chez-scheme-for-racket-bootstrap-bootfiles
fails with the error
,----
|   string-append: contract violation
|   expected: string?
|   given: #f
|   argument position: 1st
|   other arguments...:
|    ".def"
|   context...:
|    /tmp/guix-build-chez-scheme-for-racket-bootstrap-bootfiles-9.9.9-pre-release.14.drv-0/source/racket/src/rktboot/machine-def.rkt:6:0: open-file-with-machine.def-redirect
| error: in phase 'build': uncaught exception:
| %exception #<&invoke-error program: "/gnu/store/0n4skakcg05bbq9sq7g00j2zm25xh4wa-racket-vm-bc-8.8/opt/racket-vm/bin/racket" arguments: ("../rktboot/main.rkt") exit-status: 1 term-signal: #f stop-signal: #f> 
| phase `build' failed after 14.3 seconds
| command "/gnu/store/0n4skakcg05bbq9sq7g00j2zm25xh4wa-racket-vm-bc-8.8/opt/racket-vm/bin/racket" "../rktboot/main.rkt" failed with status 1
| builder for `/gnu/store/d04mbj02vzjv0ljcqy2lxs33scz7kjz0-chez-scheme-for-racket-bootstrap-bootfiles-9.9.9-pre-release.14.drv' failed with exit code 1
| @ build-failed /gnu/store/d04mbj02vzjv0ljcqy2lxs33scz7kjz0-chez-scheme-for-racket-bootstrap-bootfiles-9.9.9-pre-release.14.drv - 1 builder for `/gnu/store/d04mbj02vzjv0ljcqy2lxs33scz7kjz0-chez-scheme-for-racket-bootstrap-bootfiles-9.9.9-pre-release.14.drv' failed with exit code 1
`----
(see, e.g. the build [442314 on ci.guix.gnu.org]).

The Racket fork of Chez is natively supported on aarch64, which is supported by
comments in module (gnu packages chez), so I went on to find that machine
architecture is communicated in the build process by setting the environment
variable MACH.  I haven't looked to verify this, but it seems that this
environment variable is normally set to a guessed value by the zuo build process
(zuo for 'make' in Mandarin?).

The Guix build recipe for chez-scheme-for-racket-bootstrap-bootfiles, though, is
not configuring the whole downloaded racket source package but takes the
shortcut of just building ChezScheme in the subdirectory
  racket/src/ChezScheme
using the Racket utility
  ../rktboot/main.rkt
This script would actually accept the flag '--machine' and would set the
environment variable MACH to the value of the argument following the flag.

The problem is that in the case of aarch64 the recipe would not set the flag.
In the recipe for chez-scheme-for-racket-bootstrap-bootfiles in module (gnu
packages chez), we find the lines
,----
| #~(invoke
|    (search-input-file (or native-inputs inputs)
|                       "/opt/racket-vm/bin/racket")
|    "../rktboot/main.rkt"
|    #$@(if (racket-cs-native-supported-system?)
|           #~()
|           (let ((m (nix-system->pbarch-machine-type)))
|             #~("--machine" #$m)))))))))))))
`----
and, since `(racket-cs-native-supported-system?)' returns `tarm64le', the first
branch of the if expression is taken, ommitting the flag.

I suggest to change the above code to the following:
,----
| #~(invoke
|    (search-input-file (or native-inputs inputs)
|                       "/opt/racket-vm/bin/racket")
|    "../rktboot/main.rkt"
|    #$@(let ((m (or (racket-cs-native-supported-system?)
|                    (nix-system->pbarch-machine-type))))
|         #~("--machine" #$m))))))))))))
`----
which sets the flag for natively supported architectures and those supported by
portable bytecode.

The package (and subsequently Racket) builds on aarch64, the build on x86_64
seems to be unaffected.

It is a simple change which would make a huge difference for Guix users who want
to be able to play with Racket on an aarch64 machine.

Cheers

Tim

Lá Fhéile Pádraig sona dhaoibh!


[442314 on ci.guix.gnu.org] <https://ci.guix.gnu.org/build/442314/log/raw>

[-- Attachment #1.2: Type: text/html, Size: 8874 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: chez-racket-aarch64.patch --]
[-- Type: text/x-diff, Size: 1484 bytes --]

commit f8d7b06a92b3839da1908837ac81ab6295626cf5
Author: Tim Johann <t1m@phrogstar.de>
Date:   Thu Mar 16 18:53:13 2023 +0100

    gnu: chez-scheme-for-racket-bootstrap-bootfiles: change for aarch64.
    
    * gnu/packages/chez.scm (chez-scheme-for-racket-bootstrap-bootfiles):
    change for build on aarch64, making racket available on aarch64.
    [arguments] use --machine even when architecture is supported by Racket's
    fork of ChezScheme.

diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm
index c6420a980e..bc709917c2 100644
--- a/gnu/packages/chez.scm
+++ b/gnu/packages/chez.scm
@@ -692,10 +692,9 @@ (define-public chez-scheme-for-racket-bootstrap-bootfiles
                          (search-input-file (or native-inputs inputs)
                                             "/opt/racket-vm/bin/racket")
                          "../rktboot/main.rkt"
-                         #$@(if (racket-cs-native-supported-system?)
-                                #~()
-                                (let ((m (nix-system->pbarch-machine-type)))
-                                  #~("--machine" #$m)))))))))))))
+                         #$@(let ((m (or (racket-cs-native-supported-system?)
+                                         (nix-system->pbarch-machine-type))))
+                              #~("--machine" #$m))))))))))))
     (supported-systems
      (package-supported-systems chez-scheme-for-racket))
     (home-page "https://github.com/racket/ChezScheme")

             reply	other threads:[~2023-03-17 12:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 23:23 Tim Johann [this message]
2023-03-24  1:36 ` [bug#62231] Chez Scheme for Racket build on aarch64 (patch attached) Philip McGrath
2023-03-24 20:03   ` Tim Johann
2023-03-25  5:36     ` Philip McGrath
2023-03-26 14:26     ` bug#62231: " Ludovic Courtès

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

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

  git send-email \
    --in-reply-to=87h6ukntrg.fsf@phrogstar.de \
    --to=t1m@phrogstar.de \
    --cc=62231@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.