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 SDGwHMQ5B2MwAgAAbAwnHQ (envelope-from ) for ; Thu, 25 Aug 2022 10:58:44 +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 YJK0HMQ5B2ME1wAA9RJhRA (envelope-from ) for ; Thu, 25 Aug 2022 10:58:44 +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 11B741D55E for ; Thu, 25 Aug 2022 10:58:43 +0200 (CEST) Received: from localhost ([::1]:38834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oR8hG-0003fG-Qk for larch@yhetil.org; Thu, 25 Aug 2022 04:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oR8fg-00025a-6k for guix-patches@gnu.org; Thu, 25 Aug 2022 04:57:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oR8ff-0003CZ-TA for guix-patches@gnu.org; Thu, 25 Aug 2022 04:57:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oR8fe-0002cN-Pc for guix-patches@gnu.org; Thu, 25 Aug 2022 04:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57050] [PATCH v3 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: Thu, 25 Aug 2022 08:57:02 +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.16614177929982 (code B ref 57050); Thu, 25 Aug 2022 08:57:02 +0000 Received: (at 57050) by debbugs.gnu.org; 25 Aug 2022 08:56:32 +0000 Received: from localhost ([127.0.0.1]:48897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR8ey-0002ac-Gv for submit@debbugs.gnu.org; Thu, 25 Aug 2022 04:56:31 -0400 Received: from mail-vs1-f47.google.com ([209.85.217.47]:39808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR8eY-0002WK-Jj for 57050@debbugs.gnu.org; Thu, 25 Aug 2022 04:55:55 -0400 Received: by mail-vs1-f47.google.com with SMTP id c3so20187368vsc.6 for <57050@debbugs.gnu.org>; Thu, 25 Aug 2022 01:55:54 -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=TuFID0IIJ2v+TUorPD9gEOXmf1iru3OlaoabwCuatXyGJoKt8lFw+eYnnSsOJuFTBN lzBSi1jfofeLaebt73zxMIK4ZZKA7zGJqj2IN8Iki+pCuD57Pnsrl3RzicAIxF2oEwH1 1/ZgEVB25I3Gj8If5GlMnmjc6VujkJE/c7PhnqYeyafRgQbEZ+dRpQtPQZWNmLozHcci stznldaf0xAN0TZ1DqLagLh0bKF2fTBC2FZRqbjCsknkV5xSQDr27sdFD4WjdLaW62D8 gvtxufiZLyZ2DtzD+57kgk9kLxiSTF7zjUoGNkrU0i60rQep/HfPoLfqlGYgCfaqmY71 0VmA== 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=6yLGPKSxWAPGTVCEg2X8eL2FN0/XZIDNRbSJj8/mYuxIh+TpeXqZVZpjuuKYi1J6x1 iu262tKMh2RR/a4YD1apzUrHhA51jW6cJ/FDNq1mo2tefKx6AVZbeYyqRo9g8RfmUinc AFxUp7YdjPcD0UEbNPdgRNOS2M7guFKlTO3PwXkVqY6mqjbc4R9wgxIdGTJO8ab1PtLs Mp19JMrcjr3ve73m9G2zdWumKx5aS4x7AeH5kzDgLbtJIPA++7iqoqHKJ4YH6OgrOIyl nbWRlodb0F8EnIm23/vBd2DUgJt7vQtIDRrNV4t1b3LvlPFLwRwrs6Qi4uKIUbGhsqW6 KORA== X-Gm-Message-State: ACgBeo3G83ERVE8maStpfynhP8QDaMTWgkHP9wRiGaHG5aHny4aJuVz0 i3VFfg3y/HeZ8T8vK7cN7LzM6G6EQ4MfRQ4f X-Google-Smtp-Source: AA6agR5DtuAv0AxZLu0kDkeEEG3/3Vc2LU6pxmnTHPSp34bn6ZWqaL66GCzMUNLP8TXPOv1GWwf1MQ== X-Received: by 2002:a67:fb82:0:b0:390:8bb4:69c7 with SMTP id n2-20020a67fb82000000b003908bb469c7mr1058178vsr.33.1661417754168; Thu, 25 Aug 2022 01:55:54 -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 v12-20020a67ff8c000000b0038712af0dbesm13917365vsq.22.2022.08.25.01.55.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 01:55:53 -0700 (PDT) From: Philip McGrath Date: Thu, 25 Aug 2022 04:54:12 -0400 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 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=1661417924; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=ooUpIt6v6GE6eFoJemQYYCCp1VZ+cCUGyFCLbJm82Ag=; b=h5B+8RlnsgQ2FWGrTXkqLNV/bylLeMGJxAXzbedJW1kzrGN/VuuMMGbJ/Z0vvB9E/F9nOa oDwPrjHO73nW/nOSlqGg4CBM3wSLj7dzJzVGQrOcN3kdmCpcx1GsMy8A/cHsKzcbR+hRQQ bmY/MPcSayzulqp6CQCpPuX2ZkQikJZCaAkMiTpHSnsbanCzz7hPxfSlfktEUb6wgpGqa4 T5sc9SpG/juChB9BE2tb7l+y9GxXbCKH9Dmw80ltZXbv2y/K+owNd0/wd0fXlLerHpx06Y MDoweR2Djlc8i5RQ+QwY1EqFAtXoHAZPZQEziGfmPBByWtNH6KDapM3zib4LiQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661417924; a=rsa-sha256; cv=none; b=FAZYZXCP8Kd2n2u/p1cITlAJrNUK/e3zDplGrU1Go1lm5ZO3s6YaR5X+WMgpoCQURkgN+Z q1XXcSUo8o+KRp+EY6bovH8usAjdk9SsJjaNXZxAQtK4wyMSm1sknJ5kJRdLD5paDWnU2g rKHpzBSWw4jF2bVn4foWAfLkHRPIx2H4taonTNIXvli4sYE8c1e6bdLsxgM9WhBr3B6ZGv vOk1o3QOpAnzthdt6kzTXDhM2LfND3y4mXhuScUqnLCzzR1OmGXGUquEzK0lyaD3cuMu7i t7NuDWnbUmhL3tCMnoOETc3XrSxbRlHwMYxc48e5Aq/1cb7nQU7F5C7KU5Kh4g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=TuFID0II; 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: 4.19 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=TuFID0II; 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: 11B741D55E X-Spam-Score: 4.19 X-Migadu-Scanner: scn0.migadu.com X-TUID: Tn49hLe8sbSI * 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") -- 2.32.0