From patchwork Sat Aug 27 18:55:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip McGrath X-Patchwork-Id: 42008 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1A27227BBEA; Sat, 27 Aug 2022 19:59:00 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7048127BBE9 for ; Sat, 27 Aug 2022 19:58:59 +0100 (BST) Received: from localhost ([::1]:44858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oS11G-00055W-Ju for patchwork@mira.cbaines.net; Sat, 27 Aug 2022 14:58:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oS10O-0004KN-6y for guix-patches@gnu.org; Sat, 27 Aug 2022 14:58:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oS10N-0001i7-U5 for guix-patches@gnu.org; Sat, 27 Aug 2022 14:58:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oS10N-0008JH-R6 for guix-patches@gnu.org; Sat, 27 Aug 2022 14:58:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57050] [PATCH v4 10/14] gnu: chez-scheme-for-racket: Support cross-compilation. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 27 Aug 2022 18:58: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 , Thiago Jung Bauermann , "\(" , Maxime Devos , Liliana Marie Prikler , Efraim Flashner , Liliana Marie Prikler Received: via spool by 57050-submit@debbugs.gnu.org id=B57050.166162665431852 (code B ref 57050); Sat, 27 Aug 2022 18:58:03 +0000 Received: (at 57050) by debbugs.gnu.org; 27 Aug 2022 18:57:34 +0000 Received: from localhost ([127.0.0.1]:57077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS0zt-0008Ha-Em for submit@debbugs.gnu.org; Sat, 27 Aug 2022 14:57:33 -0400 Received: from mail-vs1-f47.google.com ([209.85.217.47]:35491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS0zS-0008Ez-IL for 57050@debbugs.gnu.org; Sat, 27 Aug 2022 14:57:07 -0400 Received: by mail-vs1-f47.google.com with SMTP id 67so4692469vsv.2 for <57050@debbugs.gnu.org>; Sat, 27 Aug 2022 11:57:06 -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=ooUpIt6v6GE6eFoJemQYYCCp1VZ+cCUGyFCLbJm82Ag=; b=ASCyFRuGkg7P7h7ErdubKW+AvLaaZfiFugJL/2BHQT/ClQrGxMrZUmYIEdC3d8LXat 8QdKVfDjVfd6lOPvWMd47CY2XY+ONHZEHQWg4cl4r9UxFIifF6zWGZ7aYJo60lmsQneA 35Cv7AHxy0fOYeD4VlW199M/GZAvBh8013kD2zZACNjfLF4R+/QVZv7WKdR66PwM6JAR 55YMXlH41ZBI5yYZedhtJzUxB1P/MauCJzJVkJ6jMH1lcXooTqm9W8xGlaGvc/emh8d4 8eGYMhGZ9vFUmtmHT/dxsCHfQo86LXiUQks4q/6VusODZi9MsGtHRzp84eV4DFvjSUZ2 cyOw== 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=ooUpIt6v6GE6eFoJemQYYCCp1VZ+cCUGyFCLbJm82Ag=; b=vBU7ASGmQEdWAvy9i4AIdX9RTl2GiWWzbN6W7rXFW2LH4R6iIZCzE9cUAe6zE2s2ne QjTdPxYWzze2TTG6GQLrRgOEhAbDYPfj2kiJPzws/In5vz6nEDWR2+ZxtwO7BGq7oX60 +tYjU7h7baCID0J1OCV7DAj7RZbbe/CDfDe7bwE41s6B2z+7f0BTrdWNLOzibQrt6II7 N0sZT6UqcMZdP+OnwLxKHJRRMNQckeojV1vbOuyuMRG91aMOffvJKj2Z/Y+i7mg3jFKA E8scLOk6b9uYCmLAU/Q7aQXKySGSwU5rZ1Grxvumc9uTid0ePFv86NWXelegoWw41rIJ N8pQ== X-Gm-Message-State: ACgBeo2F9zywpef3sjUIpZUI6hGg1naGMxhQ2FscDHKFclpJdMvC1Uvv vKTDwH96Rahmx7ncFepgzqAzJkF/29otNQio X-Google-Smtp-Source: AA6agR68CEcAyQAS4/15apZHAXEjwXAKEHBjSN+HzMBwVNy1DWa4vHgz17NakQjDJWwv83AijXsAAQ== X-Received: by 2002:a05:6102:3f55:b0:390:c753:3565 with SMTP id l21-20020a0561023f5500b00390c7533565mr909851vsv.13.1661626620967; Sat, 27 Aug 2022 11:57:00 -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 l124-20020a1ffe82000000b0037613541b27sm733728vki.39.2022.08.27.11.57.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Aug 2022 11:57:00 -0700 (PDT) From: Philip McGrath Date: Sat, 27 Aug 2022 14:55:50 -0400 Message-Id: <66d68c8973ac72a28424697187cc936ee941c6d4.1661626113.git.philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/chez.scm (racket-cs-native-supported-system): Change to return the applicable machine type instead of '#t'. (chez-scheme-for-racket)[native-inputs]: When cross-compiling, add 'this-package'. [arguments]<#:configure-flags>: When cross-compiling, supply '-m=' and '--toolprefix='. <#:phases>: Work around cross-compilation issues in 'build' and 'install-docs'. (chez-scheme-for-racket-bootstrap-bootfiles): When cross-compiling, use 'zuo' and 'chez-scheme-for-racket' instead of 'racket-vm-bc'. [arguments]<#:phases>: Adapt 'build' phase for cross-compilation. --- gnu/packages/chez.scm | 85 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index c87786c091..26f653ea9d 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -235,14 +235,15 @@ (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: @@ -453,8 +454,12 @@ (define-public chez-scheme-for-racket (replace "chez-scheme-bootstrap-bootfiles" chez-scheme-for-racket-bootstrap-bootfiles))) (native-inputs - (modify-inputs (package-native-inputs chez-scheme) - (prepend zuo))) + (let ((native-inputs (modify-inputs (package-native-inputs chez-scheme) + (prepend zuo)))) + (if (%current-target-system) + (modify-inputs native-inputs + (prepend this-package)) + native-inputs))) (arguments (substitute-keyword-arguments (package-arguments chez-scheme) ((#:out-of-source? _ #f) @@ -468,6 +473,15 @@ (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?))) + '()) + #$@(if (%current-target-system) + (list (string-append "--toolprefix=" + (%current-target-system) + "-")) + '()) ,@(let* ((chez+version (strip-store-file-name #$output)) (doc-prefix (assoc-ref %outputs "doc")) (doc-dir (string-append doc-prefix @@ -490,18 +504,42 @@ (define-public chez-scheme-for-racket #$mk-flags)) ((#:phases those-phases #~%standard-phases) #~(let* ((those-phases #$those-phases) - (unpack (assoc-ref those-phases 'unpack))) + (gnu:unpack (assoc-ref those-phases 'unpack)) + (gnu:build (assoc-ref those-phases 'build))) (modify-phases those-phases + (replace 'build + ;; need to override target for cross-compilation + ;; https://racket.discourse.group/t/950/19 + (lambda* (#:key target (make-flags '()) (parallel-build? #t) + #:allow-other-keys) + (gnu:build #:make-flags (if target + (cons "kernel" make-flags) + make-flags) + #:parallel-build? parallel-build?))) (replace 'install-docs - (lambda* (#:key make-flags #:allow-other-keys) + (lambda* (#:key native-inputs (make-flags '()) + #:allow-other-keys) + ;; The tests for 'native-inputs' are cross-compilation + ;; workarounds that would be better to address upstream: + ;; see . + (when native-inputs + (substitute* "Makefile" + (("install-docs: build \\$[(]ZUO[)]") + "install-docs: $(ZUO)"))) (apply invoke "make" "install-docs" - make-flags))) + (if native-inputs + (cons (string-append + "Scheme=" + (search-input-file native-inputs + "/bin/scheme")) + make-flags) + make-flags)))) (replace 'unpack (lambda args - (unpack #:source #$(or (package-source this-package) - (package-source racket-vm-bc))))) + (gnu:unpack #:source #$(or (package-source this-package) + (package-source racket-vm-bc))))) (add-after 'unpack 'chdir (lambda args (chdir "racket/src/ChezScheme")))))))) @@ -583,8 +621,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) @@ -604,9 +646,22 @@ (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")))))))) + #$(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") + #$(racket-cs-native-supported-system?))) + (else + ;; bootstrapping + #~(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)) (home-page "https://github.com/racket/ChezScheme")