gnu: chez-scheme-for-racket: Support all systems.
On systems for which Racket's variant of Chez Scheme cannot generate native code, it can use a 'pbarch' machine type: a variant of the ``portable bytecode'' backend specialized to word size and endianness. This allows Racket CS to replace Racket BC on those systems while maintaining comparable performance. (Racket BC lacks JIT support for those systems anyway.) It also lets us provide a Chez Scheme package on all systems Guix supports. This patch adds 'pbarch' support to both 'chez-scheme-for-racket' and 'racket-vm-cs', but it does not change the Racket VM implementation used for the 'racket' and 'racket-minimal' packages. * gnu/packages/chez.scm (nix-system->pbarch-machine-type): New variable. (chez-scheme-for-racket)[inputs]: Use 'libffi' for non-native systems. [arguments]<#:configure-flags>: Always supply '-m='. Add applicable flags for non-native systems. [supported-systems]: Use '%supported-systems'. [description]: Update. (chez-scheme-for-racket-bootstrap-bootfiles)[arguments]<#:phases>: Adapt 'build' phase for non-native systems. * gnu/packages/racket.scm (racket-vm-bc)[description]: Update. (racket-vm-cs)[description]: Likewise. [inputs]: Use 'libffi' for non-native systems. [arguments]<#:configure-flags>: Add applicable flags for non-native systems. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
cb0d106590
commit
a15d72f8e1
2 changed files with 74 additions and 28 deletions
|
@ -37,6 +37,7 @@
|
||||||
#:use-module (gnu packages compression)
|
#:use-module (gnu packages compression)
|
||||||
#:use-module (gnu packages ncurses)
|
#:use-module (gnu packages ncurses)
|
||||||
#:use-module (gnu packages ghostscript)
|
#:use-module (gnu packages ghostscript)
|
||||||
|
#:use-module (gnu packages libffi)
|
||||||
#:use-module (gnu packages linux)
|
#:use-module (gnu packages linux)
|
||||||
#:use-module (gnu packages netpbm)
|
#:use-module (gnu packages netpbm)
|
||||||
#:use-module (gnu packages racket)
|
#:use-module (gnu packages racket)
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:export (chez-scheme-for-system
|
#:export (chez-scheme-for-system
|
||||||
racket-cs-native-supported-system?
|
racket-cs-native-supported-system?
|
||||||
|
nix-system->pbarch-machine-type
|
||||||
unpack-nanopass+stex))
|
unpack-nanopass+stex))
|
||||||
|
|
||||||
;; Commentary:
|
;; Commentary:
|
||||||
|
@ -231,6 +233,28 @@ future."
|
||||||
(and=> (assoc-ref %chez-features-table chez-os)
|
(and=> (assoc-ref %chez-features-table chez-os)
|
||||||
(cut assoc-ref <> chez-arch))))
|
(cut assoc-ref <> chez-arch))))
|
||||||
|
|
||||||
|
(define* (nix-system->pbarch-machine-type #:optional
|
||||||
|
(system
|
||||||
|
(or (%current-target-system)
|
||||||
|
(%current-system)))
|
||||||
|
#:key (threads? #t))
|
||||||
|
"Return a string naming the pseudo–machine type used by Racket's variant of
|
||||||
|
Chez Scheme to represent the appropriate ``pbarch'' backend for SYSTEM: that
|
||||||
|
is, the ``portable bytecode'' backend specialized for SYSTEM's word size and
|
||||||
|
endianness. The result will name the threaded machine type unless THREADS? is
|
||||||
|
provided and is #f."
|
||||||
|
(string-append (if threads?
|
||||||
|
"t"
|
||||||
|
"")
|
||||||
|
"pb"
|
||||||
|
(if (target-64bit? system)
|
||||||
|
"64"
|
||||||
|
"32")
|
||||||
|
;; missing (guix utils) predicate target-little-endian?
|
||||||
|
(if (target-ppc32? system)
|
||||||
|
"b"
|
||||||
|
"l")))
|
||||||
|
|
||||||
(define* (racket-cs-native-supported-system? #:optional
|
(define* (racket-cs-native-supported-system? #:optional
|
||||||
(system
|
(system
|
||||||
(or (%current-target-system)
|
(or (%current-target-system)
|
||||||
|
@ -449,10 +473,14 @@ and 32-bit PowerPC architectures.")
|
||||||
;; When updating, remember to also update %racket-version in racket.scm.
|
;; When updating, remember to also update %racket-version in racket.scm.
|
||||||
(source #f) ; avoid problematic cycle with racket.scm
|
(source #f) ; avoid problematic cycle with racket.scm
|
||||||
(inputs
|
(inputs
|
||||||
(modify-inputs (package-inputs chez-scheme)
|
(let ((inputs (modify-inputs (package-inputs chez-scheme)
|
||||||
(delete "libx11" "util-linux:lib")
|
(replace "chez-scheme-bootstrap-bootfiles"
|
||||||
(replace "chez-scheme-bootstrap-bootfiles"
|
chez-scheme-for-racket-bootstrap-bootfiles)
|
||||||
chez-scheme-for-racket-bootstrap-bootfiles)))
|
(delete "libx11" "util-linux:lib"))))
|
||||||
|
(if (racket-cs-native-supported-system?)
|
||||||
|
inputs
|
||||||
|
(modify-inputs inputs
|
||||||
|
(prepend libffi)))))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(let ((native-inputs (modify-inputs (package-native-inputs chez-scheme)
|
(let ((native-inputs (modify-inputs (package-native-inputs chez-scheme)
|
||||||
(prepend zuo))))
|
(prepend zuo))))
|
||||||
|
@ -473,10 +501,16 @@ and 32-bit PowerPC architectures.")
|
||||||
((#:configure-flags cfg-flags #~'())
|
((#:configure-flags cfg-flags #~'())
|
||||||
#~`("--disable-x11"
|
#~`("--disable-x11"
|
||||||
"--threads" ;; ok to potentially duplicate
|
"--threads" ;; ok to potentially duplicate
|
||||||
#$@(if (%current-target-system)
|
#$(string-append "-m=" (or (racket-cs-native-supported-system?)
|
||||||
(list (string-append "-m="
|
(nix-system->pbarch-machine-type)))
|
||||||
(racket-cs-native-supported-system?)))
|
;; ^ could skip -m= for non-cross non-pbarch builds
|
||||||
'())
|
#$@(if (racket-cs-native-supported-system?)
|
||||||
|
#~()
|
||||||
|
;; not inferred on non-native platforms: see
|
||||||
|
;; https://racket.discourse.group/t/950/9
|
||||||
|
#~("--enable-libffi"
|
||||||
|
"CFLAGS=-g -O2 -D_REENTRANT -pthread"
|
||||||
|
"LIBS=-lm -ldl -lrt -lffi -lncurses"))
|
||||||
#$@(if (%current-target-system)
|
#$@(if (%current-target-system)
|
||||||
(list (string-append "--toolprefix="
|
(list (string-append "--toolprefix="
|
||||||
(%current-target-system)
|
(%current-target-system)
|
||||||
|
@ -543,10 +577,7 @@ and 32-bit PowerPC architectures.")
|
||||||
(add-after 'unpack 'chdir
|
(add-after 'unpack 'chdir
|
||||||
(lambda args
|
(lambda args
|
||||||
(chdir "racket/src/ChezScheme"))))))))
|
(chdir "racket/src/ChezScheme"))))))))
|
||||||
;; TODO: How to build pbarch/pbchunks for other systems?
|
(supported-systems %supported-systems)
|
||||||
;; See https://racket.discourse.group/t/950
|
|
||||||
(supported-systems (filter racket-cs-native-supported-system?
|
|
||||||
%supported-systems))
|
|
||||||
(home-page "https://github.com/racket/ChezScheme")
|
(home-page "https://github.com/racket/ChezScheme")
|
||||||
;; ^ This is downstream of https://github.com/racket/racket,
|
;; ^ This is downstream of https://github.com/racket/racket,
|
||||||
;; but it's designed to be a friendly landing place for people
|
;; but it's designed to be a friendly landing place for people
|
||||||
|
@ -559,13 +590,17 @@ supported by upstream Chez Scheme.
|
||||||
Main additions to Chez Scheme in the Racket variant:
|
Main additions to Chez Scheme in the Racket variant:
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
AArch64 support
|
AArch64 code generation
|
||||||
@item
|
@item
|
||||||
Portable bytes (@code{pb}) support, which is mainly useful for bootstrapping
|
Portable bytecode (@code{pb}) mode, which is mainly useful for bootstrapping a
|
||||||
a build on any supported platform
|
build on any platform, but can also be used on platforms without native-code
|
||||||
|
generation, compiled via Emscripten, linked with @code{libffi}, or used with
|
||||||
|
bytecode partially compiled to C
|
||||||
@item
|
@item
|
||||||
Unboxed floating-point arithmetic and flvectors
|
Unboxed floating-point arithmetic and flvectors
|
||||||
@item
|
@item
|
||||||
|
Faster multiplication and division for large exact numbers
|
||||||
|
@item
|
||||||
Type reconstruction during optimization (especially for safe code)
|
Type reconstruction during optimization (especially for safe code)
|
||||||
@item
|
@item
|
||||||
Continuation attachments
|
Continuation attachments
|
||||||
|
@ -576,8 +611,6 @@ accounting
|
||||||
@item
|
@item
|
||||||
Ordered finalization, immobile (but collectable) objects, weak/ephemeron
|
Ordered finalization, immobile (but collectable) objects, weak/ephemeron
|
||||||
generic hash tables, and reference bytevectors
|
generic hash tables, and reference bytevectors
|
||||||
@item
|
|
||||||
Faster multiplication and division for large exact numbers
|
|
||||||
@end itemize")
|
@end itemize")
|
||||||
(license asl2.0)))
|
(license asl2.0)))
|
||||||
|
|
||||||
|
@ -655,13 +688,18 @@ source.")))
|
||||||
"makefiles/boot.zuo"
|
"makefiles/boot.zuo"
|
||||||
(search-input-file (or native-inputs inputs)
|
(search-input-file (or native-inputs inputs)
|
||||||
"/bin/scheme")
|
"/bin/scheme")
|
||||||
#$(racket-cs-native-supported-system?)))
|
#$(or (racket-cs-native-supported-system?)
|
||||||
|
(nix-system->pbarch-machine-type))))
|
||||||
(else
|
(else
|
||||||
;; bootstrapping
|
;; bootstrapping
|
||||||
#~(invoke
|
#~(invoke
|
||||||
(search-input-file (or native-inputs inputs)
|
(search-input-file (or native-inputs inputs)
|
||||||
"/opt/racket-vm/bin/racket")
|
"/opt/racket-vm/bin/racket")
|
||||||
"rktboot/main.rkt"))))))))))
|
"rktboot/main.rkt"
|
||||||
|
#$@(if (racket-cs-native-supported-system?)
|
||||||
|
#~()
|
||||||
|
(let ((m (nix-system->pbarch-machine-type)))
|
||||||
|
#~("--machine" #$m)))))))))))))
|
||||||
(supported-systems
|
(supported-systems
|
||||||
(package-supported-systems chez-scheme-for-racket))
|
(package-supported-systems chez-scheme-for-racket))
|
||||||
(home-page "https://github.com/racket/ChezScheme")
|
(home-page "https://github.com/racket/ChezScheme")
|
||||||
|
|
|
@ -311,7 +311,7 @@ One of the early layers implements macros.")
|
||||||
(version %racket-version)
|
(version %racket-version)
|
||||||
(source %racket-origin)
|
(source %racket-origin)
|
||||||
(inputs (list ncurses ;; <- common to all variants (for #%terminal)
|
(inputs (list ncurses ;; <- common to all variants (for #%terminal)
|
||||||
libffi)) ;; <- only for BC variants
|
libffi)) ;; <- for BC and non-native CS variants
|
||||||
(native-inputs (cons* zuo ;; <- for all variants
|
(native-inputs (cons* zuo ;; <- for all variants
|
||||||
libtool ;; <- only for BC variants
|
libtool ;; <- only for BC variants
|
||||||
(if (%current-target-system)
|
(if (%current-target-system)
|
||||||
|
@ -417,10 +417,8 @@ code to use the 3M garbage collector.")
|
||||||
(description "The Racket BC (``before Chez'' or ``bytecode'')
|
(description "The Racket BC (``before Chez'' or ``bytecode'')
|
||||||
implementation was the default before Racket 8.0. It uses a compiler written
|
implementation was the default before Racket 8.0. It uses a compiler written
|
||||||
in C targeting architecture-independent bytecode, plus a JIT compiler on most
|
in C targeting architecture-independent bytecode, plus a JIT compiler on most
|
||||||
platforms. Racket BC has a different C API and supports a slightly different
|
platforms. Racket BC has a different C API than the current default runtime
|
||||||
set of architectures than the current default runtime system, Racket CS (based
|
system, Racket CS (based on ``Chez Scheme'').
|
||||||
on ``Chez Scheme''). It is the recommended implementation for architectures
|
|
||||||
that Racket CS doesn't support.
|
|
||||||
|
|
||||||
This package is the normal implementation of Racket BC with a precise garbage
|
This package is the normal implementation of Racket BC with a precise garbage
|
||||||
collector, 3M (``Moving Memory Manager'').")
|
collector, 3M (``Moving Memory Manager'').")
|
||||||
|
@ -433,9 +431,12 @@ collector, 3M (``Moving Memory Manager'').")
|
||||||
(inherit racket-vm-bc)
|
(inherit racket-vm-bc)
|
||||||
(name "racket-vm-cs")
|
(name "racket-vm-cs")
|
||||||
(inputs
|
(inputs
|
||||||
(modify-inputs (package-inputs racket-vm-cgc)
|
(let ((inputs (modify-inputs (package-inputs racket-vm-cgc)
|
||||||
(prepend zlib lz4)
|
(prepend zlib lz4))))
|
||||||
(delete "libffi")))
|
(if (racket-cs-native-supported-system?)
|
||||||
|
(modify-inputs inputs
|
||||||
|
(delete "libffi"))
|
||||||
|
inputs)))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(let ((native-inputs (package-native-inputs racket-vm-cgc)))
|
(let ((native-inputs (package-native-inputs racket-vm-cgc)))
|
||||||
(modify-inputs (if (%current-target-system)
|
(modify-inputs (if (%current-target-system)
|
||||||
|
@ -464,12 +465,19 @@ collector, 3M (``Moving Memory Manager'').")
|
||||||
#+(this-package-native-input
|
#+(this-package-native-input
|
||||||
"chez-scheme-for-racket")
|
"chez-scheme-for-racket")
|
||||||
"/bin/scheme")
|
"/bin/scheme")
|
||||||
|
#$@(if (racket-cs-native-supported-system?)
|
||||||
|
#~()
|
||||||
|
#~(#$(string-append "--enable-mach="
|
||||||
|
(nix-system->pbarch-machine-type))
|
||||||
|
"--enable-pb"))
|
||||||
#$racket-vm-common-configure-flags))))
|
#$racket-vm-common-configure-flags))))
|
||||||
(synopsis "Racket CS implementation")
|
(synopsis "Racket CS implementation")
|
||||||
(description "The Racket CS implementation, which uses ``Chez Scheme'' as
|
(description "The Racket CS implementation, which uses ``Chez Scheme'' as
|
||||||
its core compiler and runtime system, has been the default Racket VM
|
its core compiler and runtime system, has been the default Racket VM
|
||||||
implementation since Racket 8.0. It performs better than the Racket BC
|
implementation since Racket 8.0. It performs better than the Racket BC
|
||||||
implementation for most programs.
|
implementation for most programs. On systems for which Racket CS cannot
|
||||||
|
generate machine code, this package uses a variant of its ``portable
|
||||||
|
bytecode'' backend specialized for word size and endianness.
|
||||||
|
|
||||||
Using the Racket VM packages directly is not recommended: instead, install the
|
Using the Racket VM packages directly is not recommended: instead, install the
|
||||||
@code{racket-minimal} or @code{racket} packages.")
|
@code{racket-minimal} or @code{racket} packages.")
|
||||||
|
|
Reference in a new issue