mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
gnu: chez-scheme: Update and simplify machine-type handling.
Since Chez Scheme 10.0.0 supports all of the backends added in Racket's branch, the complexity of '%chez-features-table' is no longer needed. Ideally, even more of this logic could be maintained upstream, but this change will simplify maintenance in the mean time. * gnu/packages/chez.scm (target-chez-arch): Recognize loongarch64. (chez-upsteam-features-for-system): Remove function. (%chez-features-table): Replace with ... (define-machine-types, %machine-types): ... this new macro and variable, using the list copied directly from the Chez Scheme source code. (nix-system->pbarch-machine-type): Update docstring, since pbarch machine types are supported upstream as of Chez Scheme 10.0.0. (racket-cs-native-supported-system?): Replace with ... (nix-system->native-chez-machine-type): ... this new function, implemented using '%machine-types'. (chez-scheme-for-racket): Update accordingly. (chez-scheme-for-racket-bootstrap-bootfiles): Likewise. * gnu/packages/racket.scm (racket-vm-cs): Likewise. Change-Id: I46efebaf48cce388075ab4873c16a6f5f9692bb7 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
c3930c8bb0
commit
9d407205e8
2 changed files with 81 additions and 120 deletions
|
@ -50,7 +50,7 @@
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#: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?
|
nix-system->native-chez-machine-type
|
||||||
nix-system->pbarch-machine-type
|
nix-system->pbarch-machine-type
|
||||||
unpack-nanopass))
|
unpack-nanopass))
|
||||||
|
|
||||||
|
@ -93,6 +93,8 @@ Scheme machine types, or '#f' if none is defined."
|
||||||
"ppc32")
|
"ppc32")
|
||||||
((target-riscv64? system)
|
((target-riscv64? system)
|
||||||
"rv64")
|
"rv64")
|
||||||
|
((string-prefix? "loongarch64-" system)
|
||||||
|
"la64")
|
||||||
(else
|
(else
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
|
@ -127,111 +129,67 @@ in Chez Scheme machine types, or '#f' if none is defined."
|
||||||
(else
|
(else
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
(define %chez-features-table
|
(define-syntax define-machine-types
|
||||||
;; An alist of alists mapping:
|
(lambda (stx)
|
||||||
;; os -> arch -> (or/c #f (listof symbol?))
|
(syntax-case stx (any)
|
||||||
;; where:
|
((_ any id0 id ...)
|
||||||
;; - `os` is a string for the OS part of a Chez Scheme machine type; and
|
#`(define #,(datum->syntax #'id0 '%machine-types)
|
||||||
;; - `arch` is a string for the architecture part of a Chez machine type.
|
'(id0 id ...))))))
|
||||||
;;
|
;; The following is copied from s/cmacros.ss, line 36, in the Chez source
|
||||||
;; The absence of an entry for a given arch--os pair means that neither
|
(define-machine-types
|
||||||
;; upstream Chez Scheme nor the Racket variant can generate native code for
|
any
|
||||||
;; that system. (The Racket variant can still provide support via its
|
pb tpb
|
||||||
;; ``portable bytecode'' backends and optional compilation to C.) A value
|
pb32l tpb32l
|
||||||
;; of `#f` means that upstream Chez Scheme does not support the arch--os
|
pb32b tpb32b
|
||||||
;; pair at all, but the Racket variant does. A list has the same meaning as
|
pb64l tpb64l
|
||||||
;; a result from `chez-upstream-features-for-system`.
|
pb64b tpb64b
|
||||||
;;
|
i3nt ti3nt
|
||||||
;; The arch--os pairs marked "commented out" have been commented out in the
|
i3osx ti3osx
|
||||||
;; STeX source for the upstream release notes since the initial release as
|
i3le ti3le
|
||||||
;; free software, but they are reported to work and/or have been described
|
i3fb ti3fb
|
||||||
;; as supported by upstream maintainers.
|
i3ob ti3ob
|
||||||
;;
|
i3nb ti3nb
|
||||||
;; For this overall approach to make sense, we assume that Racket's variant
|
i3s2 ti3s2
|
||||||
;; of Chez Scheme can generate native code for a superset of the platforms
|
i3qnx ti3qnx
|
||||||
;; supported upstream, supports threads on all platforms it supports at all
|
i3gnu ti3gnu
|
||||||
;; (because they are needed for Racket), and doesn't need bootstrap
|
a6nt ta6nt
|
||||||
;; bootfiles. Those assumptions have held for several years.
|
a6osx ta6osx
|
||||||
'(;; Linux
|
a6le ta6le
|
||||||
("le"
|
a6fb ta6fb
|
||||||
("i3" threads bootstrap-bootfiles)
|
a6ob ta6ob
|
||||||
("a6" threads bootstrap-bootfiles)
|
a6nb ta6nb
|
||||||
("arm32" bootstrap-bootfiles)
|
a6s2 ta6s2
|
||||||
("arm64" . #f)
|
ppc32osx tppc32osx
|
||||||
("rv64" . #f)
|
ppc32le tppc32le
|
||||||
("ppc32" threads))
|
ppc32fb tppc32fb
|
||||||
;; Hurd
|
ppc32ob tppc32ob
|
||||||
("gnu"
|
ppc32nb tppc32nb
|
||||||
("i3" . #f))
|
arm32le tarm32le
|
||||||
;; FreeBSD
|
arm32fb tarm32fb
|
||||||
("fb"
|
arm32ob tarm32ob
|
||||||
("i3" threads) ;; commented out
|
arm32nb tarm32nb
|
||||||
("a6" threads) ;; commented out
|
arm64nt tarm64nt
|
||||||
("arm32" . #f)
|
arm64osx tarm64osx
|
||||||
("arm64" . #f)
|
arm64le tarm64le
|
||||||
("ppc32" . #f))
|
arm64fb tarm64fb
|
||||||
;; OpenBSD
|
arm64ob tarm64ob
|
||||||
("ob"
|
arm64nb tarm64nb
|
||||||
("i3" threads) ;; commented out
|
rv64le trv64le
|
||||||
("a6" threads) ;; commented out
|
rv64fb trv64fb
|
||||||
("arm32" . #f)
|
rv64ob trv64ob
|
||||||
("arm64" . #f)
|
rv64nb trv64nb
|
||||||
("ppc32" . #f))
|
la64le tla64le
|
||||||
;; NetBSD
|
)
|
||||||
("nb"
|
|
||||||
("i3" threads) ;; commented out
|
|
||||||
("a6" threads) ;; commented out
|
|
||||||
("arm32" . #f)
|
|
||||||
("arm64" . #f)
|
|
||||||
("ppc32" . #f))
|
|
||||||
;; OpenSolaris / OpenIndiana / Illumos
|
|
||||||
("s2"
|
|
||||||
("i3" threads) ;; commented out
|
|
||||||
("a6" threads)) ;; commented out
|
|
||||||
;; QNX
|
|
||||||
("qnx"
|
|
||||||
("i3" . #f))
|
|
||||||
;; Windows
|
|
||||||
("nt"
|
|
||||||
("i3" threads bootstrap-bootfiles)
|
|
||||||
("a6" threads bootstrap-bootfiles)
|
|
||||||
;; ^ threads "experiemental", but reportedly fine
|
|
||||||
("arm64" . #f))
|
|
||||||
;; Darwin
|
|
||||||
("osx"
|
|
||||||
("i3" threads bootstrap-bootfiles)
|
|
||||||
("a6" threads bootstrap-bootfiles)
|
|
||||||
("arm64" . #f)
|
|
||||||
("ppc32" . #f))))
|
|
||||||
|
|
||||||
(define* (chez-upstream-features-for-system #:optional
|
|
||||||
(system
|
|
||||||
(or (%current-target-system)
|
|
||||||
(%current-system))))
|
|
||||||
"Return a list of symbols naming features supported by upstream Chez Scheme
|
|
||||||
for the Nix system identifier SYSTEM, or @code{#f} if upstream Chez Scheme
|
|
||||||
does not support SYSTEM at all.
|
|
||||||
|
|
||||||
If native threads are supported, the returned list will include
|
|
||||||
@code{'threads}. If bootstrap bootfiles for SYSTEM are distributed in the
|
|
||||||
upstream Chez Scheme repository, the returned list will include
|
|
||||||
@code{'bootstrap-bootfiles}. Other feature symbols may be added in the
|
|
||||||
future."
|
|
||||||
(let ((chez-arch (target-chez-arch system))
|
|
||||||
(chez-os (target-chez-os system)))
|
|
||||||
(and=> (assoc-ref %chez-features-table chez-os)
|
|
||||||
(cut assoc-ref <> chez-arch))))
|
|
||||||
|
|
||||||
(define* (nix-system->pbarch-machine-type #:optional
|
(define* (nix-system->pbarch-machine-type #:optional
|
||||||
(system
|
(system
|
||||||
(or (%current-target-system)
|
(or (%current-target-system)
|
||||||
(%current-system)))
|
(%current-system)))
|
||||||
#:key (threads? #t))
|
#:key (threads? #t))
|
||||||
"Return a string naming the pseudo–machine type used by Racket's variant of
|
"Return a string naming the Chez Scheme machine type of the appropriate
|
||||||
Chez Scheme to represent the appropriate ``pbarch'' backend for SYSTEM: that
|
``pbarch'' backend for SYSTEM: that is, the ``portable bytecode'' backend
|
||||||
is, the ``portable bytecode'' backend specialized for SYSTEM's word size and
|
specialized for SYSTEM's word size and endianness. The result will name the
|
||||||
endianness. The result will name the threaded machine type unless THREADS? is
|
threaded machine type unless THREADS? is provided as #f."
|
||||||
provided and is #f."
|
|
||||||
(string-append (if threads?
|
(string-append (if threads?
|
||||||
"t"
|
"t"
|
||||||
"")
|
"")
|
||||||
|
@ -243,20 +201,23 @@ provided and is #f."
|
||||||
"l"
|
"l"
|
||||||
"b")))
|
"b")))
|
||||||
|
|
||||||
(define* (racket-cs-native-supported-system? #:optional
|
(define* (nix-system->native-chez-machine-type #:optional
|
||||||
(system
|
(system
|
||||||
(or (%current-target-system)
|
(or (%current-target-system)
|
||||||
(%current-system))))
|
(%current-system)))
|
||||||
"Can Racket's variant of Chez Scheme generate native code for SYSTEM? If
|
#:key (threads? #t))
|
||||||
so, return the applicable machine type as a string. Otherwise, when SYSTEM
|
"Return a string naming the Chez Scheme machine type of the native-code
|
||||||
can use only the ``portable bytecode'' backends, return #f."
|
backend for SYSTEM, if such a native-code backend exists. Otherwise, when
|
||||||
(let ((chez-arch (target-chez-arch system))
|
SYSTEM can use only the ``portable bytecode'' backends, return #f. The result
|
||||||
(chez-os (target-chez-os system)))
|
will name the threaded machine type unless THREADS? is provided as #f."
|
||||||
(and (and=> (assoc-ref %chez-features-table chez-os)
|
(let* ((chez-arch (target-chez-arch system))
|
||||||
;; NOT assoc-ref: supported even if cdr is #f
|
(chez-os (target-chez-os system))
|
||||||
(cut assoc chez-arch <>))
|
(machine
|
||||||
(string-append "t" chez-arch chez-os))))
|
(and chez-arch chez-os
|
||||||
|
(string-append (if threads? "t" "") chez-arch chez-os))))
|
||||||
|
(and machine
|
||||||
|
(memq (string->symbol machine) %machine-types)
|
||||||
|
machine)))
|
||||||
;;
|
;;
|
||||||
;; Chez Scheme:
|
;; Chez Scheme:
|
||||||
;;
|
;;
|
||||||
|
@ -300,7 +261,7 @@ can use only the ``portable bytecode'' backends, return #f."
|
||||||
(version "9.9.9-pre-release.23")
|
(version "9.9.9-pre-release.23")
|
||||||
(source #f)
|
(source #f)
|
||||||
(build-system gnu-build-system)
|
(build-system gnu-build-system)
|
||||||
(inputs `(,@(if (racket-cs-native-supported-system?)
|
(inputs `(,@(if (nix-system->native-chez-machine-type)
|
||||||
'()
|
'()
|
||||||
(list libffi))
|
(list libffi))
|
||||||
,chez-scheme-for-racket-bootstrap-bootfiles
|
,chez-scheme-for-racket-bootstrap-bootfiles
|
||||||
|
@ -353,10 +314,10 @@ can use only the ``portable bytecode'' backends, return #f."
|
||||||
(search-input-directory %build-inputs "/include/X11"))
|
(search-input-directory %build-inputs "/include/X11"))
|
||||||
'()
|
'()
|
||||||
'("--disable-x11"))
|
'("--disable-x11"))
|
||||||
#$(string-append "-m=" (or (racket-cs-native-supported-system?)
|
#$(string-append "-m=" (or (nix-system->native-chez-machine-type)
|
||||||
(nix-system->pbarch-machine-type)))
|
(nix-system->pbarch-machine-type)))
|
||||||
;; ^ could skip -m= for non-cross non-pbarch builds
|
;; ^ could skip -m= for non-cross non-pbarch builds
|
||||||
#$@(if (racket-cs-native-supported-system?)
|
#$@(if (nix-system->native-chez-machine-type)
|
||||||
#~()
|
#~()
|
||||||
;; not inferred on non-native platforms: see
|
;; not inferred on non-native platforms: see
|
||||||
;; https://racket.discourse.group/t/950/9
|
;; https://racket.discourse.group/t/950/9
|
||||||
|
@ -588,7 +549,7 @@ with reliability taking precedence over efficiency if necessary.")
|
||||||
(invoke "./configure"
|
(invoke "./configure"
|
||||||
"--force" ; don't complain about missing bootfiles
|
"--force" ; don't complain about missing bootfiles
|
||||||
#$(string-append
|
#$(string-append
|
||||||
"-m=" (or (racket-cs-native-supported-system?)
|
"-m=" (or (nix-system->native-chez-machine-type)
|
||||||
(nix-system->pbarch-machine-type)))
|
(nix-system->pbarch-machine-type)))
|
||||||
"ZUO=zuo"
|
"ZUO=zuo"
|
||||||
;; ignore submodules:
|
;; ignore submodules:
|
||||||
|
|
|
@ -433,7 +433,7 @@ collector, 3M (``Moving Memory Manager'').")
|
||||||
(inputs
|
(inputs
|
||||||
(let ((inputs (modify-inputs (package-inputs racket-vm-cgc)
|
(let ((inputs (modify-inputs (package-inputs racket-vm-cgc)
|
||||||
(prepend zlib lz4))))
|
(prepend zlib lz4))))
|
||||||
(if (racket-cs-native-supported-system?)
|
(if (nix-system->native-chez-machine-type)
|
||||||
(modify-inputs inputs
|
(modify-inputs inputs
|
||||||
(delete "libffi"))
|
(delete "libffi"))
|
||||||
inputs)))
|
inputs)))
|
||||||
|
@ -461,7 +461,7 @@ 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?)
|
#$@(if (nix-system->native-chez-machine-type)
|
||||||
#~()
|
#~()
|
||||||
#~(#$(string-append "--enable-mach="
|
#~(#$(string-append "--enable-mach="
|
||||||
(nix-system->pbarch-machine-type))
|
(nix-system->pbarch-machine-type))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue