From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.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 mG//FtZZCmaOlAAAe85BDQ:P1 (envelope-from ) for ; Mon, 01 Apr 2024 08:53:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id mG//FtZZCmaOlAAAe85BDQ (envelope-from ) for ; Mon, 01 Apr 2024 08:53:10 +0200 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=VFNruFHY; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="t ovLZ5P"; 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=1711954390; 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=WcpquvfO1zLYn5qc67smrGS011/1AwdabIvzco9+Xjg=; b=IAa7B2qAtVvz046V6qd4NW/es5jjr3zaoBvqhuDdbbYfZQN3dfEMQCkC+cF2Y7s4TNgdDJ 3nSfqmP6mg3LkZ1PWdEGcf8ndtOnOknmgDolct3AGNeUSXHcWIMVCTrFJrPnL8fSXIlWC/ PLMKF8YMoSPULmdmY2+eA9eHUx5h1+4cf0ZvB3wM8N+gYzAsRbKcRJF33yfXfOzu/Ut+El HW4EOWBGqMbP+ELlG7QlBo4jnWshtIfdM7+KLAl9LZJs/I96x7sUd2aoEocq3zkFXz0kO0 ECo3TWCYbkSQLTrBYpdn/2TfxSAWnbYRht+4aOPPJiUFJB4sZp5Pu8Awtf53GQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm2 header.b=VFNruFHY; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="t ovLZ5P"; 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=1711954390; a=rsa-sha256; cv=none; b=hByLwaUqhIO0umhSfWFTSYBPg/WKb21CGe23WsRhBQSZieHj1nphBodcwKu05aRWSqShaw gqfrRsocHTRa0SCH99glwihE/OZT4kI2+yq/j4N+8vU95GN63MPZDsXOHTFZ5cGoaeY8Cb 5VnVbWDuinc8pUG5skX75wEj2tyFKdHPw9eW7E9GRi+wnAjx4qmaOzfC+AQpB+VOdSBg0n g1AxhmT/xYjfdAwx7B2GA83eLxrq9LlNHGRqIOd0MsakNd3JwGGG4/9qpHjR6cplu2LCMZ lA88VvL5XzptmVNNKvW+ZKWSbIClH8xYoTrFMtHgaysb4eujOkrjw+HOlvKE0w== 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 2A7213A925 for ; Mon, 1 Apr 2024 08:53:10 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrBXU-0003gH-At; Mon, 01 Apr 2024 02:53:04 -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 1rrBXS-0003fR-Fh for guix-patches@gnu.org; Mon, 01 Apr 2024 02:53:02 -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 1rrBXS-0007xD-7l for guix-patches@gnu.org; Mon, 01 Apr 2024 02:53:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrBXV-0003QV-5h; Mon, 01 Apr 2024 02:53:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70065] [PATCH v2 7/8] 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: Mon, 01 Apr 2024 06:53:05 +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: Katherine Cox-Buday , Liliana Marie Prikler , Andrew Tropin , Philip McGrath , Skyler Ferris , Philip McGrath X-Debbugs-Original-Xcc: Philip McGrath Received: via spool by 70065-submit@debbugs.gnu.org id=B70065.171195438313137 (code B ref 70065); Mon, 01 Apr 2024 06:53:05 +0000 Received: (at 70065) by debbugs.gnu.org; 1 Apr 2024 06:53:03 +0000 Received: from localhost ([127.0.0.1]:49381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrBXS-0003PZ-6u for submit@debbugs.gnu.org; Mon, 01 Apr 2024 02:53:03 -0400 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]:38757) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrBXQ-0003Ox-9O for 70065@debbugs.gnu.org; Mon, 01 Apr 2024 02:53:01 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 296AD13800D9; Mon, 1 Apr 2024 02:52:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 01 Apr 2024 02:52:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc: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=1711954372; x=1712040772; bh=WcpquvfO1z LYn5qc67smrGS011/1AwdabIvzco9+Xjg=; b=VFNruFHYc5r7WaySeAnltx7GBf gr693Dbst/gswAUs0sLhc3EDT3HwOPMBjZWJtm2SKLs0nriEGsgg0FN6GnhyH3LH 1bRITB4dv6peEyInTK7gDXcvA/9jb63Hop+aMBqPWifuCMGavAh7pBS/vpfQj7IS rj+3TrzSO/IGjQXPEdPK3n+RvyAfMaJEE+YuUexeYuffslBBsL0+kqa6o8oedATb Km+QJVIbiUTmrD8MyC4iryIW4wEe3WuBhZWsaNsHgdUUDo0IGR0qf2X16403wrcq 0+dVWhlJpeOlU1PkHtmQeLuK3ev6ZFYOMwr+ltAWfrTV+zLrWlMQJUX3C4AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1711954372; x= 1712040772; bh=WcpquvfO1zLYn5qc67smrGS011/1AwdabIvzco9+Xjg=; b=t ovLZ5PZlZqNWEb95NsIBchTBFuUbgsgrWG1V7lk18e+jfHtH1JqIBMOkf7IhAZUa 6aJUm1dkcDMpv6uxiRxU8ydF0H+QsuFqRiemcA4txPzRuHmnm94VhdZlyn35Vm6b 9z6EnJKFwt4lEf5u2F8xy06N+T4p8Z51IGn2UMFe6pWUvDS1cIM1ATtRIDKVwTk3 NwN6vL3IlOHv9FxfWPK0lEBdwMuLssdHi0LA/AuoWzL/Mbut1/CDo3tcIBQnU4XF A7ngvyMNkxlYqXGgIwa+dzsi0hAMW+5AOtJY42L10yMitaa6Obq/AoHXzOMfNhsh CRDeHezd29dmLOb9Gb20Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddvledgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomheprfhh ihhlihhpucfotgfirhgrthhhuceophhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrd gtohhmqeenucggtffrrghtthgvrhhnpeetjefgvdfhvddtkedvhffffedtgfehuefffffg keetheffheduvdeifefhgefgvdenucffohhmrghinhepughishgtohhurhhsvgdrghhroh huphenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehp hhhilhhiphesphhhihhlihhpmhgtghhrrghthhdrtghomh X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 02:52:51 -0400 (EDT) From: Philip McGrath Date: Mon, 1 Apr 2024 02:51:12 -0400 Message-ID: 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: 0.05 X-Migadu-Queue-Id: 2A7213A925 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 0.05 X-TUID: ZePPJvgze0+r 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 807a143f61..4d3f79d9a7 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 @@ -588,7 +549,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