guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: wip: Select rust package based on system.


From: guix-commits
Subject: 03/03: wip: Select rust package based on system.
Date: Fri, 3 Dec 2021 11:10:20 -0500 (EST)

apteryx pushed a commit to branch wip-cross-built-rust
in repository guix.

commit 113c4ce0cc9722cb8c0bc2c821d7f0d354d31533
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Wed Dec 1 00:02:59 2021 -0500

    wip: Select rust package based on system.
    
    ./pre-inst-env guix build rust-average --system=i686-linux -n
    
    Doesn't yet work:
    
       [...]
       /gnu/store/d85ywxk5vd1alw6nnk8b0qzpgl24fqbd-libgcrypt-1.8.8.drv
       /gnu/store/nhymliwh2p6k6lp7c3xh024djzppz6ij-libgpg-error-1.42.drv
       /gnu/store/jv6ln1nfdzf1g23ccwk873hcjax26fn4-libssh2-1.9.0.drv
       /gnu/store/nji50rgknidczy0qi8d9b7q5jmdsfmin-rust-1.54.0.drv
       /gnu/store/s17wnhihxy14nrghscgs8m9d64r4ymrp-rust-1.53.0.drv
       /gnu/store/ygx2vs72jivgx4mmvb1h6j7s0qfhsi80-rust-1.52.1.drv
       /gnu/store/5k4phk47am88kdggrp0hzgn1qmfzx86x-rust-1.51.0.drv
       /gnu/store/4641f3h64asmfnr5xpwd30jxgv4arpkn-rust-1.50.0.drv
       /gnu/store/jjd3q99jnb7zmj5irpkgx0qbgk4l9kbw-rust-1.49.0.drv
       /gnu/store/r3p3q16rcbxw6613jd479szlg0vw2hp2-rust-1.48.0.drv
       /gnu/store/ha85z3d334w7zc7l8vknmi2rbmpi28gs-rust-1.47.0.drv
       /gnu/store/wrmp3kfkx7ps9hxgzxbq068fz77wdzwz-rust-1.46.0.drv
       /gnu/store/0fk2kca9ldj3bd3q5fxgzd7l3xplrjl9-rust-1.45.2.drv
       /gnu/store/jkfpd4gp3frwmw5rji6g0gnbq76234ys-rust-1.44.1.drv
       /gnu/store/ag8a2m4241801ibnbkx8zy9f9c67sdz3-rust-1.43.0.drv
       /gnu/store/0c4w6sglqy7hdyyy306hsljcn2dmzd6w-rust-1.42.0.drv
       /gnu/store/1kzjik5253lwg1k96adlvilx51vb7701-rust-1.41.1.drv
       /gnu/store/brjdz6gf8ig52m38a4252b8x6nyl388k-rust-1.40.0.drv
       /gnu/store/jj5fhhjp65rcmdbpzjmidvg83q8k3cxn-rust-1.39.0.drv
       /gnu/store/qy49sw7mapmyys28xvdh3cgz73r23ws4-llvm-12.0.1.drv
       [...]
    
    The rust-i686-linux needs to be seen usable as a native i686-linux package.
    How to?
    
    Proposed solution: build rustc statically (non-trivial); make it a source
    tarball; use the source tarball as the input to a 'rust-i686-linux' package,
    which simply expands it (this package being explicitly marked with
    'supported-systems '("i686-linux")).
---
 gnu/packages/rust.scm       | 24 +++++++++++++++++++-----
 guix/build-system/cargo.scm |  7 +++++--
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 99107c5..0a9cb90 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -54,11 +54,13 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix memoization)
   #:use-module (guix packages)
   #:use-module ((guix build utils) #:select (alist-replace))
   #:use-module (guix utils)
   #:use-module (ice-9 match)
-  #:use-module (srfi srfi-26))
+  #:use-module (srfi srfi-26)
+  #:export (rust))
 
 ;; This is the hash for the empty file, and the reason it's relevant is not
 ;; the most obvious.
@@ -780,10 +782,22 @@ safety and thread safety guarantees.")
                             (package-native-inputs base-rust))))))
 
 ;;; Note: Only the latest versions of Rust are supported and tested.  The
-;;; intermediate rusts are built for bootstrapping purposes and should not
-;;; be relied upon.  This is to ease maintenance and reduce the time
-;;; required to build the full Rust bootstrap chain.
-(define-public rust rust-1.54)
+;;; intermediate rusts are built for bootstrapping purposes and should not be
+;;; relied upon.  This is to ease maintenance and reduce the time required to
+;;; build the full Rust bootstrap chain.
+(define-public rust-x86-64-linux rust-1.54)
+
+(define rust-for-system
+  (mlambda (system)
+    "Return a rust package that can be built for SYSTEM."
+    (if (string-prefix? "i686" system)
+        rust-i686-linux
+        rust-x86-64-linux)))
+
+(define-syntax rust
+  (identifier-syntax (rust-for-system
+                      (or (%current-target-system)
+                          (%current-system)))))
 
 ;;; Rust cross-built for i686-linux.
 ;;; TODO: Build statically.
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 60c35ee..036d792 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -58,8 +58,11 @@ to NAME and VERSION."
 (define (default-rust)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
-  (let ((rust (resolve-interface '(gnu packages rust))))
-    (module-ref rust 'rust)))
+  (let-system (system target)
+    (let ((rust (resolve-interface '(gnu packages rust))))
+      (if (string-prefix? "i686" (or target system))
+          (module-ref rust 'rust-i686-linux)
+          (module-ref rust 'rust-x86-64-linux)))))
 
 (define %cargo-utils-modules
   ;; Build-side modules imported by default.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]