From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id WF0RJapPBmYiUwAA62LTzQ:P1 (envelope-from ) for ; Fri, 29 Mar 2024 06:20:42 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id WF0RJapPBmYiUwAA62LTzQ (envelope-from ) for ; Fri, 29 Mar 2024 06:20:42 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm2 header.b=ECMVpEuT; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="p GsxRf/"; 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"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1711689642; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=l99BGI7dBeu6d8SAQn/mtlZ+Mp4fNGrNbT7WRFCLA+I=; b=byeGTB0Pj1R+CjH0rbYVxj9PC6rILiB4fJfnCC6130hh3Y76d0FvpwEgXV2ss309G4j9BB O64w1UMstOphRKVtTtkveorm4UOuLeqF72chjahHvfUzRz2o5ITeKlZzjuL7bRVVHy834v kKdg4Pwe+XQVzlXdQo3WBJA93eEdxqGKGDJw89WUpmfNu5KOw6hDb1HMqPxSOVjqdZdcFH /E9MQPtsSqtfiy3Cswk+CkC3znUJCs2MSaVEC/BA7j3ZiAYjFvx5/HPfq5n6vgCRD0pSJ1 Rn1U5xkJWtvgr/iU4NfeyhUmbwgMCUjFy1KBMBRHKWMBrxm7lL1jMO1OPeK/9Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm2 header.b=ECMVpEuT; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="p GsxRf/"; 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"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1711689642; a=rsa-sha256; cv=none; b=UkAM6iZ2vwq2feBf3q1hawrav0a6I6tYuyFu2iayQE/2xT0St5nucWE+ysLrSmrNmjs3UU BHx2BM+b/zQrYgL38/HRxCVP2hGaB/XYvjMTYbcOxZPhQG2IgIYkmFb1ePlxGPLu7rFwrJ llw/Nkcnp7UnwkpnXEnVUc8KgALpVG+0NVLLPlyhsHeyZSDuCGWVbPN7j1T/50ARzrXBAk 5HsPQI/imV+IBlPWN99bbIj+yzR4VSp4IvLjd1PraDHapLRsBeE+OOA+O4dviXsmk0OIZa hJ+RFildBFc/VBPrZS93p/FMADReVsyr1z5nsYLqqN+GTEjeVrs7xMX2m4a97g== 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 3D0CE169CD for ; Fri, 29 Mar 2024 06:20:42 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rq4fG-0003QP-36; Fri, 29 Mar 2024 01:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq4eo-0003JD-Pu for guix-patches@gnu.org; Fri, 29 Mar 2024 01:20:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rq4eo-00067J-GH for guix-patches@gnu.org; Fri, 29 Mar 2024 01:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rq4ep-0004zh-Ic; Fri, 29 Mar 2024 01:20:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70065] [PATCH 5/6] gnu: chez-scheme: Update and simplify machine-type handling. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: philip@philipmcgrath.com, guix-patches@gnu.org Resent-Date: Fri, 29 Mar 2024 05:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70065 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70065@debbugs.gnu.org Cc: Philip McGrath X-Debbugs-Original-Xcc: Philip McGrath Received: via spool by 70065-submit@debbugs.gnu.org id=B70065.171168956119099 (code B ref 70065); Fri, 29 Mar 2024 05:20:03 +0000 Received: (at 70065) by debbugs.gnu.org; 29 Mar 2024 05:19:21 +0000 Received: from localhost ([127.0.0.1]:41490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rq4e8-0004xo-Mq for submit@debbugs.gnu.org; Fri, 29 Mar 2024 01:19:21 -0400 Received: from wfout2-smtp.messagingengine.com ([64.147.123.145]:38521) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rq4e1-0004wi-Pc for 70065@debbugs.gnu.org; Fri, 29 Mar 2024 01:19:14 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.west.internal (Postfix) with ESMTP id 052DD1C000A6 for <70065@debbugs.gnu.org>; Fri, 29 Mar 2024 01:19:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 29 Mar 2024 01:19:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1711689546; x=1711775946; bh=l99BGI7dBeu6d8SAQn/mt lZ+Mp4fNGrNbT7WRFCLA+I=; b=ECMVpEuTbyNrQv12u2ZRgHy57FfynM6NaKtHB ZFUIkFFQkBltdOsCFHVRqWYXFKSKcjrSeosm3NFSUothRS0+uyPZiHb/VnJIKHbP F+/Ej7wiAt2/wHp8wL9LB7MrMjunoyjwjGFPATVJLLVml1+A41CeenNVcJ5hJZjw S3AyDmLKIV8OtfiAjAtWPXkiOvmPP53Hf1+9yKHyxvWLNzt8DxPTt8rhRfbEZhLF SQEE9bfJ7bnV6vvC/ZbYHOhV+AFLW/EHUXiZ0AugwUcA0uAPU50RmN4iL1A8dp/F x4aON0z0tOBcQC7Tu87Q+KrxdOiRUVNMSwsfwgKv/M3JN11AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1711689546; x= 1711775946; bh=l99BGI7dBeu6d8SAQn/mtlZ+Mp4fNGrNbT7WRFCLA+I=; b=p GsxRf/MQP7SUzI/xFfRRtCPjfQXkPdMZbj58u3dyfCGhpVaYS9LswMihVd3+o918 EG/faRUl6puIcS2dlM1/jVpTdkuWB08mSedgkKo2XsVZZ/eFkPNK6NkL/GkhEo93 e47D82Plr6tTV4DT8MoHMKDibVAqIZRJxx+uIWAcFyQ7WilJs5v7UFf+cn75X0N9 mFoQkVoVKGg7n4zqwAlYr0S1yKnpGalX3Mw2lEKOJH6AvZoFeQC0nFo8wmAu2nwr NiwxIWqNr/N6P5VjwqWYo5vV5SuLHUOqTk/hw6bZPLPCE5ae9m2ljzFH/4TX0Hvr 3dihZRgZFYWbGpce+tzvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddvtddgfeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhggtgfgsehtke ertdertdejnecuhfhrohhmpefrhhhilhhiphcuofgtifhrrghthhcuoehphhhilhhiphes phhhihhlihhpmhgtghhrrghthhdrtghomheqnecuggftrfgrthhtvghrnhephffgieefhf egieelhfehvdekteekvdffkeeiieekhffglefhkeeigffggeevheevnecuffhomhgrihhn peguihhstghouhhrshgvrdhgrhhouhhpnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepphhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrdgt ohhm X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <70065@debbugs.gnu.org>; Fri, 29 Mar 2024 01:19:06 -0400 (EDT) From: Philip McGrath Date: Fri, 29 Mar 2024 01:18:54 -0400 Message-ID: <1b01392a622c3ba51360ffccfa1746738fc39837.1711688274.git.philip@philipmcgrath.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -1.45 X-Migadu-Queue-Id: 3D0CE169CD X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -1.45 X-TUID: 26T7MKtbAtmA 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 --- gnu/packages/chez.scm | 197 ++++++++++++++++------------------------ gnu/packages/racket.scm | 4 +- 2 files changed, 81 insertions(+), 120 deletions(-) diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index 406180ce0f..3f9bdbfbfc 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -50,7 +50,7 @@ (define-module (gnu packages chez) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (chez-scheme-for-system - racket-cs-native-supported-system? + nix-system->native-chez-machine-type nix-system->pbarch-machine-type unpack-nanopass)) @@ -93,6 +93,8 @@ (define* (target-chez-arch #:optional (system "ppc32") ((target-riscv64? system) "rv64") + ((string-prefix? "loongarch64-" system) + "la64") (else #f))) @@ -127,111 +129,67 @@ (define* (target-chez-os #:optional (system (or (%current-target-system) (else #f))) -(define %chez-features-table - ;; An alist of alists mapping: - ;; os -> arch -> (or/c #f (listof symbol?)) - ;; where: - ;; - `os` is a string for the OS part of a Chez Scheme machine type; and - ;; - `arch` is a string for the architecture part of a Chez machine type. - ;; - ;; The absence of an entry for a given arch--os pair means that neither - ;; upstream Chez Scheme nor the Racket variant can generate native code for - ;; that system. (The Racket variant can still provide support via its - ;; ``portable bytecode'' backends and optional compilation to C.) A value - ;; of `#f` means that upstream Chez Scheme does not support the arch--os - ;; pair at all, but the Racket variant does. A list has the same meaning as - ;; a result from `chez-upstream-features-for-system`. - ;; - ;; The arch--os pairs marked "commented out" have been commented out in the - ;; STeX source for the upstream release notes since the initial release as - ;; free software, but they are reported to work and/or have been described - ;; as supported by upstream maintainers. - ;; - ;; For this overall approach to make sense, we assume that Racket's variant - ;; of Chez Scheme can generate native code for a superset of the platforms - ;; supported upstream, supports threads on all platforms it supports at all - ;; (because they are needed for Racket), and doesn't need bootstrap - ;; bootfiles. Those assumptions have held for several years. - '(;; Linux - ("le" - ("i3" threads bootstrap-bootfiles) - ("a6" threads bootstrap-bootfiles) - ("arm32" bootstrap-bootfiles) - ("arm64" . #f) - ("rv64" . #f) - ("ppc32" threads)) - ;; Hurd - ("gnu" - ("i3" . #f)) - ;; FreeBSD - ("fb" - ("i3" threads) ;; commented out - ("a6" threads) ;; commented out - ("arm32" . #f) - ("arm64" . #f) - ("ppc32" . #f)) - ;; OpenBSD - ("ob" - ("i3" threads) ;; commented out - ("a6" threads) ;; commented out - ("arm32" . #f) - ("arm64" . #f) - ("ppc32" . #f)) - ;; 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-syntax define-machine-types + (lambda (stx) + (syntax-case stx (any) + ((_ any id0 id ...) + #`(define #,(datum->syntax #'id0 '%machine-types) + '(id0 id ...)))))) +;; The following is copied from s/cmacros.ss, line 36, in the Chez source +(define-machine-types + any + pb tpb + pb32l tpb32l + pb32b tpb32b + pb64l tpb64l + pb64b tpb64b + i3nt ti3nt + i3osx ti3osx + i3le ti3le + i3fb ti3fb + i3ob ti3ob + i3nb ti3nb + i3s2 ti3s2 + i3qnx ti3qnx + i3gnu ti3gnu + a6nt ta6nt + a6osx ta6osx + a6le ta6le + a6fb ta6fb + a6ob ta6ob + a6nb ta6nb + a6s2 ta6s2 + ppc32osx tppc32osx + ppc32le tppc32le + ppc32fb tppc32fb + ppc32ob tppc32ob + ppc32nb tppc32nb + arm32le tarm32le + arm32fb tarm32fb + arm32ob tarm32ob + arm32nb tarm32nb + arm64nt tarm64nt + arm64osx tarm64osx + arm64le tarm64le + arm64fb tarm64fb + arm64ob tarm64ob + arm64nb tarm64nb + rv64le trv64le + rv64fb trv64fb + rv64ob trv64ob + rv64nb trv64nb + la64le tla64le +) (define* (nix-system->pbarch-machine-type #:optional (system (or (%current-target-system) (%current-system))) #:key (threads? #t)) - "Return a string naming the pseudo–machine type used by Racket's variant of -Chez Scheme to represent the appropriate ``pbarch'' backend for SYSTEM: that -is, the ``portable bytecode'' backend specialized for SYSTEM's word size and -endianness. The result will name the threaded machine type unless THREADS? is -provided and is #f." + "Return a string naming the Chez Scheme machine type of the appropriate +``pbarch'' backend for SYSTEM: that is, the ``portable bytecode'' backend +specialized for SYSTEM's word size and endianness. The result will name the +threaded machine type unless THREADS? is provided as #f." (string-append (if threads? "t" "") @@ -243,20 +201,23 @@ (define* (nix-system->pbarch-machine-type #:optional "l" "b"))) -(define* (racket-cs-native-supported-system? #:optional - (system - (or (%current-target-system) - (%current-system)))) - "Can Racket's variant of Chez Scheme generate native code for SYSTEM? If -so, return the applicable machine type as a string. Otherwise, when SYSTEM -can use only the ``portable bytecode'' backends, return #f." - (let ((chez-arch (target-chez-arch system)) - (chez-os (target-chez-os system))) - (and (and=> (assoc-ref %chez-features-table chez-os) - ;; NOT assoc-ref: supported even if cdr is #f - (cut assoc chez-arch <>)) - (string-append "t" chez-arch chez-os)))) - +(define* (nix-system->native-chez-machine-type #:optional + (system + (or (%current-target-system) + (%current-system))) + #:key (threads? #t)) + "Return a string naming the Chez Scheme machine type of the native-code +backend for SYSTEM, if such a native-code backend exists. Otherwise, when +SYSTEM can use only the ``portable bytecode'' backends, return #f. The result +will name the threaded machine type unless THREADS? is provided as #f." + (let* ((chez-arch (target-chez-arch system)) + (chez-os (target-chez-os system)) + (machine + (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: ;; @@ -300,7 +261,7 @@ (define-public chez-scheme-for-racket (version "9.9.9-pre-release.23") (source #f) (build-system gnu-build-system) - (inputs `(,@(if (racket-cs-native-supported-system?) + (inputs `(,@(if (nix-system->native-chez-machine-type) '() (list libffi)) ,chez-scheme-for-racket-bootstrap-bootfiles @@ -353,10 +314,10 @@ (define-public chez-scheme-for-racket (search-input-directory %build-inputs "/include/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))) ;; ^ 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 ;; https://racket.discourse.group/t/950/9 @@ -585,7 +546,7 @@ (define-public chez-scheme-for-racket-bootstrap-bootfiles (invoke "./configure" "--force" ; don't complain about missing bootfiles #$(string-append - "-m=" (or (racket-cs-native-supported-system?) + "-m=" (or (nix-system->native-chez-machine-type) (nix-system->pbarch-machine-type))) "ZUO=zuo" ;; ignore submodules: diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm index d366f89845..f50f6f3eab 100644 --- a/gnu/packages/racket.scm +++ b/gnu/packages/racket.scm @@ -433,7 +433,7 @@ (define-public racket-vm-cs (inputs (let ((inputs (modify-inputs (package-inputs racket-vm-cgc) (prepend zlib lz4)))) - (if (racket-cs-native-supported-system?) + (if (nix-system->native-chez-machine-type) (modify-inputs inputs (delete "libffi")) inputs))) @@ -461,7 +461,7 @@ (define-public racket-vm-cs #+(this-package-native-input "chez-scheme-for-racket") "/bin/scheme") - #$@(if (racket-cs-native-supported-system?) + #$@(if (nix-system->native-chez-machine-type) #~() #~(#$(string-append "--enable-mach=" (nix-system->pbarch-machine-type)) -- 2.41.0