From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4GqVJL7j9GIidQAAbAwnHQ (envelope-from ) for ; Thu, 11 Aug 2022 13:10:54 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id QLSbJL7j9GJgYgEA9RJhRA (envelope-from ) for ; Thu, 11 Aug 2022 13:10:54 +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 41ACB28DB7 for ; Thu, 11 Aug 2022 13:10:54 +0200 (CEST) Received: from localhost ([::1]:57752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM65V-0001VR-DC for larch@yhetil.org; Thu, 11 Aug 2022 07:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM64j-0000hd-Pt for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM64j-0005Yk-DS for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oM64j-0006Z9-8I for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57050] [PATCH v2 09/13] gnu: chez-scheme-for-racket: Suport all systems. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 11 Aug 2022 11:10:05 +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: Liliana Marie Prikler , Liliana Marie Prikler , Philip McGrath , Thiago Jung Bauermann Received: via spool by 57050-submit@debbugs.gnu.org id=B57050.166021616725094 (code B ref 57050); Thu, 11 Aug 2022 11:10:05 +0000 Received: (at 57050) by debbugs.gnu.org; 11 Aug 2022 11:09:27 +0000 Received: from localhost ([127.0.0.1]:51843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oM646-0006WZ-GV for submit@debbugs.gnu.org; Thu, 11 Aug 2022 07:09:27 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]:35780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oM644-0006W8-1K for 57050@debbugs.gnu.org; Thu, 11 Aug 2022 07:09:24 -0400 Received: by mail-qt1-f182.google.com with SMTP id h22so7730062qtu.2 for <57050@debbugs.gnu.org>; Thu, 11 Aug 2022 04:09:24 -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=7MKC3/Pnu/mtp7H3lV/Zz0rLWbz6x5gR+yWAVKjusII=; b=gRwGIXNJmuv/T+l9JguzlEjFYOw1Vw7SW92udkr8uwQYEbG3RQTQ+CSUJy/Lz76Vt1 xIcePTfQsRdNA/9ImyzXGEWDGPusc/VjBYuxiHgJEt7pCmVvcwvgRUvE6RjEgu9tD5ga UlP1noryHHUteXzr3cpabLbJ0ttzZqc5IVaOtq3eNsZ/9bAJT32owngaSzX023u14Uwr AmZxScM2tn0BlV/EfgNA++p7pTeduBz//dQJJhiNWLKXb+3+J+dg3HdDZamq3+zhQNsz sFRc9KpogUtwLrgSAwOQbAz/RQhR0tORT5L/biiqmLH72REoemKwEwVtcLknMlocOzYj VvHQ== 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=7MKC3/Pnu/mtp7H3lV/Zz0rLWbz6x5gR+yWAVKjusII=; b=W2Sesz/Z4PNVEthuzUVUQueSBpVCD0d575q5dU4zD2O31MVBtpqBM/l6DdOR0Dx+nI KWcuV1KisOEIoqcTwmX6YFhspQ2HWGCXaNvBj/LKvOB8ZvKsTFQmYmC6yGxsWUGKGFgK KIbwO4BSqLeXUUzbX7t72BAtjMVdGOZzr2XwA8299b3LWbEZkz2rTT5MdPJHqbcSyH+R 8dFdYqa878B2fU7FNc+OJqczJnNrfNVbjQ2bvxxKIfIqwRBXSA2kY8M55CZ5V5HszzCA HulvkMx6lBfRS8+a35kCMGN1df9nNyDWjADbUhaRpGkbwMJpkTqRvatPQETjLzMdwSvR aztA== X-Gm-Message-State: ACgBeo1r9El/qBfdDkiNQEFCNBAdb8Zs843to4HqWSu485NsrqZEVq5u R4BPb7pftgisrCwAIOnQ45/qgoC7S2fiBXDh X-Google-Smtp-Source: AA6agR4WBvPesoFHfZb1O9SVRjXkmWFUZsi+h+XbDuOYmzefXW06za+olp+lPhyrYWf3l3vqEfpAMg== X-Received: by 2002:ac8:57d2:0:b0:31f:1f3:b3ec with SMTP id w18-20020ac857d2000000b0031f01f3b3ecmr28000425qta.214.1660216158474; Thu, 11 Aug 2022 04:09:18 -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 u8-20020ac87508000000b0031e9ab4e4cesm1480985qtq.26.2022.08.11.04.09.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Aug 2022 04:09:18 -0700 (PDT) From: Philip McGrath Date: Thu, 11 Aug 2022 07:08:19 -0400 Message-Id: <4d63cf22559de641440810e451b9366aa6091774.1660215295.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=1660216254; 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=7MKC3/Pnu/mtp7H3lV/Zz0rLWbz6x5gR+yWAVKjusII=; b=bZOtL8Mx7QivXIPEl4fxjb89iqtEctgzlrSwwEbRlOfd+l1YtNViGuVK4vUEAdrHKpipGP 1XAuAODYUZMG0RJknkVMc0QYHSdRRhi8QRcP3ariDAIUAxnUsJp/DhHDqyOSWz6O+g2CJr JBYJnLdqyNW39X9rXkppr6BOTB5TnV5wLA7od33DnKvmZr4bYoVOVeVnYPY3LhDlgIZu4B J3m1RQqJDCaJ5lt2YCTu1Tgly5pCtrNgNHGWfsHGK8ZRmaF2N9KTfhZp17PCLFCiT8ZMzI Vi+hkUpz7B94Xp2cEQSsVPam9TEnVh1hqhUVTcbw6xd4W9I8DvvLhLj7Acx2aQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660216254; a=rsa-sha256; cv=none; b=H25KHQwv+EVWQgAgDO6LcqqHRFB5ujFswOeTmGRmYIZK2dxk4uDsmQ6ZkcS8UawL+9h1cI rN2VKfFWmT7E462xVYfCcMvBt01OcrZJRK+pMRAP0gmr+AeCnohvHGxlYNVAo2GNp2k9+2 +1jO/ey9QoRu7WrLNiZE6w6GUqkObPWGyV5V8DXnx0ADFUWljuAkVq88frm5CCfaU8tgU9 74X0UVPaMG4PJzjW6DqBL90cyJv+lGxfryJt2L3aY3xEuam2JACm3sGnYzq60Bos7X2AXl 9o43rinmwZru4IdZZZBoWOi3rDN+I9fiozY6HJ0mTDCtagqs7FtzDhDnYgeysA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gRwGIXNJ; 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: 5.12 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gRwGIXNJ; 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: 41ACB28DB7 X-Spam-Score: 5.12 X-Migadu-Scanner: scn1.migadu.com X-TUID: pM/QlKAI+Z/J On systems for which Racket's variant of Chez Scheme cannot generate native code, it can use a 'pbarch' machine type: a variant of the ``portable bytecode'' backend specialized to word size and endianness. This allows Racket CS to replace Racket BC on those systems while maintaining comparable performance. (Racket BC lacks JIT support for those systems anyway.) It also lets us provide a Chez Scheme package on all systems Guix supports. This patch adds 'pbarch' support to both 'chez-scheme-for-racket' and 'racket-vm-cs', but it does not change the Racket VM implementation used for the 'racket' and 'racket-minimal' packages. * gnu/packages/chez.scm (nix-system->pbarch-machine-type): New variable. (chez-scheme-for-racket)[inputs]: Use 'libffi' for non-native systems. [arguments]<#:configure-flags>: Always supply '-m='. Add applicable flags for non-native systems. [supported-systems]: Use '%supported-systems'. [description]: Update. (chez-scheme-for-racket-bootstrap-bootfiles)[arguments]<#:phases>: Adapt 'build' phase for non-native systems. * gnu/packages/racket.scm (racket-vm-bc)[description]: Update. (racket-vm-cs)[description]: Likewise. [inputs]: Use 'libffi' for non-native systems. [arguments]<#:configure-flags>: Add applicable flags for non-native systems. --- gnu/packages/chez.scm | 76 ++++++++++++++++++++++++++++++----------- gnu/packages/racket.scm | 26 +++++++++----- 2 files changed, 74 insertions(+), 28 deletions(-) diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index be9884b3d2..38b724ae5f 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -38,6 +38,7 @@ (define-module (gnu packages chez) #:use-module (gnu packages compression) #:use-module (gnu packages ncurses) #:use-module (gnu packages ghostscript) + #:use-module (gnu packages libffi) #:use-module (gnu packages linux) #:use-module (gnu packages netpbm) #:use-module (gnu packages racket) @@ -50,6 +51,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,6 +234,28 @@ (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) @@ -453,10 +477,14 @@ (define-public chez-scheme-for-racket ;; When updating, remember to also update %racket-version in racket.scm. (source #f) ; avoid problematic cycle with racket.scm (inputs - (modify-inputs (package-inputs chez-scheme) - (delete "libx11" "util-linux:lib") - (replace "chez-scheme-bootstrap-bootfiles" - chez-scheme-for-racket-bootstrap-bootfiles))) + (let ((inputs (modify-inputs (package-inputs chez-scheme) + (replace "chez-scheme-bootstrap-bootfiles" + chez-scheme-for-racket-bootstrap-bootfiles) + (delete "libx11" "util-linux:lib")))) + (if (racket-cs-native-supported-system?) + inputs + (modify-inputs inputs + (append libffi))))) (native-inputs (let ((native-inputs (modify-inputs (package-native-inputs chez-scheme) (append zuo)))) @@ -477,10 +505,16 @@ (define-public chez-scheme-for-racket ((#:configure-flags cfg-flags #~'()) #~`("--disable-x11" "--threads" ;; ok to potentially duplicate - #$@(if (%current-target-system) - (list (string-append "-m=" - (racket-cs-native-supported-system?))) - '()) + #$(string-append "-m=" (or (racket-cs-native-supported-system?) + (nix-system->pbarch-machine-type))) + ;; ^ could skip -m= for non-cross non-pbarch builds + #$@(if (racket-cs-native-supported-system?) + #~() + ;; not inferred on non-native platforms: see + ;; https://racket.discourse.group/t/950/9 + #~("--enable-libffi" + "CFLAGS=-g -O2 -D_REENTRANT -pthread" + "LIBS=-lm -ldl -lrt -lffi -lncurses")) #$@(if (%current-target-system) (list (string-append "--toolprefix=" (%current-target-system) @@ -547,10 +581,7 @@ (define-public chez-scheme-for-racket (add-after 'unpack 'chdir (lambda args (chdir "racket/src/ChezScheme")))))))) - ;; TODO: How to build pbarch/pbchunks for other systems? - ;; See https://racket.discourse.group/t/950 - (supported-systems (filter racket-cs-native-supported-system? - %supported-systems)) + (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 @@ -563,13 +594,17 @@ (define-public chez-scheme-for-racket Main additions to Chez Scheme in the Racket variant: @itemize @bullet @item -AArch64 support +AArch64 code generation @item -Portable bytes (@code{pb}) support, which is mainly useful for bootstrapping -a build on any supported platform +Portable bytecode (@code{pb}) mode, which is mainly useful for bootstrapping a +build on any platform, but can also be used on platforms without native-code +generation, compiled via Emscripten, linked with @code{libffi}, or used with +bytecode partially compiled to C @item Unboxed floating-point arithmetic and flvectors @item +Faster multiplication and division for large exact numbers +@item Type reconstruction during optimization (especially for safe code) @item Continuation attachments @@ -580,8 +615,6 @@ (define-public chez-scheme-for-racket @item Ordered finalization, immobile (but collectable) objects, weak/ephemeron generic hash tables, and reference bytevectors -@item -Faster multiplication and division for large exact numbers @end itemize") (license asl2.0))) @@ -659,13 +692,18 @@ (define-public chez-scheme-for-racket-bootstrap-bootfiles "makefiles/boot.zuo" (search-input-file (or native-inputs inputs) "/bin/scheme") - #$(racket-cs-native-supported-system?))) + #$(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")))))))))) + "rktboot/main.rkt" + #$@(if (racket-cs-native-supported-system?) + #~() + (let ((m (nix-system->pbarch-machine-type))) + #~("--machine" #$m))))))))))))) (supported-systems (package-supported-systems chez-scheme-for-racket)) (home-page "https://github.com/racket/ChezScheme") diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm index ef353103d6..3b96cf46ef 100644 --- a/gnu/packages/racket.scm +++ b/gnu/packages/racket.scm @@ -331,7 +331,7 @@ (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 + libffi)) ;; <- for BC and non-native CS variants (native-inputs (cons* zuo ;; <- for all variants libtool ;; <- only for BC variants (if (%current-target-system) @@ -437,10 +437,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'').") @@ -453,9 +451,12 @@ (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 (let ((native-inputs (package-native-inputs racket-vm-cgc))) (modify-inputs (if (%current-target-system) @@ -484,12 +485,19 @@ (define-public racket-vm-cs #+(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.") -- 2.32.0