Subject: [PATCH] gnu: rust: Update to 1.31.1
From: Ivan Petkov <[email-masked]>
To: [email-masked]
Cc: Danny Milosavljevic <[email-masked]>
Date: Wed, 27 Feb 2019 19:53:21 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/patches/rust-gdb-llvm.patch: new file
* gnu/packages/rust.scm (rust): Rename to...
(rust-1.29): ... this.
(rust-1.30): new variable
(rust): new variable
---
 gnu/local.mk                             |  1 +
 gnu/packages/patches/rust-gdb-llvm.patch | 89 ++++++++++++++++++++++++
 gnu/packages/rust.scm                    | 83 +++++++++++++++++++++-
 3 files changed, 172 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/rust-gdb-llvm.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 73472fdc50..c17dcc2f14 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1221,6 +1221,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/rust-1.25-accept-more-detailed-gdb-lines.patch \
   %D%/packages/patches/rust-bootstrap-stage0-test.patch		\
   %D%/packages/patches/rust-coresimd-doctest.patch		\
+  %D%/packages/patches/rust-gdb-llvm.patch			\
   %D%/packages/patches/rust-reproducible-builds.patch		 \
   %D%/packages/patches/rxvt-unicode-escape-sequences.patch	\
   %D%/packages/patches/scalapack-blacs-mpi-deprecations.patch	\
