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 WHJNEJCYEGJklAAAgWs5BA (envelope-from ) for ; Sat, 19 Feb 2022 08:13:20 +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 gQ82CZCYEGK6fgAAG6o9tA (envelope-from ) for ; Sat, 19 Feb 2022 08:13:20 +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 92C0F1C3AA for ; Sat, 19 Feb 2022 08:13:19 +0100 (CET) Received: from localhost ([::1]:54626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLJvh-0001zj-I1 for larch@yhetil.org; Sat, 19 Feb 2022 02:13:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLJTS-000713-1R for guix-patches@gnu.org; Sat, 19 Feb 2022 01:44:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:34622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLJTQ-00081n-NQ for guix-patches@gnu.org; Sat, 19 Feb 2022 01:44:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nLJTQ-0004nE-Li for guix-patches@gnu.org; Sat, 19 Feb 2022 01:44:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53878] [PATCH v3 04/15] 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: Sat, 19 Feb 2022 06:44:04 +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, Liliana Marie Prikler Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Attila Lendvai , Philip McGrath , Malte Gerdes , zimoun Received: via spool by 53878-submit@debbugs.gnu.org id=B53878.164525300918228 (code B ref 53878); Sat, 19 Feb 2022 06:44:04 +0000 Received: (at 53878) by debbugs.gnu.org; 19 Feb 2022 06:43:29 +0000 Received: from localhost ([127.0.0.1]:56724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLJSq-0004jr-Fl for submit@debbugs.gnu.org; Sat, 19 Feb 2022 01:43:29 -0500 Received: from mail-qv1-f53.google.com ([209.85.219.53]:33719) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLJSi-0004is-0H for 53878@debbugs.gnu.org; Sat, 19 Feb 2022 01:43:20 -0500 Received: by mail-qv1-f53.google.com with SMTP id h9so19230783qvm.0 for <53878@debbugs.gnu.org>; Fri, 18 Feb 2022 22:43:19 -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=voen33luSuZnifO97fQiqSCtXHVzAz6OmjDwr/H6AjE=; b=HpPT57jTIJtgvMyUY3e0QDhXdCjn5rKNhwgHP6LGeRQG8+I+buXXu45zMlBQt3DuCH N8TV3LAHYNR7RzlWWU3KckyxRvU7qczcVIQKZyA1Z5cLAbZTU57U/s4kfIHzy/7va7WO mqrJZgS9WTvWmVWhStGhVUtklDaRiKk95kkfWXHXkZyp5G5v8rG+XCrKOUFZ/KeheDqx 0I9N5DCRiUj+Xz8m+K4z0tOhqV6Wf5Lr/RDHszIlmLUNDq8RWjXrrJJHo8zVuUcliu8J CC09k3AI7zCA8urJlyNHGYsHA1v4NtAibedPS0IXV16ib0AGr4OFWHmt2JPwyun3piF2 BwLg== 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=voen33luSuZnifO97fQiqSCtXHVzAz6OmjDwr/H6AjE=; b=sYKlnhLTwYZ56dH+zywqv+TbgGwuPn5OPWrSSdDrTTakGguG7fDszlE3F1c4bEYnck 75PL9hRb4O8FwOJ+MwyaCXSX2I5jVcsMSaMlZgbrkQhMtT7YhJFielcGmyscsBSmEDi1 YnwQJZyVzo5sPo8OpZHyoeCWO0qgP+7Mg0MzcQW1l2/ujoKxpaIx2xMLx2N3R2WRwVwe k0CcDDeGYln99XWKnNUK1dBtbx6gse/x/MsHWIeGJxo2MYF0fmdAmpEP992ADMtK2qZe 0Ns+WwJiOIPZsWeIorFvKp79dlDcG6PUC7IB6U6+tEFEX3AtVbpta5NkhmnO6cf7gCHx H6sQ== X-Gm-Message-State: AOAM530c3wf4WSMkKr0tbm9bFgzYCcLkpJoIobEjC5FbC6lxPxDJnWpN 8O3lspRiylrF1Ihf+vcX/cAAcvcyXF4WIkWHNoI= X-Google-Smtp-Source: ABdhPJwkFW+poFhuJUfTv0w59ACKFFeuavXk78obQTUozjBJ9wD5p4ohztQJCRJyOYkFZtKxmonORQ== X-Received: by 2002:a05:622a:1190:b0:2dc:915a:9ce4 with SMTP id m16-20020a05622a119000b002dc915a9ce4mr9527750qtk.221.1645252994291; Fri, 18 Feb 2022 22:43:14 -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 y20sm26559543qtw.28.2022.02.18.22.43.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 22:43:14 -0800 (PST) From: Philip McGrath Date: Sat, 19 Feb 2022 01:42:17 -0500 Message-Id: <20220219064228.246917-5-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219064228.246917-1-philip@philipmcgrath.com> References: <20220208151316.1897345-1-philip@philipmcgrath.com> <20220219064228.246917-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=1645254799; 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=voen33luSuZnifO97fQiqSCtXHVzAz6OmjDwr/H6AjE=; b=hX6zw/lJmjLEraTwQohloacn5fWkfGOWtCYDbfxv65BghBeYzzT073k5a9UATig2WJIGKe q7KTgy6BpQAR/1TmiAwEmnVB3xq2Ca8oqy49R3fdrnlCsKB3RHEgZw3rzAkQ47FVhn+loT BefbZ/Es0xD0vqfhlD/k+Tni1DpCfqr0enLSO0ZwncLAcYxKVrpPj9CZO1RBqgzdKAMvuT Xemk6sSJpHRbihE4Jc/q6CJCoFunObuZuQ3LR03u01Y4yIlZ6B6ZCcrxvwYwqI4MNLPmaA g0glZ84TUcMmWrXe59n+/oVsGMsZnt3Rd7EXkGtwUY0L9dWnd5naBMVqwXV11Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1645254799; a=rsa-sha256; cv=none; b=aMNQJh4mCsXRdwxSsgKy8j6RnDvHmBlKzffa9ISbSY03/KS5zGWQnztMpzTqcPXmco4Z0j 5iyr13suyo0tvXQGAESSvl1vJvOqEfs4giARGjD2Y9HK/f1+T6AeeSWKgDI+HfUHtX2sPF 84QBJAb/r/NdpWKDgFV0fMT75t/N1ug+qoe4ldAzmkC9fxe5iav20mHP/vyciyFQa/iNDG /j8UUtHRMlg3DqsT2VR2V5zVgGzP2Ia+ZVLsVYde6vF4KHwu5x8F5Uzoe4qW9zrGGPXpzs kcPmuRpzihtDMj9VhLPVT7jnETl0NlmQ+3zV684V3bixF3+ZYNH1qiZRWaHJ2Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=HpPT57jT; 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=HpPT57jT; 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: 92C0F1C3AA X-Spam-Score: 0.87 X-Migadu-Scanner: scn1.migadu.com X-TUID: J4gmOG3O9rSj * gnu/packages/chez-and-racket-bootstrap.scm (chez-machine->nonthreaded, chez-machine->threaded, chez-machine->nix-system, nix-system->chez-machine, chez-upstream-features-for-system): 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-upstream-features-for-system'. --- gnu/packages/chez-and-racket-bootstrap.scm | 118 ++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/gnu/packages/chez-and-racket-bootstrap.scm b/gnu/packages/chez-and-racket-bootstrap.scm index 11d570059b..1a923fe62d 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,115 @@ (define-module (gnu packages chez-and-racket-bootstrap) ;; ;; Code: +(define (chez-machine->nonthreaded machine) + "Given a string MACHINE naming a Chez Scheme machine type, returns a string +naming the nonthreaded machine type for the same architecture and OS as +MACHINE. The returned string may share storage with MACHINE." + ;; Chez Scheme documentation consistently uses "nonthreaded" rather than + ;; e.g. "unthreaded" + (if (eqv? #\t (string-ref machine 0)) + (substring machine 1) + machine)) +(define (chez-machine->threaded machine) + "Like @code{chez-machine->nonthreaded}, but returns the threaded machine +type." + (if (eqv? #\t (string-ref machine 0)) + machine + (string-append "t" machine))) + +;; 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->nix-system machine) + "Return the Nix system type corresponding to the Chez Scheme machine type +MACHINE. If MACHINE is not a string representing a known machine type, an +exception is raised. This function does not distinguish between threaded and +nonthreaded variants of MACHINE. + +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 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 ((machine (chez-machine->nonthreaded machine))) + (let find-arch ((alist %nix-arch-to-chez-alist)) + (match alist + (((nix . chez) . alist) + (if (string-prefix? chez machine) + (string-append + nix "-" (let ((machine-os + (substring machine (string-length chez)))) + (let find-os ((alist %nix-os-to-chez-alist)) + (match alist + (((nix . chez) . alist) + (if (equal? chez machine-os) + nix + (find-os alist))))))) + (find-arch alist))))))) + +(define* (nix-system->chez-machine #:optional + (system (or (%current-target-system) + (%current-system)))) + "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. + +It is unspecified whether the resulting string will name a threaded or a +nonthreaded machine type: when the distinction is relevant, use +@code{chez-machine->nonthreaded} or @code{chez-machine->threaded} to adjust +the result." + (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))) + (and chez-arch chez-os (string-append chez-arch chez-os)))) + +(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}. Other feature symbols may be added in the future." + (cond + ((not (nix-system->chez-machine system)) + #f) + ((target-aarch64? system) + #f) + ((target-arm32? system) + (and (target-linux? system) + '())) + ((target-ppc32? system) + (and (target-linux? system) + '(threads))) + (else + '(threads)))) + +;; +;; Chez Scheme: +;; + (define nanopass (let ((version "1.9.2")) (origin @@ -264,8 +375,11 @@ (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 chez-upstream-features-for-system + %supported-systems))) (home-page "https://cisco.github.io/ChezScheme/") (synopsis "R6RS Scheme compiler and run-time") (description -- 2.32.0