From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oBoYFEap8GJvugAAbAwnHQ (envelope-from ) for ; Mon, 08 Aug 2022 08:12:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GHMGFEap8GJwDwEA9RJhRA (envelope-from ) for ; Mon, 08 Aug 2022 08:12:22 +0200 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 B192E20671 for ; Mon, 8 Aug 2022 08:12:21 +0200 (CEST) Received: from localhost ([::1]:53470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oKvzu-0004YJ-9E for larch@yhetil.org; Mon, 08 Aug 2022 02:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oKvyj-0003jq-06 for guix-patches@gnu.org; Mon, 08 Aug 2022 02:11:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oKvyi-0002o1-4u for guix-patches@gnu.org; Mon, 08 Aug 2022 02:11:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oKvyi-0002uK-0s for guix-patches@gnu.org; Mon, 08 Aug 2022 02:11:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57050] [PATCH 5/6] gnu: racket: Use Racket CS on all systems. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Aug 2022 06:11:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57050 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57050@debbugs.gnu.org Cc: Philip McGrath Received: via spool by 57050-submit@debbugs.gnu.org id=B57050.165993904811114 (code B ref 57050); Mon, 08 Aug 2022 06:11:03 +0000 Received: (at 57050) by debbugs.gnu.org; 8 Aug 2022 06:10:48 +0000 Received: from localhost ([127.0.0.1]:38942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKvyR-0002t6-CE for submit@debbugs.gnu.org; Mon, 08 Aug 2022 02:10:48 -0400 Received: from mail-qt1-f171.google.com ([209.85.160.171]:45782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKvyL-0002sW-Pr for 57050@debbugs.gnu.org; Mon, 08 Aug 2022 02:10:42 -0400 Received: by mail-qt1-f171.google.com with SMTP id j17so1020132qtp.12 for <57050@debbugs.gnu.org>; Sun, 07 Aug 2022 23:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=rlyMJ2HDC3VXq/4buniVDog5X+AbTWspFUQWZp9ZxgE=; b=gtbhS8cj1j0J4A4HHnQRcPr5v2mqP0iIA+ZnrNGTh77+6TbhI62bU9gPaytrKt5E55 rucWMLpfVODBEg+l4QDyX42K+kCPrb2hAffxDpW9DkibF+ch2huTN2ryB/dfd1HTLMZ/ PuJMvnrF2ZEZIDsZlstwlWe7sSyArF9Acnv9hNo+ixIDx6khzoU0d6MIx3hHLo1LiHsC vqcOp1f9vMek83g2uMX513c3Mm1CP1i78g3opkCokbom1jXhVXzZC38T6AmYpQg4EqRf yJYfW21hPvWFiJ5gNPK0YGdTzCjqsZ+3lSsA8wqdrv6jpeYv+nO9eMVZNvc5qP1WqmjK 4NPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=rlyMJ2HDC3VXq/4buniVDog5X+AbTWspFUQWZp9ZxgE=; b=g9TGZMjbt3v6y0ZKmwd7DZl3XodkboAXWPEzYjrVUTUSoUx1ayMhEv5xEnBgoukVRr s6uhnyC/xYXkK6eqLOxB8hVBz3fgs6hyOBgwtzpZPE6HYHvBuQHjc9QoJ5Dnkak7PLVo 82A+sRKlepdjmZPZtFbotlq+5RkNck6HMyr556D7Pa98dFpZtrnEvk7HdKyYG9pBDizI kINU9iCTxiNLlNkw2bue9BvarT/YHahdlU3yT8qUJS/DNq82JrPJ0u5EZM8nXqiG9aSr 4SypMQJRfXuKnxE5Rw0bdNAqQa1zS/5IYqeGscFXPqE/oRoO/iT2452Qy1rC0e3IoHOa L8Yw== X-Gm-Message-State: ACgBeo1xdi4rMUgtwQeirge7nXMVK7K4GutK1LWIoHXCoVxAq0dfaFNW 05OqWrMzRps4CcdBHxm4YIdZ26F6tRu6Xa8+ X-Google-Smtp-Source: AA6agR4d9B3k3YGyhv+mO1XAB20E2aVFVcrV3ZT01zx56Y6owRc85PjnhQBQoI20NQ+i/mF2QuFEuA== X-Received: by 2002:a05:622a:14c8:b0:342:f7fe:ab33 with SMTP id u8-20020a05622a14c800b00342f7feab33mr3374009qtx.327.1659939036163; Sun, 07 Aug 2022 23:10:36 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id ay39-20020a05620a17a700b006a5d2eb58b2sm8431884qkb.33.2022.08.07.23.10.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Aug 2022 23:10:36 -0700 (PDT) From: Philip McGrath Date: Mon, 8 Aug 2022 02:10:06 -0400 Message-Id: <497d143fafeb9c866e278454dd0b1235796ac68f.1659936550.git.philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659939141; 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=rlyMJ2HDC3VXq/4buniVDog5X+AbTWspFUQWZp9ZxgE=; b=L4smPdH0bYKmGtcIUM44dQ9v9tZ24MkRs7XYCe/7WeNoB+KugtvTyyy44j+hD0CsFUrtJC bIl4TXZ9jvz68mYmnKCZ6yNItjQQQcu8Bvil3ME88RnBsVWP90VzBRp3YAUTXSG1a7olDz yWPQo2zkEurC35jsQ+zoLJNVpgwLXTclv6ce4pTVFDzbt1aLtGjRf1bPBLoxFN+aY3r2Ed jCzUJcoeXoB98ubCTPGT8+ZxEny3HVLoXopsjNNkvAyKZjLswnR9uaP6G/keaQronrze4c v7zxdnXfi39pZDx1YBqXZynAroZF4KGSRZDKuX6ZKiythF4i9IW8KEoE4Cv/Zw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659939141; a=rsa-sha256; cv=none; b=n6Fe4k7FTye7Q0khz3O8VDlT34J/kK3lIJKdzRKI5Xvv9F5komgFdWb6eg3bf/Aa2EBkFK lxUstnWErNwmr8lGeBo0QoNBNC9mA6BECr7nswTkzAq8sV9N5MS7RaebqgiSUFbkun+KLX ZfcSL0cLU/Tmg2sr2xFJiP4TgMQ4rksmUmgAjoP2mtNWWbr3Y7WAVSKxKsTs1Xyc7JV6Tc Tu/NNjl8auWSBaWX0JYTJdwgM/2kRJAJldmN2udE225Dn1BUL6ocCbFzIh+e5o4oGYr3Xb EbDFfE4wxBnq/wGUolI2w99SLYPc2cAguA9sUS2D9WM/7zIUwGptZmZdwbnC/A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gtbhS8cj; 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: 1.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gtbhS8cj; 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: B192E20671 X-Spam-Score: 1.31 X-Migadu-Scanner: scn0.migadu.com X-TUID: fl2CqT3XAHJZ On systems for which Racket CS cannot generate native code, it can use a 'pbarch' machine type---a variant of the ``portable bytecode'' backend specialized to word size and endianness---allowing Racket CS to replace Racket BC on those systems while maintaining comparable performance. (Racket BC lacks JIT support for those systems anyway.) This patch adds 'pbarch' support to 'racket-vm-cs' and 'chez-scheme-for-racket-bootstrap-bootfiles' and changes 'racket' and 'racket-minimal' to use 'racket-vm-cs' on all systems. In the process, it also adds support for cross-compiling the bootfiles, 'racket-vm-cgc', 'racket-vm-bc', and 'racket-vm-cs'. This is not enough to cross-compile 'racket-minimal' or 'racket': that would require building and loading cross-compilation pluggins for 'racket-vm-cs', which will be much easier once we can build the package 'raco-cross'. This patch does not address 'chez-scheme-for-racket'. * gnu/packages/chez.scm (nix-system->pbarch-machine-type): New variable. (racket-cs-native-supported-system): Change to return the applicable machine type instead of '#t'. (chez-scheme-for-racket-bootstrap-bootfiles)[native-inputs]: When cross-compiling, use 'zuo' and 'chez-scheme-for-racket' instead of 'racket-vm-bc'. [arguments]: Support cross-compilation and 'pbarch' machine types. [supported-systems]: Use '%supported-systems' instead of inheriting. * gnu/packages/racket.scm (racket-vm-for-system): Remove. (racket-vm-cgc)[native-inputs]: Add 'this-package' when cross-compiling. (racket-vm-bc)[native-inputs]: Adjust accordingly. [description]: Update. (racket-vm-cs)[description]: Likewise. [inputs]: Use 'libffi' for 'pbarch' machine types. [native-inputs]: Use 'racket-vm-cs' instead of 'racket-vm-bc' when cross-compiling. Adapt to changes to 'racket-vm-cgc'. [arguments]<#:configure-flags>: Support cross-compilation and 'pbarch' machine types. (racket-minimal, racket)[inputs]: Replace '(racket-vm-for-system)' with 'racket-vm-cs'. --- gnu/packages/chez.scm | 65 ++++++++++++++++++++++++++++------ gnu/packages/racket.scm | 77 ++++++++++++++++++++++------------------- 2 files changed, 97 insertions(+), 45 deletions(-) diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index dde2c22ca5..2afef8d3bd 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -50,6 +50,7 @@ (define-module (gnu packages chez) #:use-module (srfi srfi-26) #:export (chez-scheme-for-system racket-cs-native-supported-system? + nix-system->pbarch-machine-type unpack-nanopass+stex)) ;; Commentary: @@ -232,18 +233,41 @@ (define* (chez-upstream-features-for-system #:optional (and=> (assoc-ref %chez-features-table chez-os) (cut assoc-ref <> chez-arch)))) +(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." + (string-append (if threads? + "t" + "") + "pb" + (if (target-64bit? system) + "64" + "32") + ;; missing (guix utils) predicate target-little-endian? + (if (target-ppc32? system) + "b" + "l"))) + (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? -Otherwise, SYSTEM can use only the ``portable bytecode'' backends." + "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 <>)) - #t))) + (string-append "t" chez-arch chez-os)))) ;; ;; Chez Scheme: @@ -587,8 +611,12 @@ (define-public chez-scheme-for-racket-bootstrap-bootfiles (name "chez-scheme-for-racket-bootstrap-bootfiles") (version (package-version chez-scheme-for-racket)) (source #f) ; avoid problematic cycle with racket.scm - (native-inputs (list chez-nanopass-bootstrap racket-vm-bc)) - ;; TODO: cross compilation + (native-inputs + (cons* chez-nanopass-bootstrap + (if (%current-target-system) + (list zuo + chez-scheme-for-racket) + (list racket-vm-bc)))) (arguments (substitute-keyword-arguments (package-arguments chez-scheme-bootstrap-bootfiles) @@ -608,11 +636,28 @@ (define-public chez-scheme-for-racket-bootstrap-bootfiles #$unpack-nanopass+stex)) (add-before 'install 'build (lambda* (#:key native-inputs inputs #:allow-other-keys) - (invoke (search-input-file (or native-inputs inputs) - "/opt/racket-vm/bin/racket") - "rktboot/main.rkt")))))))) - (supported-systems - (package-supported-systems chez-scheme-for-racket)) + #$(cond + ((%current-target-system) + ;; cross-compiling + #~(invoke + (search-input-file (or native-inputs inputs) + "/bin/zuo") + "makefiles/boot.zuo" + (search-input-file (or native-inputs inputs) + "/bin/scheme") + #$(or (racket-cs-native-supported-system?) + (nix-system->pbarch-machine-type)))) + (else + ;; bootstrapping + #~(invoke + (search-input-file (or native-inputs inputs) + "/opt/racket-vm/bin/racket") + "rktboot/main.rkt" + #$@(if (racket-cs-native-supported-system?) + #~() + (let ((m (nix-system->pbarch-machine-type))) + #~("--machine" #$m))))))))))))) + (supported-systems %supported-systems) (home-page "https://github.com/racket/ChezScheme") ;; ^ This is downstream of https://github.com/racket/racket, ;; but it's designed to be a friendly landing place for people diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm index f1a2794164..7920d6812c 100644 --- a/gnu/packages/racket.scm +++ b/gnu/packages/racket.scm @@ -129,10 +129,9 @@ (define-module (gnu packages racket) ;; This file defines the packages 'racket-vm-cgc', 'racket-vm-bc', and ;; 'racket-vm-cs'. All three are in-place builds of 'racket/src/' and ;; 'racket/collects/' and are installed to 'opt/racket-vm/' in the store -;; output. The function 'racket-vm-for-system' returns the recomended Racket -;; VM package for a given system. +;; output. ;; -;; We then define the packages 'racket-minimal' and +;; Using 'racket-vm-cs', we then define the packages 'racket-minimal' and ;; 'racket'. These use Racket's support for ``layered installations'', which ;; allow an immutable base layer to be extended with additional packages. ;; They use the layer configuration directly provide ready-to-install FHS-like @@ -193,17 +192,6 @@ (define-module (gnu packages racket) ;; ;; CODE: -(define* (racket-vm-for-system #:optional - (system (or (%current-target-system) - (%current-system)))) - "Return 'racket-vm-cs' if we are able to build it for SYSTEM; 'racket-vm-bc' -otherwise." - ;; Once we figure out the issues in https://racket.discourse.group/t/950, - ;; we can use 'racket-vm-cs' everywhere. - (if (racket-cs-native-supported-system? system) - racket-vm-cs - racket-vm-bc)) - (define %racket-version "8.6") ; Remember to update chez-scheme-for-racket! (define %zuo-version "1.0") ;; defined in racket/src/zuo/zuo.c (define %racket-commit @@ -331,9 +319,12 @@ (define-public racket-vm-cgc (source %racket-origin) (inputs (list ncurses ;; <- common to all variants (for #%terminal) bash-minimal ;; <- common to all variants (for `system`) - libffi)) ;; <- only for BC variants - (native-inputs (list zuo ;; <- for all variants - libtool)) ;; <- only for BC variants + libffi)) ;; <- for BC and non-native CS variants + (native-inputs (cons* zuo ;; <- for all variants + libtool ;; <- only for BC variants + (if (%current-target-system) + (list this-package) + '()))) (outputs '("out" "debug")) (build-system gnu-build-system) (arguments @@ -421,8 +412,10 @@ (define-public racket-vm-bc (inherit racket-vm-cgc) (name "racket-vm-bc") (native-inputs - (modify-inputs (package-native-inputs racket-vm-cgc) - (prepend racket-vm-cgc))) + (if (%current-target-system) + (package-native-inputs racket-vm-cgc) + (modify-inputs (package-native-inputs racket-vm-cgc) + (prepend racket-vm-cgc)))) (arguments (substitute-keyword-arguments (package-arguments racket-vm-cgc) ((#:configure-flags _ '()) @@ -432,10 +425,8 @@ (define-public racket-vm-bc (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 and supports a slightly different -set of architectures than the current default runtime system, Racket CS (based -on ``Chez Scheme''). It is the recommended implementation for architectures -that Racket CS doesn't support. +platforms. Racket BC has a different C API than the current default runtime +system, Racket CS (based on ``Chez Scheme''). This package is the normal implementation of Racket BC with a precise garbage collector, 3M (``Moving Memory Manager'').") @@ -448,15 +439,24 @@ (define-public racket-vm-cs (inherit racket-vm-bc) (name "racket-vm-cs") (inputs - (modify-inputs (package-inputs racket-vm-cgc) - (prepend zlib lz4) - (delete "libffi"))) + (let ((inputs (modify-inputs (package-inputs racket-vm-cgc) + (prepend zlib lz4)))) + (if (racket-cs-native-supported-system?) + (modify-inputs inputs + (delete "libffi")) + inputs))) (native-inputs - (modify-inputs (package-native-inputs racket-vm-cgc) - (delete "libtool") - (prepend chez-scheme-for-racket - chez-nanopass-bootstrap - racket-vm-bc))) + (let ((native-inputs (package-native-inputs racket-vm-cgc))) + (modify-inputs (if (%current-target-system) + (modify-inputs native-inputs + (delete "racket-vm-cgc")) + native-inputs) + (delete "libtool") + (prepend chez-scheme-for-racket + chez-nanopass-bootstrap + (if (%current-target-system) + racket-vm-cs + racket-vm-bc))))) (arguments (substitute-keyword-arguments (package-arguments racket-vm-cgc) ((#:phases those-phases #~%standard-phases) @@ -470,15 +470,22 @@ (define-public racket-vm-cs "--enable-libz" "--enable-lz4" (string-append "--enable-scheme=" - #$(this-package-native-input + #+(this-package-native-input "chez-scheme-for-racket") "/bin/scheme") + #$@(if (racket-cs-native-supported-system?) + #~() + #~(#$(string-append "--enable-mach=" + (nix-system->pbarch-machine-type)) + "--enable-pb")) #$(racket-vm-common-configure-flags))))) (synopsis "Racket CS implementation") (description "The Racket CS implementation, which uses ``Chez Scheme'' as its core compiler and runtime system, has been the default Racket VM implementation since Racket 8.0. It performs better than the Racket BC -implementation for most programs. +implementation for most programs. On systems for which Racket CS cannot +generate machine code, this package uses a variant of its ``portable +bytecode'' backend specialized for word size and endianness. Using the Racket VM packages directly is not recommended: instead, install the @code{racket-minimal} or @code{racket} packages.") @@ -554,7 +561,7 @@ (define-public racket-minimal (inputs (list openssl sqlite - (racket-vm-for-system) + racket-vm-cs (racket-packages-origin "base" %racket-origin '(("base" "pkgs/base") @@ -672,7 +679,7 @@ (define-public racket unixodbc libedit ;; TODO reconsider in light of expeditor and readline-gpl racket-minimal ;; <-- TODO non-tethered layer - (racket-vm-for-system) + racket-vm-cs (simple-racket-origin "2d" (base32 "0fb5v6058ls08xw3zbmqyr2ym0psm119gl9ffgmhm9w8rs9i4dq7") '("2d" "2d-doc" "2d-lib")) -- 2.32.0