From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id e4zZFsKX22BCiQAAgWs5BA (envelope-from ) for ; Tue, 29 Jun 2021 23:59:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SG3oEcKX22A+UQAAbx9fmQ (envelope-from ) for ; Tue, 29 Jun 2021 21:59:30 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A74E9824D for ; Tue, 29 Jun 2021 23:59:29 +0200 (CEST) Received: from localhost ([::1]:34264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyLlQ-0002WH-OR for larch@yhetil.org; Tue, 29 Jun 2021 17:59:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyLl1-0002Ma-9v for guix-patches@gnu.org; Tue, 29 Jun 2021 17:59:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44308) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyLl1-0007cb-2b for guix-patches@gnu.org; Tue, 29 Jun 2021 17:59:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyLl1-0003Xw-0H for guix-patches@gnu.org; Tue, 29 Jun 2021 17:59:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49280] [PATCH 4/4] gnu: racket-next-minimal: Bootstrap from C. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Jun 2021 21:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49280 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49280@debbugs.gnu.org Cc: Philip McGrath Received: via spool by 49280-submit@debbugs.gnu.org id=B49280.162500389713557 (code B ref 49280); Tue, 29 Jun 2021 21:59:02 +0000 Received: (at 49280) by debbugs.gnu.org; 29 Jun 2021 21:58:17 +0000 Received: from localhost ([127.0.0.1]:55851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyLkG-0003Wa-9Q for submit@debbugs.gnu.org; Tue, 29 Jun 2021 17:58:17 -0400 Received: from mail-qk1-f174.google.com ([209.85.222.174]:37811) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyLkD-0003Vv-83 for 49280@debbugs.gnu.org; Tue, 29 Jun 2021 17:58:14 -0400 Received: by mail-qk1-f174.google.com with SMTP id z3so325639qkl.4 for <49280@debbugs.gnu.org>; Tue, 29 Jun 2021 14:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KJqHB3IouE86/cSOeFf5g7VR9FXYvEPEZYQlU4ol4oQ=; b=eM0YXhKtsmLOrVbMpusDN40AEQOCwm8beh0fJaZzS/zl8BgbXjSmmMkhI2C+CPFnwC nkuVXvvbDANg1/+tHspoC1XvknqTsuJ3kovZP67R4IzkFLFF4xIqbtKIpZ4KU24rFYkg AR74jjLXVG8An2fTaZqu8GWSRMc0TJak+b7uYSB6npvtgNNRDym0tfA3appCwjUoEAV/ tD3Yu4u6wLfKDO6xXf5JrNHxTllHRD3rYseNaDHgADoXRitGY+0nNSMtTpt0BBtrKUJC f0qpiquzvImFormxdb1pO4ZM7H/0vJ5nT1G/clr7tySe8kUFUrPAb3GFaeAUy72Yh41b 3M2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJqHB3IouE86/cSOeFf5g7VR9FXYvEPEZYQlU4ol4oQ=; b=JD9sJxmwTSyjPRTjJinmW12FNx36o5FGmAIHXRkqv2DywApSdLmWaJa9zpRrJwLFEO 7oGHqWXe4RxBKojUlMO+HqX2W0PMhTRnHm7nQAx38MB43FoQsomJRCSRid7S1Ow5sPUn JpRIXJYMpTfCsMWkVE+hGSNLbj6pZUT+YqBkE8fWB2+3xhXLy50vW5KaKRwnnxW2dQ26 4zvs6c2+CPD0Ty9uJmAXAPeM+VFcy0MwZv/rvQb4szKopzjtteMg2X6fQUJA+ZkP/Kgr G93VKViY6fd7FSsxu/4Y5rIVJ1RwyfwDTxOhzbeRzhJR/UI4jyRwKctuLGnm0PvEDris +t6w== X-Gm-Message-State: AOAM533QMZsconc19v7gDT75GdwEKai+Wspr3ncbpzsUXeGVm87ULkHO hP+ZN3fY9Llk4MteZIecobPfoejpTWX1U+7spZY= X-Google-Smtp-Source: ABdhPJw6ZQr1Di7CQQfye9l0IyK+9T4qLb84/hzT6E+GT/fSL4gp+IA7VA0jaQAZxeUAqelYdzOZYA== X-Received: by 2002:a37:59c7:: with SMTP id n190mr32832441qkb.146.1625003887495; Tue, 29 Jun 2021 14:58:07 -0700 (PDT) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with ESMTPSA id t11sm3995529qtq.75.2021.06.29.14.58.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 14:58:07 -0700 (PDT) From: Philip McGrath Date: Tue, 29 Jun 2021 17:57:42 -0400 Message-Id: <20210629215742.3112654-4-philip@philipmcgrath.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210629215742.3112654-1-philip@philipmcgrath.com> References: <20210629215255.3110238-1-philip@philipmcgrath.com> <20210629215742.3112654-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625003969; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=KJqHB3IouE86/cSOeFf5g7VR9FXYvEPEZYQlU4ol4oQ=; b=HF44GjhqEfuXWXk3sPIyK2FiVT1olig3w42ObNoeOKV0JDHCsemruoYM/7iDQbbS39C/gP kJLCHdgcV56H7N5A5YNsKRwORxCA6OV77pEYglNCXsehBO4ajw0npdLEjHjqMioS4pDSDq mqyeBuK7WrKqZ18hnTnnS7o1mfroH8T5yRHff+Cf1LVHg8Xrh5ImRdGDA3htJpco8C9fwB X57LxJomWZzSreOckZCc1FcnX0WQ8NRJ1DFsDo2aIKFV4al2MyfoSvh5keaB6xoDOkr4Ei j6HraXBL8uFkSGqYEd7Bb7GOyACY/Y1+LgpDtznXmCWLyfzTXe8LXNTAITl0Cg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625003969; a=rsa-sha256; cv=none; b=JxAT134lk05ad5raCL3dbU0x1iHuORb4KnR1NJclHB0a9z7vGNgmVcUiQGZZyQxwPmGKmR 5UuYJrx+puu/7P61lKiELUBzMM6V5idLpkhKc2qU9MSY5MADHu1bpn+KvNQRaGrUM6xo95 E+XbM5sqmO7k5/6U69fOZlyi7gVuoyUs5z9HnGqkEHcv+JrK6vzuAWGt/RrY7j126I2cUM Q547X4LI+1HUzvxvH2pgPDA9/w0DDHBzykZSvLnGXqxQKsF5fwNEkeHJOYHUgeguYs54Q7 NAyg+8dezKj2LzBa6Kb/W9TCiQXODA1maVNXbc3m1Mp6y0HRHi5LeagQPL6jlg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=eM0YXhKt; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.58 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=eM0YXhKt; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: A74E9824D X-Spam-Score: 3.58 X-Migadu-Scanner: scn0.migadu.com X-TUID: g2Zb0oi7jyrj This commit bootstraps the Racket compiler and runtime system from source, including Racket CS as well as both variants of Racket BC. (One remaining limitation is discussed in comments added to gnu/packages/racket.scm.) In the process, it moves to building minimal Racket from the Git repository, rather than the packaged source tarballs. The Git repository is slightly better as the ``corresponding source'': 1. A few packages especially closely tied to the Racket core implementation (like "compiler-lib", "base", and "racket-doc") are developed in the same Git repository. Having them use the same Guix origin, too, will help to keep them in sync. 2. The top-level Makefile in the Git repository is an important ``script[] used to control compilation and installation.'' In particular, it cooperates with the "distro-build" package to create the source tarballs and installers for a Racket distribution. (Racket supports a notion of custom distributions.) 3. It is ``the preferred form ... for making modifications'' to the core Racket implementation. Racket releases are tagged in the Git repository (e.g. "v8.1"). At the beginning of each release cycle, a branch is created to stabalize a version for extra testing. Active development happens on the "master" branch. * gnu/packages/racket-next-minimal-sh-via-rktio.patch: New file, coppied from racket-sh-via-rktio.patch to accomodate an extra directory layer. When racket-next-minimal becomes racket-minimal, this version will be the only one needed. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/local/racket.scm (cfg-flag:sh-for-rktio, cfg-flag:enable-lt, cfg-flag:enable-racket, unpack-nanopass+stex, %main-repo-main-distribution-pkgs): New private variables. * gnu/local/racket.scm (racket-next-minimal)[source]: Use Git. [source](snippet): Unbundle nanopass, stex, and libffi. [inputs]: List explicitly. [native-inputs]: Use racket-next-bootstrap-bootfiles, plus its dependencies (for Chez, plus a Racket for bootstrappig). [arguments]: Revise extensively. * gnu/local/racket.scm (racket-next-minimal-bc-3m, racket-next-minimal-bc-cgc): New packages, hidden at least for now. (racket-next-bootstrap-chez-bootfiles): Another new package, but this one is especially likely to stay hidden. * gnu/local/racket.scm (racket-next)[origin](snippet): Unbundle packages developed in the main Git repository, but leave their links.rktd and pkgs.rktd entries in place. [native-inputs]: Add the main Racket Git repository. [arguments](#:phases): Adjust 'unpack-packages to also unpack package sources from the main Racket Git repository. --- gnu/local.mk | 1 + .../racket-next-minimal-sh-via-rktio.patch | 87 +++++ gnu/packages/racket.scm | 357 +++++++++++++++--- 3 files changed, 396 insertions(+), 49 deletions(-) create mode 100644 gnu/packages/patches/racket-next-minimal-sh-via-rktio.patch diff --git a/gnu/local.mk b/gnu/local.mk index 6b9202cba1..4ca35cf56a 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1671,6 +1671,7 @@ dist_patch_DATA = \ %D%/packages/patches/ripperx-missing-file.patch \ %D%/packages/patches/rpcbind-CVE-2017-8779.patch \ %D%/packages/patches/rtags-separate-rct.patch \ + %D%/packages/patches/racket-next-minimal-sh-via-rktio.patch \ %D%/packages/patches/racket-sh-via-rktio.patch \ %D%/packages/patches/remake-impure-dirs.patch \ %D%/packages/patches/retroarch-LIBRETRO_DIRECTORY.patch \ diff --git a/gnu/packages/patches/racket-next-minimal-sh-via-rktio.patch b/gnu/packages/patches/racket-next-minimal-sh-via-rktio.patch new file mode 100644 index 0000000000..6bc2ee8331 --- /dev/null +++ b/gnu/packages/patches/racket-next-minimal-sh-via-rktio.patch @@ -0,0 +1,87 @@ +From 3574b567c486d264d680a37586436c3b5a8cb978 Mon Sep 17 00:00:00 2001 +From: Philip McGrath +Date: Thu, 4 Mar 2021 04:11:50 -0500 +Subject: [PATCH] patch rktio_process for "/bin/sh" on Guix + +Racket provides the functions `system` and `process`, +which execute shell commands using `sh` (or `cmd` on Windows). +Racket assumes that `sh` can be found at "/bin/sh", +which is not necessarily true on Guix. + +This patch adds a special case for "/bin/sh" to `rktio_process`, +the C function that implements the core of `system`, `process`, +and related Racket functions. + +Guix should enable the special case by defining the C preprocessor +macro `GUIX_RKTIO_PATCH_BIN_SH` with the path to `sh` in the store. +If: + + 1. The `GUIX_RKTIO_PATCH_BIN_SH` macro is defined; and + + 2. `rktio_process` is called with the exact path "/bin/sh"; and + + 3. The path specified by `GUIX_RKTIO_PATCH_BIN_SH` does exists; + +then `rktio_process` will execute the file specified +by `GUIX_RKTIO_PATCH_BIN_SH` instead of "/bin/sh". + +Compared to previous attempts to patch the Racket sources, +making this change at the C level is both: + + - More comprehensive: it catches all attempts to execute "/bin/sh", + without having to track down the source of every occurance; and + + - Less intrusive: by guarding the special case with a C preprocessor + conditional and a runtime check that the file in the store exists, + we make it much less likely that it will "leak" out of Guix. +--- + racket/src/rktio/rktio_process.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/racket/src/rktio/rktio_process.c b/racket/src/rktio/rktio_process.c +index 89202436c0..465ebdd5c5 100644 +--- a/racket/src/rktio/rktio_process.c ++++ b/racket/src/rktio/rktio_process.c +@@ -1224,12 +1224,14 @@ int rktio_process_allowed_flags(rktio_t *rktio) + /*========================================================================*/ + + rktio_process_result_t *rktio_process(rktio_t *rktio, +- const char *command, int argc, rktio_const_string_t *argv, ++ /* PATCHED for Guix (next line) */ ++ const char *_guix_orig_command, int argc, rktio_const_string_t *argv, + rktio_fd_t *stdout_fd, rktio_fd_t *stdin_fd, rktio_fd_t *stderr_fd, + rktio_process_t *group_proc, + const char *current_directory, rktio_envvars_t *envvars, + int flags) + { ++ const char *command; /* PATCHED for Guix */ + rktio_process_result_t *result; + intptr_t to_subprocess[2], from_subprocess[2], err_subprocess[2]; + int pid; +@@ -1255,6 +1257,23 @@ rktio_process_result_t *rktio_process(rktio_t *rktio, + int i; + #endif + ++/* BEGIN PATCH for Guix */ ++#if defined(GUIX_RKTIO_PATCH_BIN_SH) ++# define GUIX_AS_a_STR_HELPER(x) #x ++# define GUIX_AS_a_STR(x) GUIX_AS_a_STR_HELPER(x) ++ /* A level of indirection makes `#` work as needed: */ ++ command = ++ ((0 == strcmp(_guix_orig_command, "/bin/sh")) ++ && rktio_file_exists(rktio, GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH))) ++ ? GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH) ++ : _guix_orig_command; ++# undef GUIX_AS_a_STR ++# undef GUIX_AS_a_STR_HELPER ++#else ++ command = _guix_orig_command; ++#endif ++/* END PATCH for Guix */ ++ + /* avoid compiler warnings: */ + to_subprocess[0] = -1; + to_subprocess[1] = -1; +-- +2.21.1 (Apple Git-122.3) + diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm index cf0240be5c..4e2d498364 100644 --- a/gnu/packages/racket.scm +++ b/gnu/packages/racket.scm @@ -32,7 +32,9 @@ #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:use-module (gnu packages) + #:use-module (gnu packages autotools) #:use-module (gnu packages bash) + #:use-module (gnu packages chez) #:use-module (gnu packages compression) #:use-module (gnu packages databases) #:use-module (gnu packages fontutils) @@ -41,6 +43,7 @@ #:use-module (gnu packages gtk) #:use-module (gnu packages image) #:use-module (gnu packages libedit) + #:use-module (gnu packages libffi) #:use-module (gnu packages multiprecision) #:use-module (gnu packages sqlite) #:use-module (gnu packages tls) @@ -49,6 +52,7 @@ ;; Commentary: ;; ;; Preliminary guidelines on naming things: +;; ;; - `racket` is the main package. It corresponds to `racket-minimal` ;; with the Racket-level package "main-distribution" installed. ;; - `racket-minimal` is Racket runtime system and core libraries: @@ -74,6 +78,49 @@ ;; individually, we will need `racket-next-pkg-` for the packages ;; that make up `racket-next`. ;; +;; Here's how bootstrapping minimal Racket works: +;; +;; - Racket BC [CGC] can be built with only a C compiler (except for +;; one caveat discussed below). +;; - Racket BC [3M] needs an existing Racket to run "xform", +;; which transforms its own C source code to add additional annotations +;; for the precise garbage collector. +;; - Racket CS needs (bootfiles for) Racket's fork of Chez Scheme. +;; It also needs an existing Racket to compile Racket-implemented +;; parts of the runtime system to R6RS libraries. +;; - Chez Scheme also needs bootfiles for itself, but Racket can simulate +;; enough of Chez Scheme to load Racket's fork of the Chez Scheme compiler +;; purely from source into Racket and apply the compiler to itself, +;; producing the needed bootfiles (albeit very slowly). +;; Any variant of Racket since version 7.1 can run the simulation. +;; +;; So, we build CGC to build 3M to build bootfiles and CS. +;; +;; One remaining bootstrapping limitation is that Racket's reader, module +;; system, and macro expander are implemented in Racket. For Racket CS, +;; they are compiled to R6RS libraries as discussed above. This note from the +;; README file applies to all such subsystems: +;; +;; The Racket version must be practically the same as the current Racket +;; verson, although it can be the Racket BC implementation (instead of +;; the Racket CS implementation). +;; +;; Unlike Chez Scheme boot files, the files generated in "schemified" +;; are human-readable and -editable Scheme code. That provides a way +;; out of bootstrapping black holes, even without BC. +;; +;; However, other Racket subsystems implemented in Racket for Racket CS +;; use older C implementations for Racket BC, whereas the reader, expander, +;; and module system were completely replaced with the Racket implementation +;; as of Racket 7.0. +;; +;; For Racket BC, the compiled "linklet" s-expressions (primitive modules) +;; are embeded in C as a static string constant. Eventually, they are further +;; compiled by the C-implemented Racket BC bytecode and JIT compilers. +;; (On platforms where Racket BC's JIT is not supported, yet another compiler +;; instead compiles the linklets to C code, but this is not a bootstrapping +;; issue.) +;; ;; Code: @@ -200,7 +247,6 @@ DrRacket IDE, are not included.") ;; https://download.racket-lang.org/license.html (license (list lgpl3+ asl2.0 expat)))) - (define-public racket (package (inherit racket-minimal) @@ -243,8 +289,35 @@ The main Racket distribution comes with many bundled packages, including the DrRacket IDE, libraries for GUI and web programming, and implementations of languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog."))) -(define %pre-release-installers - "https://pre-release.racket-lang.org/installers/") + +(define cfg-flag:sh-for-rktio + `(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH=" + (assoc-ref %build-inputs "sh") + "/bin/sh")) +(define cfg-flag:enable-lt + `(string-append "--enable-lt=" + (assoc-ref %build-inputs "libtool") + "/bin/libtool")) +(define cfg-flag:enable-racket + `(let ((racket (assoc-ref %build-inputs "racket"))) + (string-append "--enable-racket=" + racket + "/bin/racket"))) + +(define unpack-nanopass+stex + ;; Copied from chez-scheme. + ;; TODO: Eventually, we should refactor Chez Scheme + ;; enough to share more directly, so that we can make + ;; Racket's version of Chez avalable as a Guix package, + ;; e.g. for architectures not supported upstream. + ;; For now, we let Racket drive the Chez build process + ;; other than this step. + `(for-each (lambda (dep) + (define src + (assoc-ref (or native-inputs inputs) dep)) + (copy-recursively src dep + #:keep-mtime? #t)) + '("nanopass" "stex"))) (define-public racket-next-minimal (package @@ -253,12 +326,214 @@ languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog."))) (version "8.1.900") (source (origin - (inherit (package-source racket-minimal)) + (method git-fetch) + (uri (git-reference + (url "https://github.com/racket/racket") + (commit "0874b76de4f147ada46607857d8acf8445a1073d"))) (sha256 (base32 - "0dm849wvlaxpfgz2qmgy2kwdslyi515rxn1m1yff38lagbn21vxq")) - (uri (string-append %pre-release-installers - "racket-minimal-src.tgz")))))) + "0gy6rwyrpaij5k5pcyiif821b4vffqiaxg1vpg4iykw2c5ypfp43")) + (file-name + (git-file-name name version)) + (patches + (search-patches + "racket-next-minimal-sh-via-rktio.patch")) + (snippet + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + ;; unbundle Chez submodules + (with-directory-excursion "racket/src/ChezScheme" + #$(origin-snippet (package-source chez-scheme))) + ;; unbundle libffi + (for-each + delete-file-recursively + '("racket/src/bc/foreign/libffi"))))))) + (inputs + `(;; common to all racket-minimal variants: + ("openssl" ,openssl) + ("sqlite" ,sqlite) + ("sh" ,bash-minimal) + ;; only for CS + ("zlib" ,zlib) + ("zlib:static" ,zlib "static") + ("lz4" ,lz4) + ("lz4:static" ,lz4 "static"))) + (native-inputs + `(("bootfiles" ,racket-next-bootstrap-chez-bootfiles) + ,@(package-native-inputs racket-next-bootstrap-chez-bootfiles))) + (build-system gnu-build-system) + (arguments + `(#:configure-flags + (list "--enable-csonly" + "--enable-libz" + "--enable-liblz4" + ,cfg-flag:enable-racket + ,cfg-flag:sh-for-rktio) + #:out-of-source? #true + #:tests? #f ;; not yet + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'unpack-nanopass+stex + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (with-directory-excursion "racket/src/ChezScheme" + ,unpack-nanopass+stex))) + (add-after 'unpack-nanopass+stex 'unpack-bootfiles + (lambda* (#:key inputs #:allow-other-keys) + (with-directory-excursion "racket/src/ChezScheme" + (copy-recursively + (string-append (assoc-ref inputs "bootfiles") "/boot") + "boot")))) + (add-before 'configure 'initialize-config.rktd + (lambda* (#:key inputs #:allow-other-keys) + (mkdir-p "racket/etc") + (with-output-to-file "racket/etc/config.rktd" + (lambda () + (format #t + "#hash((lib-search-dirs . ~s))\n" + (cons #f + (map (lambda (lib) + (string-append (assoc-ref inputs lib) + "/lib")) + '("openssl" + "sqlite")))))) + #t)) + (replace 'configure + (let ((inner (assq-ref %standard-phases 'configure))) + (lambda args + (chdir "racket/src") + (apply inner args)))) + (add-after 'install 'remove-pkgs-directory + ;; otherwise, e.g., `raco pkg show` will try and fail to + ;; create a lock file + (lambda* (#:key outputs #:allow-other-keys) + ;; rmdir because we want an error if it isn't empty + (rmdir (string-append (assoc-ref outputs "out") + "/share/racket/pkgs")) + #t))))) + ;; https://download.racket-lang.org/license.html + ;; The LGPL components are only used by Racket BC. + (license (list asl2.0 expat)))) + +(define-public racket-next-minimal-bc-3m + (hidden-package + (package/inherit racket-next-minimal + (name "racket-next-minimal-bc-3m") + (inputs + `(("libffi" ,libffi) ;; <- only for BC variants + ,@(filter (match-lambda + ((label . _) + (not (member label + '("zlib" "zlib:static" + "lz4" "lz4:static"))))) + (package-inputs racket-next-minimal)))) + (native-inputs + `(("libtool" ,libtool) + ("racket" ,(if (%current-target-system) + racket-next-minimal + racket-next-minimal-bc-cgc)))) + (arguments + (substitute-keyword-arguments (package-arguments racket-next-minimal) + ((#:configure-flags _ '()) + `(list "--enable-bconly" + ,cfg-flag:enable-racket + ,cfg-flag:enable-lt + ,cfg-flag:sh-for-rktio)) + ((#:phases usual-phases) + `(modify-phases ,usual-phases + (delete 'unpack-nanopass+stex) + (delete 'unpack-bootfiles))))) + (synopsis "Minimal Racket with the BC [3M] runtime system") + (description "The Racket BC (``before Chez'' or ``bytecode'') implementation was the default before Racket 8.0. It uses a compiler written in C targeting architecture-independent bytecode, plus a JIT compiler on most platforms. Racket BC has a different C API than the newer runtune system (Racket CS) supports a slightly different set of architectures than the current runtime system, Racket CS (based on ``Chez Scheme''). + +This packackage is the normal implementation of Racket BC with a precise garbage collector, 3M (``Moving Memory Manager'').")))) + +(define-public racket-next-minimal-bc-cgc + (package/inherit racket-next-minimal-bc-3m + (name "racket-next-minimal-bc-cgc") + (native-inputs + (filter (match-lambda + (("racket" . _) + #f) + (_ + #t)) + (package-native-inputs racket-next-minimal-bc-3m))) + (arguments + (substitute-keyword-arguments (package-arguments racket-next-minimal-bc-3m) + ((#:configure-flags _ '()) + `(list "--enable-cgcdefault" + ,cfg-flag:enable-lt + ,cfg-flag:sh-for-rktio)))) + (synopsis "Old Racket implemetation used for bootstapping") + (description "This variant of the Racket BC (``before Chez'' or ``bytecode'') implementation is not recommended for general use. It uses CGC (a ``Conservative Garbage Collector''), which was succeeded as default in PLT Scheme version 370 (which translates to 3.7 in the current versioning scheme) by the 3M variant, which in turn was succeeded in version 8.0 by the Racket CS implementation. + +Racket BC [CGC] is primarily used for bootstrapping Racket BC [3M]. It may also be used for embedding applications without the annotations needed in C code to use the 3M garbage collector."))) + +(define-public racket-next-bootstrap-chez-bootfiles + (hidden-package + (package/inherit racket-next-minimal + (name "racket-next-bootstrap-chez-bootfiles") + (inputs `()) + (native-inputs + `(("racket" ,(if (%current-target-system) + racket-next-minimal + racket-next-minimal-bc-3m)) + ("stex" ,@(assoc-ref (package-native-inputs chez-scheme) "stex")) + ("nanopass" ,@(assoc-ref (package-native-inputs chez-scheme) + "nanopass")))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'unpack-nanopass+stex + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (with-directory-excursion "racket/src/ChezScheme" + ,unpack-nanopass+stex))) + (delete 'configure) + (delete 'patch-generated-file-shebangs) + (replace 'build + (lambda* (#:key inputs outputs #:allow-other-keys) + (with-directory-excursion "racket/src/ChezScheme" + (invoke (string-append (assoc-ref inputs "racket") + "/bin/racket") + "rktboot/main.rkt" + "--dest" (assoc-ref outputs "out"))) + #t)) + (delete 'check) + (delete 'install)))) + (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 ``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 ``cs-bootstap'' 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 ``cs-bootstrap'' does not currently support building upstream Chez Scheme.") + (license (package-license chez-scheme))))) + + +(define %pre-release-installers + "https://pre-release.racket-lang.org/installers/") + +(define %main-repo-main-distribution-pkgs + ;; These are the packages developed in the main Racket Git repository + ;; that are part of the main distribution. + '("at-exp-lib" + "base" + "compiler-lib" + ;; NOT "compiler-test" + "compiler" + "net-doc" + "net-lib" + ;; NOT "net-test" + "net" + ;; NOT "plt-services" + ;; NOT "racket-benchmarks" + ;; NOT "racket-build-guide" + "racket-doc" + "racket-index" + "racket-lib" + ;; NOT "racket-test-core" + ;; NOT "racket-test-extra" + ;; NOT "racket-test" + "zo-lib")) (define-public racket-next (package @@ -289,36 +564,10 @@ languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog."))) "README" "src")) ;; unbundle package sources included elsewhere - (define (substitute/delete file pattern) - (substitute - file - (list (cons pattern - (lambda (line matches) - ;; must match exactly once - (match matches - ((m) - (string-append (match:prefix m) - (match:suffix m))))))))) - (define (unbundle-pkg pkg) - (define quoted-pkg (regexp-quote pkg)) - (with-directory-excursion "share" - (substitute/delete - "links.rktd" - (string-append - "[(][^()]+[(]#\"pkgs\" #\"" - quoted-pkg - "\"[)][)]")) - (with-directory-excursion "pkgs" - (substitute/delete - "pkgs.rktd" - (string-append - "[(]\"" - quoted-pkg - "\" \\. #s[(]" - "(pkg-info|[(]sc-pkg-info pkg-info 3[)])" - " [(][^()]+[)] [^()]+[)][)]")) - (delete-file-recursively pkg)))) - (unbundle-pkg "racket-lib")))))) + (with-directory-excursion "share/pkgs" + (for-each delete-file-recursively + '#+%main-repo-main-distribution-pkgs)) + #t))))) (inputs `(("cairo" ,cairo) ("fontconfig" ,fontconfig) @@ -336,22 +585,32 @@ languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog."))) ("libedit" ,libedit))) (native-inputs `(("racket" ,racket-next-minimal) - ("extend-layer" ,extend-layer))) + ("extend-layer" ,extend-layer) + ("main-repo" ,(package-source racket-next-minimal)))) (arguments `(#:phases (modify-phases %standard-phases (add-before 'configure 'unpack-packages - (lambda* (#:key native-inputs inputs outputs #:allow-other-keys) - (let ((racket (assoc-ref (or native-inputs inputs) "racket")) - (prefix (assoc-ref outputs "out"))) - (mkdir-p (string-append prefix "/share/racket/pkgs")) - (copy-recursively - "share/links.rktd" - (string-append prefix "/share/racket/links.rktd")) - (copy-recursively - "share/pkgs" - (string-append prefix "/share/racket/pkgs")) - #t))) + (let ((unpack (assoc-ref %standard-phases 'unpack))) + (lambda* (#:key native-inputs inputs outputs #:allow-other-keys) + (let* ((racket (assoc-ref (or native-inputs inputs) "racket")) + (prefix (assoc-ref outputs "out")) + (pkgs-dir (string-append prefix "/share/racket/pkgs"))) + (mkdir-p pkgs-dir) + (copy-recursively + "share/links.rktd" + (string-append prefix "/share/racket/links.rktd")) + (copy-recursively "share/pkgs" pkgs-dir) + ;; NOTE: unpack changes the working directory + (unpack #:source (assoc-ref (or native-inputs inputs) + "main-repo")) + (for-each (lambda (pkg) + (define dest (string-append pkgs-dir "/" pkg)) + (mkdir-p dest) + (copy-recursively (string-append "pkgs/" pkg) + dest)) + ',%main-repo-main-distribution-pkgs) + #t)))) (replace 'configure (lambda* (#:key native-inputs inputs outputs #:allow-other-keys) (let ((racket (assoc-ref (or native-inputs inputs) "racket")) -- 2.30.2