GNU bug report logs - #77093
[PATCH rust-team 00/18] New Rust packaging workflow based on lockfile importer.

Previous Next

Package: guix-patches;

Reported by: Hilton Chain <hako <at> ultrarare.space>

Date: Tue, 18 Mar 2025 07:18:02 UTC

Severity: normal

Tags: patch

Full log


Message #329 received at 77093 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77093 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v4 rust-team 20/22] build/cargo: Accept rust-sysroot from
 native-inputs.
Date: Tue, 29 Apr 2025 00:23:17 +0800
This is a workaround to support Rust cross-compilation in build systems other
than cargo-build-system.  Since there's no interface for target-inputs, using
native-inputs makes most sense.

* guix/build-system/cargo.scm (lower)[bag]<target-inputs>: Label rust-sysroot
with its package name.
* guix/build/cargo-build-system.scm (configure): Use it.
When cross-compiling, accept rust-sysroot from native-inputs if there's none
in inputs.

Change-Id: I5cb63c8c815d3a2c9f0ece01857254f6d0090dd1
---
 guix/build-system/cargo.scm       |  3 ++-
 guix/build/cargo-build-system.scm | 15 +++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 045809874c..d2d9a075b9 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -430,7 +430,8 @@ (define* (lower name
 
                      ;; This provides a separate sysroot for the regular rustc
                      ,@(if target
-                         `(("rust-sysroot" ,(rust-sysroot target)))
+                         `((,(string-append "rust-sysroot-for-" target)
+                            ,(rust-sysroot target)))
                          '())))
     (outputs outputs)
     (build (if target cargo-cross-build cargo-build))
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index edc4e0d836..45b17df6ff 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -156,7 +156,7 @@ (define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
          (format #t "error: Possible pre-generated file found: ~a~%" file)))
      (find-files "." (negate empty-file?)))))
 
-(define* (configure #:key source inputs
+(define* (configure #:key source inputs native-inputs
                     target system
                     (cargo-target #f)
                     (vendor-dir "guix-vendor")
@@ -193,9 +193,16 @@ (define* (configure #:key source inputs
   ;; For cross-building
   (when target
     (setenv "CARGO_BUILD_TARGET" cargo-target)
-    (setenv "RUSTFLAGS" (string-append
-                          (or (getenv "RUSTFLAGS") "")
-                          " --sysroot " (assoc-ref inputs "rust-sysroot")))
+    (setenv "RUSTFLAGS"
+            (string-append
+             (or (getenv "RUSTFLAGS") "")
+             " --sysroot "
+             (assoc-ref
+              (append inputs
+                      ;; Workaround for other build systems, as no interface
+                      ;; is available for target-inputs.
+                      (or native-inputs '()))
+              (string-append "rust-sysroot-for-" target))))
 
     (setenv "PKG_CONFIG" (string-append target "-pkg-config"))
 
-- 
2.49.0





This bug report was last modified 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.