guix-commits
[Top][All Lists]
Advanced

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

03/137: gnu: rust: Use platform-rust-target.


From: guix-commits
Subject: 03/137: gnu: rust: Use platform-rust-target.
Date: Thu, 21 Dec 2023 04:25:55 -0500 (EST)

efraim pushed a commit to branch rust-team
in repository guix.

commit 7a20ef72b38bf905344e287267261f8d40b84ae7
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Sun Dec 17 17:09:31 2023 +0200

    gnu: rust: Use platform-rust-target.
    
    * gnu/packages/rust.scm (nix-system->gnu-triplet-for-rust): Remove
    procedure.
    (rust-bootstrap)[arguments]: Adjust make-flags, custom 'install phase
    to use platform-rust-target.
    (rust-1.55)[arguments]: Adjust custom 'configure and 'install phases to
    use platform-rust-target.
    (make-rust-sysroot)[arguments]: Adjust custom 'configure phase to use
    platform-rust-target.
    
    Change-Id: I102d44231c1411ea14ca75170f4884304d11bee1
---
 gnu/packages/rust.scm | 48 ++++++++++++++++++++----------------------------
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index e3a7944d9b..f80b7489cd 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -63,6 +63,7 @@
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
+  #:use-module (guix platform)
   #:use-module ((guix build utils) #:select (alist-replace))
   #:use-module (guix utils)
   #:use-module (guix gexp)
@@ -99,21 +100,6 @@
 (define %cargo-reference-hash
   "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
 
-(define* (nix-system->gnu-triplet-for-rust
-          #:optional (system (%current-system)))
-  (match system
-    ("x86_64-linux"   "x86_64-unknown-linux-gnu")
-    ("i686-linux"     "i686-unknown-linux-gnu")
-    ("armhf-linux"    "armv7-unknown-linux-gnueabihf")
-    ("aarch64-linux"  "aarch64-unknown-linux-gnu")
-    ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
-    ("riscv64-linux"  "riscv64gc-unknown-linux-gnu")
-    ("i586-gnu" "i686-unknown-hurd-gnu")
-    ("i686-gnu" "i686-unknown-hurd-gnu")
-    ("i686-mingw" "i686-pc-windows-gnu")
-    ("x86_64-mingw" "x86_64-pc-windows-gnu")
-    (_                (nix-system->gnu-triplet system))))
-
 (define* (rust-uri version #:key (dist "static"))
   (string-append "https://"; dist ".rust-lang.org/dist/"
                  "rustc-" version "-src.tar.gz"))
@@ -213,8 +199,10 @@
        #:parallel-build? ,(target-x86-64?)
        #:make-flags
        (list ,(string-append "RUSTC_TARGET="
-                             (or (%current-target-system)
-                                 (nix-system->gnu-triplet-for-rust)))
+                             (platform-rust-target
+                               (lookup-platform-by-target-or-system
+                                 (or (%current-target-system)
+                                     (%current-system)))))
              ,(string-append "RUSTC_VERSION=" version)
              ,(string-append "MRUSTC_TARGET_VER="
                              (version-major+minor version))
@@ -351,10 +339,12 @@
                     (rustc (string-append bin "/rustc"))
                     (cargo-bin (string-append cargo "/bin"))
                     (lib (string-append out "/lib"))
-                    (gnu-triplet ,(or (%current-target-system)
-                                      (nix-system->gnu-triplet-for-rust)))
-                    (system-lib-prefix (string-append lib "/rustlib/"
-                                                      gnu-triplet "/lib")))
+                    (system-lib-prefix
+                      (string-append lib "/rustlib/"
+                                     ,(platform-rust-target
+                                        (lookup-platform-by-target-or-system
+                                          (or (%current-target-system)
+                                              (%current-system)))) "/lib")))
                (mkdir-p (dirname rustc))
                (copy-file "run_rustc/output/prefix/bin/rustc_binary" rustc)
                (wrap-program rustc
@@ -477,7 +467,7 @@ jemalloc=true
 default-linker = \"" gcc "/bin/gcc" "\"
 channel = \"stable\"
 rpath = true
-[target." ,(nix-system->gnu-triplet-for-rust) "]
+[target." ,(platform-rust-target (lookup-platform-by-system 
(%current-system))) "]
 llvm-config = \"" llvm "/bin/llvm-config" "\"
 cc = \"" gcc "/bin/gcc" "\"
 cxx = \"" gcc "/bin/g++" "\"
@@ -498,9 +488,11 @@ ar = \"" binutils "/bin/ar" "\"
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
                     (cargo-out (assoc-ref outputs "cargo"))
-                    (gnu-triplet ,(or (%current-target-system)
-                                      (nix-system->gnu-triplet-for-rust)))
-                    (build (string-append "build/" gnu-triplet)))
+                    (build (string-append "build/"
+                                          ,(platform-rust-target
+                                             
(lookup-platform-by-target-or-system
+                                               (or (%current-target-system)
+                                                   (%current-system)))))))
                ;; Manually do the installation instead of calling './x.py
                ;; install', as that is slow and needlessly rebuilds some
                ;; things.
@@ -1179,7 +1171,7 @@ docs = false
 python = \"" (which "python") "\"
 vendor = true
 submodules = false
-target = [\"" ,(nix-system->gnu-triplet-for-rust (gnu-triplet->nix-system 
target)) "\"]
+target = [\"" ,(platform-rust-target (lookup-platform-by-target target)) "\"]
 [install]
 prefix = \"" out "\"
 sysconfdir = \"etc\"
@@ -1188,14 +1180,14 @@ debug = false
 jemalloc = false
 default-linker = \"" target-cc "\"
 channel = \"stable\"
-[target." ,(nix-system->gnu-triplet-for-rust) "]
+[target." ,(platform-rust-target (lookup-platform-by-system 
(%current-system))) "]
 # These are all native tools
 llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
 linker = \"" (which "gcc") "\"
 cc = \"" (which "gcc") "\"
 cxx = \"" (which "g++") "\"
 ar = \"" (which "ar") "\"
-[target." ,(nix-system->gnu-triplet-for-rust (gnu-triplet->nix-system target)) 
"]
+[target." ,(platform-rust-target (lookup-platform-by-target target)) "]
 llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
 linker = \"" target-cc "\"
 cc = \"" target-cc "\"



reply via email to

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