From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8nftAjF+CWIsjgAAgWs5BA (envelope-from ) for ; Sun, 13 Feb 2022 22:54:57 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id ECDSNDB+CWK4XgEAG6o9tA (envelope-from ) for ; Sun, 13 Feb 2022 22:54:56 +0100 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 4D7CB1A502 for ; Sun, 13 Feb 2022 22:54:56 +0100 (CET) Received: from localhost ([::1]:57012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJMpb-0005fN-HZ for larch@yhetil.org; Sun, 13 Feb 2022 16:54:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJMol-0005c4-UP for guix-patches@gnu.org; Sun, 13 Feb 2022 16:54:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJMol-0001tn-LQ for guix-patches@gnu.org; Sun, 13 Feb 2022 16:54:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nJMol-0003E0-LZ for guix-patches@gnu.org; Sun, 13 Feb 2022 16:54:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53878] [PATCH 04/11] gnu: chez-and-racket-bootstrap: Add utilities for Chez machine types. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Feb 2022 21:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53878 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53878@debbugs.gnu.org Cc: Liliana Marie Prikler , Philip McGrath Received: via spool by 53878-submit@debbugs.gnu.org id=B53878.164478919012219 (code B ref 53878); Sun, 13 Feb 2022 21:54:03 +0000 Received: (at 53878) by debbugs.gnu.org; 13 Feb 2022 21:53:10 +0000 Received: from localhost ([127.0.0.1]:39058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJMnt-0003B0-4i for submit@debbugs.gnu.org; Sun, 13 Feb 2022 16:53:09 -0500 Received: from mail-qk1-f177.google.com ([209.85.222.177]:33342) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJMno-00039u-Ko for 53878@debbugs.gnu.org; Sun, 13 Feb 2022 16:53:05 -0500 Received: by mail-qk1-f177.google.com with SMTP id o10so13044635qkg.0 for <53878@debbugs.gnu.org>; Sun, 13 Feb 2022 13:53:04 -0800 (PST) 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=Lox4biAAsxxoQq6Fxhf7L0m7IO8uJocQ7vmE7rh9eMo=; b=QSu4qpMq8pjrATd5vBunqgkFvoB6jFyUtXzY9a50hwT6KhueTe5sAuJM0dPyUHQqaK 9b8xFhBO84LqteCTOAK5Jr7En0bOn1ihTHb2n0PSGahBTOkO61/cYkpyq0QsTboBVwYh m8uGTaS57wDZJ+I/ZrEHYnCGoiUbVgshaR+PXrehYmC7HoWjFTcp8+wCNulaaXN1ivoY eH2HWp29Z6qMy+qiSXG8NvHxzL4exY5UIWhNih8Hl8uNETBdwz8iT8jyRNjUXtQbHxL/ E2m5jFNKXYnX5ixCnNo00qMg3dOqfez5pXWR1tIVrvrLjPrx+woftnBsKu1wIqcyW/W8 Rf0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lox4biAAsxxoQq6Fxhf7L0m7IO8uJocQ7vmE7rh9eMo=; b=uvkU1d54ZdmexbTbeJEm7uL3trE5FX8L64WBxTIFdJkH8l3Dy3zR9AMVy8qoLPaWwW 3+8rUwUCSmdE1geNiIKXZBUzbAXZ8sqz1DATNHRcpKIKwnDnI70ht+WNWfTIHb6SMggi YUZKvbn2TTGIUQs1V8Iy8+vRwsjxZhYhWR0/N/mVwCYePeaRYNzYe3uR2mqOxF5FEzrg 3N9fcVZgCk0t1hToZJVLcIcvKLvNDHRLV9ok1jpUdFZBuoZT4Tnw/4SpBTQOLSz6KMkl +o8zcBxfKw4ZKUZNYz+r7kbwVODxVlaiXPruhOpTYjvtz34z6NNPd3c/OGxEtrct+zvM B/NQ== X-Gm-Message-State: AOAM531qVj663zYYrx5Ls+Vph80CBXSPBzlFzaAC4yZc2NEK60Mp1e+D BiYHpbTu4EhGhZ8jOy6hPQGxJdylwEuPX0jjK3A= X-Google-Smtp-Source: ABdhPJxVs7Xpyad4UMkgLrm5MjktsXpKWBxoYu7ZhaMxsWmEJJVRI7cN0K1jZyEy5egCE09R30TP6g== X-Received: by 2002:a05:620a:25cc:: with SMTP id y12mr5773709qko.94.1644789178891; Sun, 13 Feb 2022 13:52:58 -0800 (PST) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id s34sm16669359qtc.88.2022.02.13.13.52.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Feb 2022 13:52:58 -0800 (PST) From: Philip McGrath Date: Sun, 13 Feb 2022 16:51:20 -0500 Message-Id: <20220213215127.218952-5-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220213215127.218952-1-philip@philipmcgrath.com> References: <20220213215127.218952-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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644789296; 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=Lox4biAAsxxoQq6Fxhf7L0m7IO8uJocQ7vmE7rh9eMo=; b=T5iFDPg33YYrffi+OMOKxVquWUqsAkMfjHMa8H3t+c/gfuPJU/WlVnY9OQ8/OK2jcFhm3K yLuOCbMLe5CrgVwtBtzoD1EtYMa3xjVigmIJWRl0qjfB+bQc4CFRL7MiV/1TMVLfbbBCEc yUfKJY5buOAYC+mCc+x89rnZxR8Tdx00liWWldoGigRl7bDd1j4gv4S7JU8mRrOcmBJ5fR SUHJ3KNyNlJAM96ZP2Fn5stRntSXct/82VJRnL6Xtxdv/u05w+aSF4niH5EygjMLaxYRMC VwIOuinUaLdN7Qw31uh/sEmHQvZB4W3qSRUbiguD4Ytrv2ltOjnxDkOspZGhwQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644789296; a=rsa-sha256; cv=none; b=iHk1KpuSwhnCCVqPqzLGa+RqnqBkk7KR7T6e8GhWQID5SYXm/ns2kLPd3A4OTv01QOjms5 FMnzjwJGljAGVn5cU075WeeF5rzKz6z8yqH2N121NxC0VYW5haBF2CeoBq6KYf71ebh3p0 oqYRLa4traNh7QPS1bvmBZg1H2et9H36LjXu5an6wY8cEqH+3WO94Md3dCcW+nHSrnRj5d MMcsj+4/nqqDiVYs42q4AUKFiPmx5f1vgEQ7LJOqwCEtityBtmuSHe8eOh5FglxbUMje3g 1B1FiTSd0L1gQy6bfzbpJk2qQyAba8uuI6vVc55VW1+V5LWDi+8QjivWHFE4og== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=QSu4qpMq; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.87 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=QSu4qpMq; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 4D7CB1A502 X-Spam-Score: 0.87 X-Migadu-Scanner: scn1.migadu.com X-TUID: NbARTNvS3CE+ * gnu/packages/chez-and-racket-bootstrap.scm (chez-machine->unthreaded, chez-machine->upstream-restriction, chez-machine->nix-system, nix-system->chez-machine): New private functions. (%nix-arch-to-chez-alist, %nix-os-to-chez-alist): New private constants. (chez-scheme)[supported-systems]: Compute based on 'nix-system->chez-machine' and 'chez-machine->upstream-restriction'. --- gnu/packages/chez-and-racket-bootstrap.scm | 142 ++++++++++++++++++++- 1 file changed, 140 insertions(+), 2 deletions(-) diff --git a/gnu/packages/chez-and-racket-bootstrap.scm b/gnu/packages/chez-and-racket-bootstrap.scm index 11d570059b..fc1da53178 100644 --- a/gnu/packages/chez-and-racket-bootstrap.scm +++ b/gnu/packages/chez-and-racket-bootstrap.scm @@ -28,7 +28,9 @@ (define-module (gnu packages chez-and-racket-bootstrap) #:use-module (guix utils) #:use-module (guix gexp) #:use-module (ice-9 match) + #:use-module (ice-9 regex) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (guix build-system gnu) #:use-module (gnu packages) #:use-module (gnu packages compression) @@ -61,6 +63,134 @@ (define-module (gnu packages chez-and-racket-bootstrap) ;; ;; Code: +(define (chez-machine->unthreaded mach) + "Given a string MACH naming a Chez Scheme machine type, returns a string +naming the unthreaded machine type for the same architecture and OS as MACH. +The returned string may share storage with MACH." + (if (eqv? #\t (string-ref mach 0)) + (substring mach 1) + mach)) +(define (chez-machine->threaded mach) + "Like @code{chez-machine->unthreaded}, but returns the threaded machine +type." + (if (eqv? #\t (string-ref mach 0)) + mach + (string-append "t" mach))) + +;; Based on the implementation from raco-cross-lib/private/cross/platform.rkt +;; in https://github.com/racket/raco-cross. +;; For supported platforms, refer to release_notes/release_notes.stex in the +;; upstream Chez Scheme repository or to racket/src/ChezScheme/README.md +;; in https://github.com/racket/racket. +(define %nix-arch-to-chez-alist + `(("x86_64" . "a6") + ("i386" . "i3") + ("aarch64" . "arm64") + ("armhf" . "arm32") ;; Chez supports ARM v6+ + ("ppc" . "ppc32"))) +(define %nix-os-to-chez-alist + `(("w64-mingw32" . "nt") + ("darwin" . "osx") + ("linux" . "le") + ("freebsd" . "fb") + ("openbsd" . "ob") + ("netbsd" . "nb") + ("solaris" . "s2"))) + +(define (chez-machine->upstream-restriction mach) + "Given a string MACH naming a Chez Scheme machine type, returns a symbol +naming a restriction on the upstream Chez Scheme implementation compared to +the Racket variant, or @code{#f} if no such restriction exists. The +restriction is reported for the architecture--OS pair, regardless of whether +MACH specifies a threaded or an unthreaded variant. + +Possible restrictions currently include: +@itemize @bullet +@item +@code{'no-threads}: Support for native threads is not available upstream. +@item +@code{'no-support}: The upstream release doesn't claim to support this +architecture--OS combination at all. +@end itemize + +See @code{chez-machine->nix-system} for more details about acceptable values +for MACH." + (let ((mach (chez-machine->unthreaded mach))) + (cond + ((string-prefix? "arm64" mach) + 'no-support) + ((string-prefix? "arm32" mach) + (if (string-suffix? "le" mach) + 'no-threads + 'no-support)) + ((string-prefix? "ppc32" mach) + (if (string-suffix? "le" mach) + #f + 'no-support)) + (else + #f)))) + +(define (chez-machine->nix-system mach) + "Return the Nix system type corresponding to the Chez Scheme machine type +MACH. If MACH is not a string representing a known machine type, an exception +is raised. This function does not distinguish between threaded and unthreaded +variants of MACH. + +Note that this function only handles Chez Scheme machine types in the +strictest sense, not other kinds of descriptors sometimes used in place of a +Chez Scheme machine type by the Racket, such as @code{\"pb\"}, @code{#f}, or +@code{\"racket\"}. (When using such extensions, the Chez Scheme machine type +for the host system is often still relevant.)" + (let ((mach (chez-machine->unthreaded mach))) + (let find-arch ((alist %nix-arch-to-chez-alist)) + (match alist + (((nix . chez) . alist) + (if (string-prefix? chez mach) + (string-append + nix "-" (let ((mach-os (substring mach (string-length chez)))) + (let find-os ((alist %nix-os-to-chez-alist)) + (match alist + (((nix . chez) . alist) + (if (equal? chez mach-os) + nix + (find-os alist))))))) + (find-arch alist))))))) + +(define* (nix-system->chez-machine #:optional (system (%current-system)) + #:key (threads? 'always)) + "Return the Chez Scheme machine type corresponding to the Nix system +identifier SYSTEM, or @code{#f} if the translation of SYSTEM to a Chez Scheme +machine type is undefined. + +When THREADS? is @code{'always} (the default), the threaded variant of the +machine type will be returned: note that the package returned by +@code{chez-scheme-for-system} will always support native threads. When +THREADS? is @code{#f}, the unthreaded machine type will be returned. If +THREADS? is @code{'upstream} (the default), the threaded variant of the +machine type will be returned if and only if it is supported by upstream Chez +Scheme (see @code{chez-machine->upstream-restriction}). If THREADS? is any +other value, an exception is raised." + (let* ((hyphen (string-index system #\-)) + (nix-arch (substring system 0 hyphen)) + (nix-os (substring system (+ 1 hyphen))) + (chez-arch (assoc-ref %nix-arch-to-chez-alist nix-arch)) + (chez-os (assoc-ref %nix-os-to-chez-alist nix-os)) + (mach (and chez-arch chez-os (string-append chez-arch chez-os)))) + (and mach + (match threads? + ('always + (chez-machine->threaded mach)) + (#f + mach) + ('upstream + (if (chez-machine->upstream-restriction mach) + mach + (chez-machine->threaded mach))))))) + +;; +;; Chez Scheme: +;; + (define nanopass (let ((version "1.9.2")) (origin @@ -264,8 +394,16 @@ (define* (stex-make #:optional (suffix "")) ;; We should too. It is the Chez machine type arm32le ;; (no threaded version upstream yet, though there is in ;; Racket's fork), more specifically (per the release notes) ARMv6. - (supported-systems (fold delete %supported-systems - '("mips64el-linux" "armhf-linux"))) + (supported-systems + (delete + "armhf-linux" ;; <-- should work, but reportedly broken + (filter + (lambda (system) + (and=> (nix-system->chez-machine system) + (lambda (mach) + (not (eq? 'no-support + (chez-machine->upstream-restriction mach)))))) + %supported-systems))) (home-page "https://cisco.github.io/ChezScheme/") (synopsis "R6RS Scheme compiler and run-time") (description -- 2.32.0