From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uKVuGsHj9GIidQAAbAwnHQ (envelope-from ) for ; Thu, 11 Aug 2022 13:10:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id kLNRGsHj9GKitwAAauVa8A (envelope-from ) for ; Thu, 11 Aug 2022 13:10:57 +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 265A43DEC9 for ; Thu, 11 Aug 2022 13:10:57 +0200 (CEST) Received: from localhost ([::1]:57510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM65Y-0001LE-AF for larch@yhetil.org; Thu, 11 Aug 2022 07:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM64i-0000fw-Jv for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM64i-0005Pw-8t for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oM64i-0006Yn-4Z for guix-patches@gnu.org; Thu, 11 Aug 2022 07:10:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57050] [PATCH v2 07/13] 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, 11 Aug 2022 11:10:04 +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.166021615725046 (code B ref 57050); Thu, 11 Aug 2022 11:10:04 +0000 Received: (at 57050) by debbugs.gnu.org; 11 Aug 2022 11:09:17 +0000 Received: from localhost ([127.0.0.1]:51835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oM63x-0006Vt-8u for submit@debbugs.gnu.org; Thu, 11 Aug 2022 07:09:17 -0400 Received: from mail-qk1-f170.google.com ([209.85.222.170]:45983) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oM63q-0006UA-Hd for 57050@debbugs.gnu.org; Thu, 11 Aug 2022 07:09:11 -0400 Received: by mail-qk1-f170.google.com with SMTP id b2so455707qkh.12 for <57050@debbugs.gnu.org>; Thu, 11 Aug 2022 04:09:10 -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=HxhcUY+za+mNFpnCVDuQEKAH0aEVOhBTm4Rup5xFZAs=; b=elaofE0KfGyWS2UrVApjRQOoijzfAyFQWO/j+PPy/giBVcpwn81njhv3iTUkdj41Un DRqix2jZh24qul5DhgtjW79whxBCNSgmH36TDNBbdC/GwBRlDyW0mHKFgtOHNEb3bOhs C4P8apaAGc4FhJAvWHANM5VWpyoHde505uhq+N9YgmuqpLYFjI59f4Q/Dj6ljY6M90aj a9Zm/xSk3IuWCua+RMhMf70fX8qUFNLAHGEKGTpm7upJFvfhsJ92rYT4eZ4ed0sqxofa 4/zSdaKEOK156o3i0pc0Vh/GVKqtXz2rw18M1UdkT203iEuRsPtgNC+TO0FuYoKc3us3 jGWw== 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=HxhcUY+za+mNFpnCVDuQEKAH0aEVOhBTm4Rup5xFZAs=; b=C1A+h1tZGtD3gEl0x+DhjJMXvK8cxqj4JpfHnuuwmurc5Yqj0i4VzYxRJxgsx73rji YHbdok5QQ2QZXzr2z5aAvshTXCEcXoJoex3bQ5UNcy9B/AYDq6P0C00tZ1Z5LNM7sa1B VDkMgqtCAnoBVze8sqp5ebf/w3sexgtlNrdwshj+ELk7JpCEtGqWYgkhL6pyDmUrvPCX kZyHjjbp6RqIo1go7Nhcx6AVAfMHzYM4Iwz0f92c7/nLNhaJEKGRU/Fbvut1HVSao+Xj aC+8Z25UskMVTETobuuuzXkRzpDIME47ZeamwFHn2+jVdhdgiqqfudY0InMosnQ75ugN aqGQ== X-Gm-Message-State: ACgBeo3cvoomJVeSU2hsqjdKVVOwHSAfpkCYhW2cakXr+zh8QMIPKhtz DN6X1GU394GIt7RqFwCuArC5aO/U44BgizE1 X-Google-Smtp-Source: AA6agR6JP8y6PUP2QeZsMgYom0TNGfmcfYsv2r1YeOLT4rL7c99+vHWb0RFdkuFlHzjaNFRVV8+nfw== X-Received: by 2002:a05:620a:4411:b0:6b9:aded:c992 with SMTP id v17-20020a05620a441100b006b9adedc992mr4329312qkp.107.1660216150112; Thu, 11 Aug 2022 04:09:10 -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 v17-20020a05620a441100b006b5e5ebfff8sm1696670qkp.62.2022.08.11.04.09.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Aug 2022 04:09:09 -0700 (PDT) From: Philip McGrath Date: Thu, 11 Aug 2022 07:08:17 -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=1660216257; 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=HxhcUY+za+mNFpnCVDuQEKAH0aEVOhBTm4Rup5xFZAs=; b=jQ7m2GT330nfFRr4tvRtjZE231L4KMlYsV99KkUbgouQeP1qrXJAmeLnEoacP7FuPjqGdL FslqRjXEeQ1hWhdzrNEway7QVyFf/wJ6afAPSiBJW8zDfcYIppUOvIuleVZJ10JkuLnY9A O8OTtGQJGFNbAztZPgHdxdBajBm3X+5D+DXvT8AJSq0ZHL1kBBAL8J5Mt9nU3TvQIISdkH Iu15FbnL6B3CbNcMy/0kqZeCMmW+q2+zPp5dB6ASuIbdU2WlwcHmIyWXFMOUqCiMu2h3kp TLrm4XqRd3ynQ6x3k0j6MgXhNCSQFuCD5hmqwf/vjPQ4PsRqQ0HcmWCYgW/1xw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660216257; a=rsa-sha256; cv=none; b=m0/5kmqOMYFhtJdlmGIH7eBq96Q9kAd3RF36MMnAalJHVqrAeZKqbksp2Wou2xl3qUPaDx dWWUYLOa5uOMvFYDb6+gIbkAAi+M5kYtZGfz7FoM/wPb5vInKu8BsJ6Du8oMXWJ5lVNOPs qnRTwYF5xy4SY5rmKfigU4Zf1js/J7jbSf2hNngP1pDzzHyInkE8EZSnYXF82gQiMPYE4+ Mvbntc3FHATjazopjZ51NJV/3ebtse29RGBfgnBkiiuFdeDZdIS8+qk8pB7JdF2KKO8ESA c4q2ibZII5qKyEWFj0vQcon37TdbWqEbphzIORLQMUIlOrDJp9XfI7pFCD0enA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=elaofE0K; 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.62 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=elaofE0K; 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: 265A43DEC9 X-Spam-Score: 5.62 X-Migadu-Scanner: scn1.migadu.com X-TUID: DKlkYCYFnzsC * 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 294edca1a4..be9884b3d2 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -236,14 +236,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: @@ -457,8 +458,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) - (append zuo))) + (let ((native-inputs (modify-inputs (package-native-inputs chez-scheme) + (append zuo)))) + (if (%current-target-system) + (modify-inputs native-inputs + (append this-package)) + native-inputs))) (arguments (substitute-keyword-arguments (package-arguments chez-scheme) ((#:out-of-source? _ #f) @@ -472,6 +477,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 @@ -494,18 +508,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")))))))) @@ -587,8 +625,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,9 +650,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