summaryrefslogtreecommitdiff
path: root/gnu/packages/rust.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-12-17 17:09:31 +0200
committerEfraim Flashner <efraim@flashner.co.il>2024-02-20 13:56:20 +0200
commit3a076fc06e146c088708046d92d6f07296207939 (patch)
tree534f3053bf82de2dc5bd7ec91aa95f757556756c /gnu/packages/rust.scm
parent4bf325381f76d8388944df2d81b08e52f1cb33f7 (diff)
downloadguix-patches-3a076fc06e146c088708046d92d6f07296207939.tar
guix-patches-3a076fc06e146c088708046d92d6f07296207939.tar.gz
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
Diffstat (limited to 'gnu/packages/rust.scm')
-rw-r--r--gnu/packages/rust.scm48
1 files changed, 20 insertions, 28 deletions
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 64ce9b77a2..df3cb112d1 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -64,6 +64,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)
@@ -101,21 +102,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"))
@@ -216,8 +202,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))
@@ -354,10 +342,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
@@ -481,7 +471,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++" "\"
@@ -502,9 +492,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.
@@ -1187,7 +1179,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\"
@@ -1196,14 +1188,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 "\"