From f032a41f419f6304069820695366a5d00a4e9066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Sat, 9 May 2026 16:17:03 +0200 Subject: [PATCH] gnu: chicken: Bootstrap from Scheme source code. The CHICKEN compiler is itself written in CHICKEN. To mitigate the compiler bootstrapping problem, the CHICKEN release tarball includes auto-generated C code, from which the CHICKEN compiler is build using a C compiler. However, if we want to patch the CHICKEN Scheme source (for #8471), we need to be able to build the CHICKEN compiler from its Scheme source files. This is achieved here by separate the build into two packages chicken-bootstrap (build from the auto-generated C code) and chicken (build from the Scheme source). Note that this still isn't a full-source bootstrap, we still require the auto-generated C source code, but at least we can now patch the package based on the Scheme source. Hence, it improves the situation. See also: https://issues.guix.gnu.org/22366 * gnu/packages/chicken.scm (chicken-bootstrap): Rename from chicken. * gnu/packages/chicken.scm (chicken): New package. Change-Id: Ie656e95e2112241b066158a62e55ac07c722c150 Signed-off-by: Liliana Marie Prikler --- gnu/packages/chicken.scm | 127 ++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 47 deletions(-) diff --git a/gnu/packages/chicken.scm b/gnu/packages/chicken.scm index a499c5d9ee4..42b72e10a76 100644 --- a/gnu/packages/chicken.scm +++ b/gnu/packages/chicken.scm @@ -20,65 +20,98 @@ (define-module (gnu packages chicken) #:use-module (gnu packages) + #:use-module (guix gexp) #:use-module (guix packages) + #:use-module (guix utils) #:use-module (guix build-system chicken) #:use-module (guix build-system gnu) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix svn-download) #:use-module ((guix licenses) - #:prefix license:)) + #:prefix license:) + #:use-module (srfi srfi-1)) +;; This package is build from pre-built C source code, provided in the CHICKEN +;; release tarball. Based on this bootstrap compiler, we build CHICKEN from +;; the Scheme source, thus enabling us to (at least) patch it. +;; +;; See . +(define-public chicken-bootstrap + (hidden-package + (package + (name "chicken-bootstrap") + (version "5.4.0") + (source (origin + (method url-fetch) + (uri (string-append "https://code.call-cc.org/releases/" + version "/chicken-" version ".tar.gz")) + (sha256 + (base32 + "0pzcrnzkjw2sa44vy59wbygvlc3nva8zisprkdnvyrqi3jk4lp9w")))) + (build-system gnu-build-system) + (arguments + `(#:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-1)) + + ;; No `configure' script; run "make check" after "make install" as + ;; prescribed by README. + #:phases + (modify-phases %standard-phases + (delete 'configure) + (delete 'check) + (add-after 'install 'check + (assoc-ref %standard-phases 'check))) + + #:make-flags (let ((out (assoc-ref %outputs "out"))) + (list "PLATFORM=linux" + (string-append "PREFIX=" out) + (string-append "VARDIR=" out "/var/lib"))) + + ;; Parallel builds are not supported, as noted in README. + #:parallel-build? #f)) + (native-search-paths + (list (search-path-specification + (variable "CHICKEN_REPOSITORY_PATH") + ;; TODO extract binary version into a module level definition. + (files (list "var/lib/chicken/11"))))) + ;; Reference gcc-toolchain lazily to avoid circular module dependency + ;; problems. + (propagated-inputs (list (module-ref (resolve-interface + '(gnu packages commencement)) + 'gcc-toolchain))) + (home-page "https://www.call-cc.org/") + (synopsis "R5RS Scheme implementation that compiles native code via C") + (description + "CHICKEN is a compiler for the Scheme programming language. CHICKEN +pr oduces portable and efficient C, supports almost all of the R5RS Scheme +la nguage standard, and includes many enhancements and extensions.") + (license license:bsd-3)))) + +;; The CHICKEN compiler is itself written in CHICKEN, the CHICKEN release +;; tarballs includes auto-generated C code to mitigate the compiler +;; bootstrapping problem. To be able to patch the original Scheme source, +;; we compile from this Scheme source here using the chicken-bootstrap +;; compiler obtained from the autogenerated C code. +;; +;; See . (define-public chicken (package + (inherit chicken-bootstrap) (name "chicken") - (version "5.4.0") - (source (origin - (method url-fetch) - (uri (string-append "https://code.call-cc.org/releases/" - version "/chicken-" version ".tar.gz")) - (sha256 - (base32 - "0pzcrnzkjw2sa44vy59wbygvlc3nva8zisprkdnvyrqi3jk4lp9w")))) - (build-system gnu-build-system) (arguments - `(#:modules ((guix build gnu-build-system) - (guix build utils) - (srfi srfi-1)) - - ;; No `configure' script; run "make check" after "make install" as - ;; prescribed by README. - #:phases - (modify-phases %standard-phases - (delete 'configure) - (delete 'check) - (add-after 'install 'check - (assoc-ref %standard-phases 'check))) - - #:make-flags (let ((out (assoc-ref %outputs "out"))) - (list "PLATFORM=linux" - (string-append "PREFIX=" out) - (string-append "VARDIR=" out "/var/lib"))) - - ;; Parallel builds are not supported, as noted in README. - #:parallel-build? #f)) - (native-search-paths - (list (search-path-specification - (variable "CHICKEN_REPOSITORY_PATH") - ;; TODO extract binary version into a module level definition. - (files (list "var/lib/chicken/11"))))) - ;; Reference gcc-toolchain lazily to avoid circular module dependency - ;; problems. - (propagated-inputs (list (module-ref (resolve-interface - '(gnu packages commencement)) - 'gcc-toolchain))) - (home-page "https://www.call-cc.org/") - (synopsis "R5RS Scheme implementation that compiles native code via C") - (description - "CHICKEN is a compiler for the Scheme programming language. CHICKEN -produces portable and efficient C, supports almost all of the R5RS Scheme -language standard, and includes many enhancements and extensions.") - (license license:bsd-3))) + (substitute-keyword-arguments (package-arguments chicken-bootstrap) + ((#:phases phases) + #~(modify-phases #$phases + ;; CHICKEN contains auto-generated C code, remove it and + ;; compile from the Scheme source using chicken-bootstrap. + (add-after 'unpack 'remove-auto-generated-code + (lambda _ + (invoke "make" "spotless"))))))) + (inputs (list chicken-bootstrap)) + (properties + (alist-delete 'hidden? (package-properties chicken-bootstrap))))) (define-public chicken-compile-file (package