gnu: chez-scheme: Explicitly package bootstrap bootfiles.

This makes the structure of the upstream Chez Scheme package the same as
for the Racket variant, it sets things up for (one day, hopefully)
actually being able to bootstrap the upstream Chez Scheme bootfiles, and
it may be useful for cross-compilation and adding support for
architectures without pre-built bootfiles from upstream.

* gnu/packages/chez.scm (chez-scheme-bootstrap-bootfiles): New
variable.
(chez-scheme)[native-inputs]: Add it.
[arguments]<#:phases>: Add 'unpack-bootfiles'.
(chez-scheme-for-racket-bootstrap-bootfiles): Inherit from
'chez-scheme-bootstrap-bootfiles'.
[arguments]: Adapt accordingly.

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
This commit is contained in:
Philip McGrath 2022-02-27 16:29:16 -05:00 committed by Liliana Marie Prikler
parent 6bca38f282
commit f79049caae
No known key found for this signature in database
GPG key ID: 442A84B8C70E2F87

View file

@ -46,6 +46,7 @@
#:use-module (gnu packages xorg) #:use-module (gnu packages xorg)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (nix-system->chez-machine #:export (nix-system->chez-machine
chez-machine->nonthreaded chez-machine->nonthreaded
chez-machine->threaded chez-machine->threaded
@ -211,7 +212,9 @@ If native threads are supported, the returned list will include
;; for X11 clipboard support in expeditor: ;; for X11 clipboard support in expeditor:
;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232 ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
libx11)) libx11))
(native-inputs (list chez-nanopass-bootstrap stex-bootstrap)) (native-inputs (list chez-scheme-bootstrap-bootfiles
chez-nanopass-bootstrap
stex-bootstrap))
(native-search-paths (native-search-paths
(list (search-path-specification (list (search-path-specification
(variable "CHEZSCHEMELIBDIRS") (variable "CHEZSCHEMELIBDIRS")
@ -232,6 +235,14 @@ If native threads are supported, the returned list will include
(add-after 'unpack 'unpack-nanopass+stex (add-after 'unpack 'unpack-nanopass+stex
(lambda args (lambda args
#$unpack-nanopass+stex)) #$unpack-nanopass+stex))
(add-after 'unpack-nanopass+stex 'unpack-bootfiles
(lambda* (#:key native-inputs inputs #:allow-other-keys)
(when (directory-exists? "boot")
(delete-file-recursively "boot"))
(copy-recursively
(search-input-directory (or native-inputs inputs)
"lib/chez-scheme-bootfiles")
"boot")))
;; NOTE: the custom Chez 'configure' script doesn't allow ;; NOTE: the custom Chez 'configure' script doesn't allow
;; unrecognized flags, such as those automatically added ;; unrecognized flags, such as those automatically added
;; by `gnu-build-system`. ;; by `gnu-build-system`.
@ -316,8 +327,46 @@ generates native code for each target processor, with support for x86, x86_64,
and 32-bit PowerPC architectures.") and 32-bit PowerPC architectures.")
(license asl2.0))) (license asl2.0)))
(define-public chez-scheme-bootstrap-bootfiles
(package
(inherit chez-scheme)
(name "chez-scheme-bootstrap-bootfiles")
(inputs '())
(native-inputs '())
(outputs '("out"))
(build-system copy-build-system)
;; TODO: cross compilation
(arguments
(list #:install-plan
#~`(("boot/" "lib/chez-scheme-bootfiles"))))
(supported-systems
;; Upstream only distributes pre-built bootfiles for
;; arm32le and t?(i3|a6)(le|nt|osx)
(filter (lambda (system)
(let ((machine (and=> (nix-system->chez-machine system)
chez-machine->nonthreaded)))
(or (equal? "arm32le" machine)
(and machine
(member (substring machine 0 2) '("i3" "a6"))
(or-map (cut string-suffix? <> machine)
'("le" "nt" "osx"))))))
%supported-systems))
(synopsis "Chez Scheme bootfiles (binary seed)")
(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.)
This package provides bootstrap bootfiles for upstream Chez Scheme.
Currently, it simply packages the binaries checked in to the upsream
repository. Hopefully we can eventually adapt Racket's @code{cs-bootstrap} to
work with upstream Chez Scheme so that we can bootstrap these files from
source.")))
(define-public chez-scheme-for-racket-bootstrap-bootfiles (define-public chez-scheme-for-racket-bootstrap-bootfiles
(package (package
(inherit chez-scheme-bootstrap-bootfiles)
(name "chez-scheme-for-racket-bootstrap-bootfiles") (name "chez-scheme-for-racket-bootstrap-bootfiles")
(version "9.5.7.3") (version "9.5.7.3")
;; The version should match `(scheme-fork-version-number)`. ;; The version should match `(scheme-fork-version-number)`.
@ -325,32 +374,30 @@ and 32-bit PowerPC architectures.")
;; It will always be different than the upstream version! ;; It will always be different than the upstream version!
;; 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 `())
(native-inputs (list chez-nanopass-bootstrap racket-vm-bc)) (native-inputs (list chez-nanopass-bootstrap racket-vm-bc))
(build-system copy-build-system)
;; TODO: cross compilation ;; TODO: cross compilation
(arguments (arguments
(list (substitute-keyword-arguments
#:install-plan (package-arguments chez-scheme-bootstrap-bootfiles)
#~`(("boot/" "lib/chez-scheme-bootfiles")) ((#:phases those-phases #~%standard-phases)
#:phases #~(let* ((those-phases #$those-phases)
#~(let ((unpack (assoc-ref %standard-phases 'unpack))) (unpack (assoc-ref those-phases 'unpack)))
(modify-phases %standard-phases (modify-phases those-phases
(replace 'unpack (replace 'unpack
(lambda args (lambda args
(unpack #:source #$(or (package-source this-package) (unpack #:source #$(or (package-source this-package)
(package-source racket-vm-bc))))) (package-source racket-vm-bc)))))
(add-after 'unpack 'chdir (add-after 'unpack 'chdir
(lambda args (lambda args
(chdir "racket/src/ChezScheme"))) (chdir "racket/src/ChezScheme")))
(add-after 'chdir 'unpack-nanopass+stex (add-after 'chdir 'unpack-nanopass+stex
(lambda args (lambda args
#$unpack-nanopass+stex)) #$unpack-nanopass+stex))
(add-before 'install 'build (add-before 'install 'build
(lambda* (#:key native-inputs inputs #:allow-other-keys) (lambda* (#:key native-inputs inputs #:allow-other-keys)
(invoke (search-input-file (or native-inputs inputs) (invoke (search-input-file (or native-inputs inputs)
"/opt/racket-vm/bin/racket") "/opt/racket-vm/bin/racket")
"rktboot/main.rkt"))))))) "rktboot/main.rkt"))))))))
(supported-systems (filter nix-system->chez-machine (supported-systems (filter nix-system->chez-machine
%supported-systems)) %supported-systems))
(home-page "https://github.com/racket/ChezScheme") (home-page "https://github.com/racket/ChezScheme")
@ -372,8 +419,7 @@ long as using an existing Chez Scheme, but @code{cs-bootstrap} supports Racket
Note that the generated bootfiles are specific to Racket's fork of Chez Note that the generated bootfiles are specific to Racket's fork of Chez
Scheme, and @code{cs-bootstrap} does not currently support building upstream Scheme, and @code{cs-bootstrap} does not currently support building upstream
Chez Scheme.") Chez Scheme.")))
(license (list asl2.0))))
;; ;;
;; Chez's bootstrap dependencies: ;; Chez's bootstrap dependencies: