Subject: [PATCH] gnu: Add Rust 1.48.

From: Matthew Kraai <[email-masked]>
Date: Mon, 7 Dec 2020 14:47:39 -0800

* gnu/packages/rust.scm (rust-1.48): New variable.
---
 .../patches/rust-1.48-linker-locale.patch     | 14 +++++++++
 gnu/packages/rust.scm                         | 29 +++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 gnu/packages/patches/rust-1.48-linker-locale.patch

diff --git a/gnu/packages/patches/rust-1.48-linker-locale.patch b/gnu/packages/patches/rust-1.48-linker-locale.patch
new file mode 100644
index 0000000000..d06dcbe682
--- /dev/null
+++ b/gnu/packages/patches/rust-1.48-linker-locale.patch
@@ -0,0 +1,14 @@
+https://github.com/rust-lang/rust/pull/74416
+diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
+index 3df956c465e..f45fee45be4 100644
+--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
++++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
+@@ -28,7 +28,7 @@
+ pub fn disable_localization(linker: &mut Command) {
+     // No harm in setting both env vars simultaneously.
+     // Unix-style linkers.
+-    linker.env("LC_ALL", "C");
++    linker.env("LC_ALL", "en_US.UTF-8");
+     // MSVC's `link.exe`.
+     linker.env("VSLANG", "1033");
+ }
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 1a79927c45..714d04ba14 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1358,5 +1358,34 @@ move around."
                  (generate-all-checksums "vendor")
                  #t)))))))))
 
+(define-public rust-1.48
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.47 "1.48.0"
+           "0fz4gbb5hp5qalrl9lcl8yw4kk7ai7wx511jb28nypbxninkwxhf")))
+    (package
+      (inherit base-rust)
+      (source
+        (origin
+          (inherit (package-source base-rust))
+          (patches (search-patches "rust-1.48-linker-locale.patch"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base-rust)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (replace 'patch-tests
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((bash (assoc-ref inputs "bash")))
+                   (substitute* "library/std/src/process/tests.rs"
+                     ;; The newline is intentional.
+                     ;; There's a line length "tidy" check in Rust which would
+                     ;; fail otherwise.
+                     (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
+                   ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
+                   (substitute* "library/std/src/sys/unix/process/process_common/tests.rs"
+                     (("fn test_process_mask") "#[allow(unused_attributes)]
+    #[ignore]
+    fn test_process_mask"))
+                   #t))))))))))
+
 ;; TODO(staging): Bump this variable to the latest packaged rust.
 (define-public rust rust-1.45)
-- 
2.29.2