summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorPhilip McGrath <philip@philipmcgrath.com>2024-04-01 02:51:13 -0400
committerLudovic Courtès <ludo@gnu.org>2024-04-11 12:46:41 +0200
commit4e7337536ba41e888a601c92fada8a4adca9d2c6 (patch)
tree5b0c4b8da0f544c44c0228a00486792aa61a3a94 /gnu
parent9d407205e8e711218e3bfa50ab6e2f55b0df623d (diff)
gnu: chez-scheme: Bootstrap from source.
* gnu/packages/chez.scm (chez-scheme)[source]<snippet>: Also unbundle pre-built boot files. (chez-scheme-bootstrap-bootfiles): Stop inheriting from 'chez-scheme'. [native-inputs]: Add 'zuo', 'chez-nanopass-bootstrap', and either 'chez-scheme-for-racket' or, for cross builds, 'chez-scheme'. [build-system]: Change to gnu-build-system. [arguments]: Change to run 'configure' and then bootstrap via `make re.boot` or, for cross builds, `make cross.boot` [synopsis, description]: Update accordingly. (chez-scheme-for-racket-bootstrap-bootfiles)[synopsis]: Write "boot files" as two words in prose. [description]: Likewise. * gnu/packages/racket.scm: Update comments. Change-Id: I55d9b57090ecaca0aa2ab19c2c3ebae2243a9173 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/chez.scm123
-rw-r--r--gnu/packages/racket.scm24
2 files changed, 112 insertions, 35 deletions
diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm
index 4d3f79d9a72..db582fa8210 100644
--- a/gnu/packages/chez.scm
+++ b/gnu/packages/chez.scm
@@ -57,15 +57,54 @@
57;; Commentary: 57;; Commentary:
58;; 58;;
59;; The bootstrapping paths for Chez Scheme and Racket are closely 59;; The bootstrapping paths for Chez Scheme and Racket are closely
60;; entwined. Racket CS (the default Racket implementation) is based on (a fork 60;; entwined. See "Bootstrapping Racket" in the commentary on "racket.scm" for
61;; of) Chez Scheme. Racket's variant of Chez Scheme shares sources for 61;; details on the Racket portion of Chez Scheme's bootstrapping path.
62;; nanopass and stex with upstream Chez Scheme.
63;; 62;;
64;; Racket's variant of Chez Scheme can be bootstrapped by an older Racket 63;; Chez Scheme is a self-hosting compiler. A small kernel implemented in C
65;; implementation, Racket BC, which can be bootstrapped from C. Porting that 64;; loads "boot files" (in a custom object file format) compiled from the parts
66;; code to work with upstream Chez Scheme (or finding an old version that 65;; of the system implemented in Chez Scheme. (While Chez Scheme generates
67;; does) is our best hope for some day bootstrapping upstream Chez Scheme from 66;; native machine code, it implements its own linker and loader.)
68;; source. 67;;
68;; As of Chez Scheme 10.0.0 (and the pre-release versions that preceded it on
69;; the Racket branch), there are several ways to obtain boot files:
70;;
71;; 1. The Racket package "cs-bootstrap" (in the "racket/src/rktboot/"
72;; directory of the main Racket Git repository) simulates enough of Chez
73;; Scheme to load the Chez Scheme compiler purely from source into Racket
74;; and apply the compiler to itself, producing the needed boot files
75;; (albeit very slowly).
76;; Any variant of Racket since version 7.1 can run the simulation. Using
77;; the older Racket BC implementation, which does not depend on Chez
78;; Scheme, breaks the dependency cycle.
79;; However, the simulation relies on implementation details of Chez
80;; Scheme, so a given version of Chez Scheme can only be bootstrapped by
81;; the corresponding version of the "cs-bootstrap" package.
82;;
83;; 2. The Chez Scheme makefile provides a "re.boot" target for bootstrapping
84;; via a different version of Chez Scheme (9.5.4 or later).
85;; This path manages potential differences in implementation details
86;; across Chez Scheme versions using a strategy similar to "cs-bootstrap",
87;; but the compatibility shim is maintained with the Chez Scheme source
88;; code (in "s/reboot.ss"). Also, it's faster, since less indirection is
89;; needed.
90;;
91;; 3. For cross-compilation, or with an extremely similar Chez Scheme, the
92;; makefile provides "cross.boot" and related targets.
93;;
94;; 4. The Chez Scheme Git repository includes pre-built "pb" (portable
95;; bytecode) boot files, which can be used for bootstrapping on any
96;; platform, but these binary files are removed from the source Guix uses.
97;;
98;; Concretely, we use racket-vm-bc to bootstrap chez-scheme-for-racket, which
99;; we then use to bootstrap both chez-scheme and racket-vm-cs.
100;;
101;; In principle, it would be possible instead to use chez-scheme to bootstrap
102;; chez-scheme-for-racket. However, since Racket is ultimately used for
103;; bootstrapping, chez-scheme would still need to be rebuilt when Racket
104;; changes, whereas treating chez-scheme as a leaf avoids having to rebuild
105;; Racket when upstream Chez Scheme changes. Furthermore, since "cs-bootstrap"
106;; is developed in the Racket source repository, we don't have to look for the
107;; version of "cs-bootstrap" compatible with the upstream Chez Scheme release.
69;; 108;;
70;; Code: 109;; Code:
71 110
@@ -479,7 +518,8 @@ version of Chez Scheme.")
479 (for-each (lambda (dir) 518 (for-each (lambda (dir)
480 (when (directory-exists? dir) 519 (when (directory-exists? dir)
481 (delete-file-recursively dir))) 520 (delete-file-recursively dir)))
482 '("lz4" 521 '("boot"
522 "lz4"
483 "nanopass" 523 "nanopass"
484 "stex" 524 "stex"
485 "zlib" 525 "zlib"
@@ -575,10 +615,10 @@ with reliability taking precedence over efficiency if necessary.")
575 "/opt/racket-vm/bin/racket") 615 "/opt/racket-vm/bin/racket")
576 "../rktboot/main.rkt")))))))) 616 "../rktboot/main.rkt"))))))))
577 (home-page "https://pkgs.racket-lang.org/package/cs-bootstrap") 617 (home-page "https://pkgs.racket-lang.org/package/cs-bootstrap")
578 (synopsis "Chez Scheme bootfiles bootstrapped by Racket") 618 (synopsis "Chez Scheme boot files bootstrapped by Racket")
579 (description "Chez Scheme is a self-hosting compiler: building it 619 (description "Chez Scheme is a self-hosting compiler: building it requires
580requires ``bootfiles'' containing the Scheme-implemented portions compiled for 620``boot files'' containing the Scheme-implemented portions compiled for the
581the current platform. (Chez can then cross-compile bootfiles for all other 621current platform. (Chez can then cross-compile boot files for all other
582supported platforms.) 622supported platforms.)
583 623
584The Racket package @code{cs-bootstrap} (part of the main Racket Git 624The Racket package @code{cs-bootstrap} (part of the main Racket Git
@@ -591,28 +631,57 @@ long as using an existing Chez Scheme, but @code{cs-bootstrap} supports Racket
591 631
592(define-public chez-scheme-bootstrap-bootfiles 632(define-public chez-scheme-bootstrap-bootfiles
593 (package 633 (package
594 (inherit chez-scheme)
595 (name "chez-scheme-bootstrap-bootfiles") 634 (name "chez-scheme-bootstrap-bootfiles")
596 (inputs '()) 635 (version (package-version chez-scheme))
597 (native-inputs '()) 636 (source (package-source chez-scheme))
637 (native-inputs (list chez-nanopass-bootstrap
638 (if (%current-target-system)
639 chez-scheme
640 chez-scheme-for-racket)
641 zuo))
598 (outputs '("out")) 642 (outputs '("out"))
599 (build-system copy-build-system) 643 (build-system gnu-build-system)
600 ;; TODO: cross compilation
601 (arguments 644 (arguments
602 (list #:install-plan 645 (list
603 #~`(("boot/" "lib/chez-scheme-bootfiles")))) 646 #:configure-flags
604 (synopsis "Chez Scheme bootfiles (binary seed)") 647 #~`("--force" ; don't complain about missing bootfiles
648 "ZLIB=-lz" "LZ4=-llz4" "STEXLIB=/GuixNotUsingStex" ; ignore submods
649 "ZUO=zuo"
650 ;; could skip -m= for non-cross non-pbarch builds
651 #$(string-append "-m=" (or (nix-system->native-chez-machine-type)
652 (nix-system->pbarch-machine-type))))
653 #:make-flags
654 #~(list (string-append "SCHEME="
655 (search-input-file %build-inputs "/bin/scheme"))
656 #$(if (%current-target-system)
657 "cross.boot"
658 "re.boot"))
659 #:phases
660 #~(modify-phases %standard-phases
661 (add-after 'unpack 'unpack-nanopass
662 #$unpack-nanopass)
663 (replace 'configure
664 #$chez-configure)
665 (delete 'check)
666 (replace 'install
667 (lambda args
668 (mkdir-p (string-append #$output "/lib"))
669 (copy-recursively
670 "boot"
671 (string-append #$output "/lib/chez-scheme-bootfiles")))))))
672 (home-page "https://cisco.github.io/ChezScheme/")
673 (synopsis "Bootstrapped Chez Scheme boot files")
605 (description 674 (description
606 "Chez Scheme is a self-hosting compiler: building it requires 675 "Chez Scheme is a self-hosting compiler: building it requires
607``bootfiles'' containing the Scheme-implemented portions compiled for the 676``boot files'' containing the Scheme-implemented portions compiled for the
608current platform. (Chez can then cross-compile bootfiles for all other 677current platform. (Chez can then cross-compile bootfiles for all other
609supported platforms.) 678supported platforms.)
610 679
611This package provides bootstrap bootfiles for upstream Chez Scheme. 680This package provides boot files for the released version of Chez Scheme
612Currently, it simply packages the binaries checked in to the upstream 681bootstrapped by @code{chez-scheme-for-racket}. Chez Scheme 9.5.4 or any later
613repository. Hopefully we can eventually adapt Racket's @code{cs-bootstrap} to 682version can be used for bootstrapping. Guix ultimately uses the Racket package
614work with upstream Chez Scheme so that we can bootstrap these files from 683@code{cs-bootstrap} to bootstrap its initial version of Chez Scheme.")
615source."))) 684 (license asl2.0)))
616 685
617;; 686;;
618;; Chez's bootstrap dependencies: 687;; Chez's bootstrap dependencies:
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index f50f6f3eab3..2b203531592 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -72,6 +72,7 @@
72;; ├── bc/ 72;; ├── bc/
73;; ├── cs/ 73;; ├── cs/
74;; ├── ChezScheme/ 74;; ├── ChezScheme/
75;; ├── rktboot/
75;; ├── zuo/ 76;; ├── zuo/
76;; └── ... 77;; └── ...
77;; 78;;
@@ -149,14 +150,12 @@
149;; - Racket BC [3M] needs an existing Racket to run "xform", 150;; - Racket BC [3M] needs an existing Racket to run "xform",
150;; which transforms its own C source code to add additional annotations 151;; which transforms its own C source code to add additional annotations
151;; for the precise garbage collector. 152;; for the precise garbage collector.
152;; - Racket CS needs (bootfiles for) Racket's fork of Chez Scheme. 153;; - Racket CS needs (boot files for) the corresponding version of Chez
153;; It also needs an existing Racket to compile Racket-implemented 154;; Scheme. It also needs an existing Racket to compile Racket-implemented
154;; parts of the runtime system to R6RS libraries. 155;; parts of the runtime system to R6RS libraries.
155;; - Chez Scheme also needs bootfiles for itself, but Racket can simulate 156;; - Chez Scheme also needs boot files for itself, but Racket BC can
156;; enough of Chez Scheme to load Racket's fork of the Chez Scheme compiler 157;; bootstrap these using the code in "racket/src/rktboot/".
157;; purely from source into Racket and apply the compiler to itself, 158;; See the commentary in "chez.scm" for further details
158;; producing the needed bootfiles (albeit very slowly).
159;; Any variant of Racket since version 7.1 can run the simulation.
160;; 159;;
161;; So, we build CGC to build 3M to build bootfiles and CS. 160;; So, we build CGC to build 3M to build bootfiles and CS.
162;; 161;;
@@ -164,6 +163,14 @@
164;; often use "BC" to mean "3M", consistent with `(banner)` and the 163;; often use "BC" to mean "3M", consistent with `(banner)` and the
165;; suffixes used on executables when more than one variant co-exists.) 164;; suffixes used on executables when more than one variant co-exists.)
166;; 165;;
166;; Since the pre-releases for Chez Scheme 10.0.0, all of Racket's changes have
167;; been merged upstream, and development will be kept in sync going
168;; forward. However, there is no plan to align the Chez Scheme and Racket
169;; release cycles. For the near fulture, a given released version of Racket
170;; will continue to depend on a specific pre-release version of Chez Scheme as
171;; part of Racket CS's "ABI". See upstream discussion at
172;; <https://racket.discourse.group/t/2739/3>.
173;;
167;; One remaining bootstrapping limitation is that Racket's reader, module 174;; One remaining bootstrapping limitation is that Racket's reader, module
168;; system, and macro expander are implemented in Racket. For Racket CS, 175;; system, and macro expander are implemented in Racket. For Racket CS,
169;; they are compiled to R6RS libraries as discussed above. This note from the 176;; they are compiled to R6RS libraries as discussed above. This note from the
@@ -189,7 +196,8 @@
189;; Zuo is notably *not* a problem for bootstrapping. The implementation is a 196;; Zuo is notably *not* a problem for bootstrapping. The implementation is a
190;; single hand-written C file designed to build with just `cc -o zuo zuo.c`, 197;; single hand-written C file designed to build with just `cc -o zuo zuo.c`,
191;; even with very old or limited compilers. (We use the Autoconf support for 198;; even with very old or limited compilers. (We use the Autoconf support for
192;; convienience.) 199;; convienience.) As of Zuo 1.8, Zuo has tagged releases in its own repository
200;; independent of the Racket release cycle.
193;; 201;;
194;; CODE: 202;; CODE:
195 203