diff mbox series

[bug#53878,v2,11/15] gnu: Add chez-scheme-for-racket.

Message ID 20220217205048.967383-12-philip@philipmcgrath.com
State Accepted
Headers show
Series Update Racket to 8.4. Adjust Chez Scheme packages. | 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
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

Philip McGrath Feb. 17, 2022, 8:50 p.m. UTC
The Racket variant of Chez Scheme can be used to support platforms that
are not yet supported by upstream Chez Scheme.

* gnu/packages/chez-and-racket-bootstrap.scm (unpack-nanopass+stex):
(chez-scheme-for-racket):
(chez-scheme-for-racket-bootstrap-bootfiles): New variables.
(chez-scheme)[arguments]<#:phases>: Adapt 'unpack-nanopass+stex' phase
to use the eponymous new variable.
---
 gnu/packages/chez-and-racket-bootstrap.scm | 131 +++++++++++++++++++--
 1 file changed, 120 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/chez-and-racket-bootstrap.scm b/gnu/packages/chez-and-racket-bootstrap.scm
index dc87e090cb..dea49b7e89 100644
--- a/gnu/packages/chez-and-racket-bootstrap.scm
+++ b/gnu/packages/chez-and-racket-bootstrap.scm
@@ -317,6 +317,19 @@  (define unbundle-chez-submodules
                   "lz4"
                   "zlib"))))
 
+(define unpack-nanopass+stex
+  #~(begin
+      (copy-recursively
+       (dirname (search-input-file %build-inputs
+                                   "lib/chez-scheme/nanopass.ss"))
+       "nanopass"
+       #:keep-mtime? #t)
+      (mkdir-p "stex")
+      (with-output-to-file "stex/Mf-stex"
+        (lambda ()
+          ;; otherwise, it will try to download submodules
+          (display "# to placate ../configure")))))
+
 ;;
 ;; Racket VM:
 ;;
@@ -548,17 +561,8 @@  (define-public chez-scheme
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'unpack-nanopass+stex
-            (lambda* (#:key native-inputs inputs #:allow-other-keys)
-              (copy-recursively
-               (dirname (search-input-file (or native-inputs inputs)
-                                           "lib/chez-scheme/nanopass.ss"))
-               "nanopass"
-               #:keep-mtime? #t)
-              (mkdir-p "stex")
-              (with-output-to-file "stex/Mf-stex"
-                (lambda ()
-                  ;; otherwise, it will try to download submodules
-                  (display "# to placate ../configure")))))
+            (lambda args
+              #$unpack-nanopass+stex))
           (add-after 'unpack-nanopass+stex 'unpack-bootfiles
             (lambda* (#:key native-inputs inputs #:allow-other-keys)
               (when (directory-exists? "boot")
@@ -688,6 +692,111 @@  (define-public chez-scheme-bootstrap-bootfiles
 work with upstream Chez Scheme so that we can bootstrap these files from
 source.")))
 
+(define-public chez-scheme-for-racket
+  (package
+    (inherit chez-scheme)
+    (name "chez-scheme-for-racket")
+    (version "9.5.7.3")
+    ;; The version should match `(scheme-fork-version-number)`.
+    ;; See racket/src/ChezScheme/s/cmacros.ss c. line 360.
+    ;; It will always be different than the upstream version!
+    (source (package-source racket-vm-cgc))
+    (inputs
+     (modify-inputs (package-inputs chez-scheme)
+       (delete "libx11" "util-linux:lib")))
+    (native-inputs
+     (modify-inputs (package-native-inputs chez-scheme)
+       (replace "chez-scheme-bootstrap-bootfiles"
+         chez-scheme-for-racket-bootstrap-bootfiles)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments chez-scheme)
+       ((#:configure-flags cfg-flags #~'())
+        #~(cons "--disable-x11" #$cfg-flags))
+       ((#:phases those-phases #~%standard-phases)
+        #~(modify-phases #$those-phases
+            (add-after 'unpack 'chdir
+              (lambda args
+                (chdir "racket/src/ChezScheme")))))))
+    (supported-systems (filter nix-system->chez-machine
+                               %supported-systems))
+    (home-page "https://github.com/racket/ChezScheme")
+    ;; ^ This is downstream of https://github.com/racket/racket,
+    ;; but it's designed to be a friendly landing place for people
+    ;; who want a ChezScheme-shaped repositroy.
+    (synopsis "Variant of Chez Scheme extended for Racket")
+    (description "This variant of Chez Scheme is extended to support the
+implementation of Racket.  It may be useful on platforms that are not yet
+supported by upstream Chez Scheme.
+
+Main additions to Chez Scheme in the Racket variant:
+@itemize @bullet
+@item
+AArch64 support
+@item
+Portable bytes (@code{pb}) support, which is mainly useful for bootstrapping
+a build on any supported platform
+@item
+Unboxed floating-point arithmetic and flvectors
+@item
+Type reconstruction during optimization (especially for safe code)
+@item
+Continuation attachments
+@item
+Parallel garbage collection, in-place garbage collection for old-generation
+objects (instead of always copying), and reachability-based memory
+accounting
+@item
+Ordered finalization, immobile (but collectable) objects, weak/ephemeron
+generic hash tables, and reference bytevectors
+@item
+Faster multiplication and division for large exact numbers
+@end itemize")
+    (license license:asl2.0)))
+
+(define-public chez-scheme-for-racket-bootstrap-bootfiles
+  (package
+    (inherit chez-scheme-bootstrap-bootfiles)
+    (name "chez-scheme-for-racket-bootstrap-bootfiles")
+    (version (package-version chez-scheme-for-racket))
+    (source (package-source chez-scheme-for-racket))
+    (native-inputs (list chez-nanopass-bootstrap racket-vm-bc))
+    (arguments
+     (substitute-keyword-arguments
+         (package-arguments chez-scheme-bootstrap-bootfiles)
+       ((#:phases those-phases #~%standard-phases)
+        #~(modify-phases #$those-phases
+            (add-after 'unpack 'chdir
+              (lambda args
+                (chdir "racket/src/ChezScheme")))
+            (add-after 'chdir 'unpack-nanopass+stex
+              (lambda args
+                #$unpack-nanopass+stex))
+            (add-before 'install 'build
+              (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                (invoke (search-input-file (or native-inputs inputs)
+                                           "/opt/racket-vm/bin/racket")
+                        "rktboot/main.rkt")))))))
+    (home-page "https://github.com/racket/ChezScheme")
+    ;; ^ This is downstream of https://github.com/racket/racket,
+    ;; but it's designed to be a friendly landing place for people
+    ;; who want a ChezScheme-shaped repositroy.
+    (synopsis "Chez Scheme bootfiles bootstrapped by Racket")
+    (description "Chez Scheme is a self-hosting compiler: building it
+requires ``bootfiles'' containing the Scheme-implemented portions compiled for
+the current platform.  (Chez can then cross-compile bootfiles for all other
+supported platforms.)
+
+The Racket package @code{cs-bootstrap} (part of the main Racket Git
+repository) implements enough of a Chez Scheme simulation to load the Chez
+Scheme compiler purely from source into Racket and apply the compiler to
+itself, thus bootstrapping Chez Scheme.  Bootstrapping takes about 10 times as
+long as using an existing Chez Scheme, but @code{cs-bootstrap} supports Racket
+7.1 and later, including the Racket BC variant.
+
+Note that the generated bootfiles are specific to Racket's fork of Chez
+Scheme, and @code{cs-bootstrap} does not currently support building upstream
+Chez Scheme.")))
+
 ;;
 ;; Chez's bootstrap dependencies:
 ;;