From patchwork Mon Dec 9 22:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Kubisiak X-Patchwork-Id: 34717 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 A2C6927BBEA; Mon, 9 Dec 2024 22:17:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS autolearn=ham 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 B3BEA27BBE2 for ; Mon, 9 Dec 2024 22:17:37 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKm3u-00015L-5r; Mon, 09 Dec 2024 17:17:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKm3s-000156-EE for guix-patches@gnu.org; Mon, 09 Dec 2024 17:17:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKm3q-0006qL-IP for guix-patches@gnu.org; Mon, 09 Dec 2024 17:17:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:From:Date:To:Subject; bh=WrsHxaMkI5qLf7vRBnK2wE0FlgQgLbgikWoRa3hPlag=; b=uj5svh0ecO/Zsw7wO7lQeKbzW+dbBChRD8Pt7HQe0RpSz1hw5KvyFg5dGLkx5V3V25ScRsu67PZzEBdkUzCsYe5SGEYUM0Cflggk/6UufEjhiI7WtkE5z128WyP/7rbJqfBeqwkg2WpL5h4knKj4udR1b9RRpZa1inOMgudmbUeHl5m9hrCuji3cWr0+wnDHkCGSObNxNRdcnZfKiev7/0I1NIaeCCsWo+XTSc1D9GgmAvwtuqqTuQw6JEmQCDQlF6p4rveyryPpl6YB3UgrAgpus8pdGAHvJ+sS2FRb4WJhOg9carPwjLlvHq9Uf6ihwl/8z6/pe6PllSFXYAr+gA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tKm3q-0004kO-D6 for guix-patches@gnu.org; Mon, 09 Dec 2024 17:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74758] [PATCH] pack: Allow cross-compiling with '--relocatable'. Resent-From: Brian Kubisiak Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 09 Dec 2024 22:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74758 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74758@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173378257418155 (code B ref -1); Mon, 09 Dec 2024 22:17:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Dec 2024 22:16:14 +0000 Received: from localhost ([127.0.0.1]:56056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKm33-0004il-GQ for submit@debbugs.gnu.org; Mon, 09 Dec 2024 17:16:13 -0500 Received: from lists.gnu.org ([209.51.188.17]:45046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKm30-0004iY-Ki for submit@debbugs.gnu.org; Mon, 09 Dec 2024 17:16:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKm0s-0000F3-Rs for guix-patches@gnu.org; Mon, 09 Dec 2024 17:13:58 -0500 Received: from [75.171.110.13] (helo=mail.kubisiak.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKm0r-0006Q8-Ax for guix-patches@gnu.org; Mon, 09 Dec 2024 17:13:58 -0500 dkim-signature: v=1; a=rsa-sha256; d=kubisiak.com; s=s1; c=relaxed/relaxed; q=dns/txt; h=From:Subject:Date:Message-ID:To:MIME-Version:Content-Type; bh=7bxTQjKIQe4i043Mev73d2xcxhQCe8MzMt7H+SmVXV8=; b=QvRl3jhnQQickuj+i4RofxNcJWoGQJQbJGc+QxKsuEcJw0QFKg7QRC+JCQ/0cX7CwoJnQFuv04IqFeWXHA5y5HEjxCMwdwfN7E6RXNJHm6LhQMFu+He0m9rtCx6Bq2ttc3gDeD0Q3F/IbFeE361K8ZTIFgDVYZBbHMy2okptU46hsLnJ4psJhKtZObUravywm1gtc5smVj+Ldt8422xG8f5u2ILLv9Vd55/QaYgKa0xD+iK5Wnhnwam0SL wXg4YQn1pE1rIFPs3QLSuX2E/79lhm6SdEpZoMFQNMPHXRPPer5/v1RSB1R6E1ZHXeXBBvB92L+cSZzlOOVuC7J21/uA== Received: from peregrine (135-180-130-213.dsl.dynamic.sonic.net [135.180.130.213]) (envelope-sender ) by mail.kubisiak.com with ESMTPSA id for (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256) ; Mon, 9 Dec 2024 16:13:53 -0600 Date: Mon, 9 Dec 2024 14:13:51 -0800 From: Brian Kubisiak Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Host-Lookup-Failed: Reverse DNS lookup failed for 75.171.110.13 (failed) Received-SPF: pass client-ip=75.171.110.13; envelope-from=brian@kubisiak.com; helo=mail.kubisiak.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/pack.scm (c-compiler-compiler): Remove exception when cross-compiling and always build gexp->script for the host. [toolchain]: Use standard-cross-packages when cross-compiling. [search-paths]: Use package-search-paths instead of package-native-search-paths when cross-compiling. [run]: Use cc-for-target and strip-for-target. Change-Id: I5503e48b3394fdfee06999f8d1ad82f5f0d9af96 --- guix/scripts/pack.scm | 47 ++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) base-commit: 9001514e242ad15c190588439930b0fa4f6782e3 -- 2.46.0 diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 58cd55b129..d0e66c3013 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -1105,12 +1105,30 @@ (define-gexp-compiler (c-compiler-compiler (compiler ) system target "Lower COMPILER to a single script that does the right thing." (define toolchain (or (c-compiler-toolchain compiler) - (list (first (assoc-ref (standard-packages) "gcc")) - (first (assoc-ref (standard-packages) "ld-wrapper")) - (first (assoc-ref (standard-packages) "binutils")) - (first (assoc-ref (standard-packages) "libc")) - (gexp-input (first (assoc-ref (standard-packages) "libc")) - "static")))) + (if target + (let* ((cross-packages-host + (standard-cross-packages target 'host)) + (cross-packages-target + (standard-cross-packages target 'target)) + (xgcc + (first (assoc-ref cross-packages-host "cross-gcc")))) + (list xgcc + ;; ld-wrapper-cross isn't included with + ;; STANDARD-CROSS-PACKAGES, pull it from the inputs of + ;; cross-gcc instead + (first (assoc-ref (package-native-inputs xgcc) + "ld-wrapper-cross")) + (first (assoc-ref cross-packages-host "cross-binutils")) + (first (assoc-ref cross-packages-target "cross-libc")) + (gexp-input (first (assoc-ref cross-packages-target + "cross-libc:static")) + "static"))) + (list (first (assoc-ref (standard-packages) "gcc")) + (first (assoc-ref (standard-packages) "ld-wrapper")) + (first (assoc-ref (standard-packages) "binutils")) + (first (assoc-ref (standard-packages) "libc")) + (gexp-input (first (assoc-ref (standard-packages) "libc")) + "static"))))) (define inputs (match (append-map package-propagated-inputs @@ -1120,7 +1138,9 @@ (define-gexp-compiler (c-compiler-compiler (compiler ) system target (define search-paths (cons $PATH - (append-map package-native-search-paths + (append-map (if target + package-search-paths + package-native-search-paths) (filter package? inputs)))) (define run @@ -1144,17 +1164,12 @@ (define-gexp-compiler (c-compiler-compiler (compiler ) system target '#$inputs) (let ((output (output-file (command-line)))) - (apply invoke "gcc" (cdr (command-line))) - (invoke "strip" output))))) - - (when target - ;; TODO: Yep, we'll have to do it someday! - (leave (G_ "cross-compilation not implemented here; -please email '~a'~%") - (@ (guix config) %guix-bug-report-address))) + (apply invoke #$(cc-for-target target) (cdr (command-line))) + (invoke #$(strip-for-target target) output))))) (gexp->script "c-compiler" run - #:guile (c-compiler-guile compiler))) + #:guile (c-compiler-guile compiler) + #:target #f)) ;;;