diff --git a/gnu/packages/patches/rust-gdb-llvm.patch b/gnu/packages/patches/rust-gdb-llvm.patch
new file mode 100644
index 0000000000..e8f0acc8b4
--- /dev/null
+++ b/gnu/packages/patches/rust-gdb-llvm.patch
@@ -0,0 +1,89 @@
+Tweak some gdb tests which were broken during LLVM upgrades.
+This has been subsequently fixed upstream in later rustc versions,
+but still needed to bootstrap some earlier versions of the compiler.
+
+diff -r -u rustc-1.30.1-src-orig/src/test/debuginfo/borrowed-c-style-enum.rs rustc-1.30.1-src/src/test/debuginfo/borrowed-c-style-enum.rs
+--- rustc-1.30.1-src-orig/src/test/debuginfo/borrowed-c-style-enum.rs	2019-02-04 12:49:34.055483896 -0800
++++ rustc-1.30.1-src/src/test/debuginfo/borrowed-c-style-enum.rs	2019-02-04 13:01:10.915950356 -0800
+@@ -18,15 +18,15 @@
+ 
+ // gdb-command:print *the_a_ref
+ // gdbg-check:$1 = TheA
+-// gdbr-check:$1 = borrowed_c_style_enum::ABC::TheA
++// gdbr-check:$1 = borrowed_c_style_enum::TheA
+ 
+ // gdb-command:print *the_b_ref
+ // gdbg-check:$2 = TheB
+-// gdbr-check:$2 = borrowed_c_style_enum::ABC::TheB
++// gdbr-check:$2 = borrowed_c_style_enum::TheB
+ 
+ // gdb-command:print *the_c_ref
+ // gdbg-check:$3 = TheC
+-// gdbr-check:$3 = borrowed_c_style_enum::ABC::TheC
++// gdbr-check:$3 = borrowed_c_style_enum::TheC
+ 
+ 
+ // === LLDB TESTS ==================================================================================
+diff -r -u rustc-1.30.1-src-orig/src/test/debuginfo/c-style-enum-in-composite.rs rustc-1.30.1-src/src/test/debuginfo/c-style-enum-in-composite.rs
+--- rustc-1.30.1-src-orig/src/test/debuginfo/c-style-enum-in-composite.rs	2019-02-04 12:49:34.051483727 -0800
++++ rustc-1.30.1-src/src/test/debuginfo/c-style-enum-in-composite.rs	2019-02-04 13:02:00.981997525 -0800
+@@ -19,31 +19,31 @@
+ 
+ // gdb-command:print tuple_interior_padding
+ // gdbg-check:$1 = {__0 = 0, __1 = OneHundred}
+-// gdbr-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
++// gdbr-check:$1 = (0, c_style_enum_in_composite::OneHundred)
+ 
+ // gdb-command:print tuple_padding_at_end
+ // gdbg-check:$2 = {__0 = {__0 = 1, __1 = OneThousand}, __1 = 2}
+-// gdbr-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
++// gdbr-check:$2 = ((1, c_style_enum_in_composite::OneThousand), 2)
+ 
+ // gdb-command:print tuple_different_enums
+ // gdbg-check:$3 = {__0 = OneThousand, __1 = MountainView, __2 = OneMillion, __3 = Vienna}
+-// gdbr-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna)
++// gdbr-check:$3 = (c_style_enum_in_composite::OneThousand, c_style_enum_in_composite::MountainView, c_style_enum_in_composite::OneMillion, c_style_enum_in_composite::Vienna)
+ 
+ // gdb-command:print padded_struct
+ // gdbg-check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
+-// gdbr-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5}
++// gdbr-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::OneMillion, c: 4, d: c_style_enum_in_composite::Toronto, e: 5}
+ 
+ // gdb-command:print packed_struct
+ // gdbg-check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
+-// gdbr-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8}
++// gdbr-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::OneHundred, c: 7, d: c_style_enum_in_composite::Vienna, e: 8}
+ 
+ // gdb-command:print non_padded_struct
+ // gdbg-check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
+-// gdbr-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto}
++// gdbr-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::OneMillion, b: c_style_enum_in_composite::MountainView, c: c_style_enum_in_composite::OneThousand, d: c_style_enum_in_composite::Toronto}
+ 
+ // gdb-command:print struct_with_drop
+ // gdbg-check:$7 = {__0 = {a = OneHundred, b = Vienna}, __1 = 9}
+-// gdbr-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9)
++// gdbr-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::OneHundred, b: c_style_enum_in_composite::Vienna}, 9)
+ 
+ // === LLDB TESTS ==================================================================================
+ 
+diff -r -u rustc-1.30.1-src-orig/src/test/debuginfo/gdb-pretty-struct-and-enums-pre-gdb-7-7.rs rustc-1.30.1-src/src/test/debuginfo/gdb-pretty-struct-and-enums-pre-gdb-7-7.rs
+--- rustc-1.30.1-src-orig/src/test/debuginfo/gdb-pretty-struct-and-enums-pre-gdb-7-7.rs	2019-02-04 12:49:34.043483393 -0800
++++ rustc-1.30.1-src/src/test/debuginfo/gdb-pretty-struct-and-enums-pre-gdb-7-7.rs	2019-02-04 13:02:17.954691634 -0800
+@@ -27,15 +27,15 @@
+ 
+ // gdb-command: print c_style_enum1
+ // gdbg-check:$3 = CStyleEnumVar1
+-// gdbr-check:$3 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnum::CStyleEnumVar1
++// gdbr-check:$3 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnumVar1
+ 
+ // gdb-command: print c_style_enum2
+ // gdbg-check:$4 = CStyleEnumVar2
+-// gdbr-check:$4 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnum::CStyleEnumVar2
++// gdbr-check:$4 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnumVar2
+ 
+ // gdb-command: print c_style_enum3
+ // gdbg-check:$5 = CStyleEnumVar3
+-// gdbr-check:$5 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnum::CStyleEnumVar3
++// gdbr-check:$5 = gdb_pretty_struct_and_enums_pre_gdb_7_7::CStyleEnumVar3
+ 
+ #![allow(dead_code, unused_variables)]
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 111f74e4ec..dc8600a5e4 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -783,7 +783,7 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
              ;; The thinlto test should pass with llvm 6.
              (delete 'disable-thinlto-test))))))))
 
-(define-public rust
+(define-public rust-1.29
   (let ((base-rust
          (rust-bootstrapped-package rust-1.28 "1.29.2"
                                     "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h"
@@ -792,3 +792,84 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
                                       "rust-reproducible-builds.patch"))))
     (package
       (inherit base-rust))))
+
+(define-public rust-1.30
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.29 "1.30.1"
+                                    "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn"
+                                    #:patches
+                                    '("rust-1.25-accept-more-detailed-gdb-lines.patch"
+                                      "rust-gdb-llvm.patch"
+                                      "rust-reproducible-builds.patch"))))
+    (package
+      (inherit base-rust)
+      (inputs
+       ;; Use LLVM 7.0
+       (alist-replace "llvm" (list llvm)
+                      (package-inputs base-rust)))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base-rust)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'patch-cargo-tests 'patch-cargo-env-shebang
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((coreutils (assoc-ref inputs "coreutils")))
+                   (substitute* "src/tools/cargo/tests/testsuite/fix.rs"
+                     ;; Cargo has a test which explicitly sets a
+                     ;; RUSTC_WRAPPER environment variable which points
+                     ;; to /usr/bin/env. Since it's not a shebang, it
+                     ;; needs to be manually patched
+                     (("\"/usr/bin/env\"")
+                      (string-append "\"" coreutils "/bin/env\"")))
+                   #t)))
+             (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
+               (lambda* _
+                 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
+                   ;; These tests largely check that cargo outputs warning/error
+                   ;; messages as expected. It seems that cargo outputs an
+                   ;; absolute path to something in the store instead of the
+                   ;; expected relative path (e.g. `[..]`) so we'll ignore
+                   ;; these for now
+                   (("fn include") "#[ignore]\nfn include")
+                   (("fn exclude") "#[ignore]\nfn exclude"))
+                   #t))
+             ;; Appears that this test isn't currently running and has been
+             ;; moved elsewhere, so the patch doesn't apply.
+             (delete 'disable-amd64-avx-test))))))))
+
+(define-public rust
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.30 "1.31.1"
+                                    "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli"
+                                    #:patches
+                                    '("rust-1.25-accept-more-detailed-gdb-lines.patch"
+                                      "rust-gdb-llvm.patch"
+                                      "rust-reproducible-builds.patch"))))
+    (package
+      (inherit base-rust)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base-rust)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'patch-tests 'patch-command-exec-tests
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((coreutils (assoc-ref inputs "coreutils")))
+                   (substitute* "src/test/run-pass/command-exec.rs"
+                     ;; This test suite includes some tests that the stdlib's
+                     ;; `Command` execution properly handles situations where
+                     ;; the environment or PATH variable are empty, but this
+                     ;; fails since we don't have `echo` available in the usual
+                     ;; Linux directories.
+                     ;; NB: the leading space is so we don't fail a tidy check
+                     ;; for trailing whitespace, and the newlines are to ensure
+                     ;; we don't exceed the 100 chars tidy check as well
+                     ((" Command::new\\(\"echo\"\\)")
+                      (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n")))
+                   #t)))
+             (add-after 'patch-tests 'patch-process-docs-rev-cmd
+               (lambda* _
+                 ;; Disable some doc tests which depend on the "rev" command
+                 ;; https://github.com/rust-lang/rust/pull/58746
+                 (substitute* "src/libstd/process.rs"
+                   (("```rust") "```rust,no_run"))
+                 #t)))))))))
-- 
2.20.1