Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [WIP] rust: update to 1.36.0
@ 2019-07-06 16:19 voidlinux-github
  2019-07-06 16:20 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 16:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

There is a new pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 76518 bytes --]

From d3eb0d7848898720a028c82e6ec75d09ec2a63c9 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes
---
 ...-Don-t-pass-CFLAGS-to-the-C-compiler.patch |  26 ++
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 srcpkgs/rust/patches/0040-rls-atomics.patch   |  58 +++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 352 +++++++++-------
 23 files changed, 1167 insertions(+), 308 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 create mode 100644 srcpkgs/rust/patches/0040-rls-atomics.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
new file mode 100644
index 00000000000..fc3d3c10945
--- /dev/null
+++ b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
@@ -0,0 +1,26 @@
+From aa432f281344baa87c69add2229dd8d81acee967 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Wed, 10 Jan 2018 13:36:41 -0600
+Subject: [PATCH 01/12] Don't pass CFLAGS to the C++ compiler
+
+---
+ src/bootstrap/builder.rs | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
+index 51663e931..af4b47192 100644
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -1116,8 +1116,7 @@ impl<'a> Builder<'a> {
+             if let Ok(cxx) = self.cxx(target) {
+                 let cxx = ccacheify(&cxx);
+                 cargo
+-                    .env(format!("CXX_{}", target), &cxx)
+-                    .env(format!("CXXFLAGS_{}", target), cflags);
++                    .env(format!("CXX_{}", target), &cxx);
+             }
+         }
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/0040-rls-atomics.patch b/srcpkgs/rust/patches/0040-rls-atomics.patch
new file mode 100644
index 00000000000..8d061b8af8e
--- /dev/null
+++ b/srcpkgs/rust/patches/0040-rls-atomics.patch
@@ -0,0 +1,58 @@
+--- rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
+@@ -7,7 +7,7 @@ use crate::config::Config;
+ use crate::server::{self, LsService, Notification, Request, RequestId};
+ use rls_analysis::{AnalysisHost, Target};
+ use rls_vfs::Vfs;
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ 
+ use lsp_types::{
+     ClientCapabilities, CodeActionContext, CodeActionParams, CompletionItem,
+@@ -314,8 +314,8 @@ fn url(file_name: &str) -> Url {
+ }
+ 
+ fn next_id() -> RequestId {
+-    static ID: AtomicU64 = AtomicU64::new(1);
+-    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst))
++    static ID: AtomicU32 = AtomicU32::new(1);
++    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst).into())
+ }
+ 
+ // Custom reader and output for the RLS server.
+--- rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
+@@ -7,7 +7,7 @@ use crate::lsp_data::{LSPNotification, LSPRequest};
+ 
+ use std::fmt;
+ use std::io::{self, BufRead, Write};
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ use std::sync::Arc;
+ 
+ use jsonrpc_core::{self as jsonrpc, response, version, Id};
+@@ -171,13 +171,13 @@ pub trait Output: Sync + Send + Clone + 'static {
+ /// An output that sends notifications and responses on `stdout`.
+ #[derive(Clone)]
+ pub(super) struct StdioOutput {
+-    next_id: Arc<AtomicU64>,
++    next_id: Arc<AtomicU32>,
+ }
+ 
+ impl StdioOutput {
+     /// Constructs a new `stdout` output.
+     pub(crate) fn new() -> StdioOutput {
+-        StdioOutput { next_id: Arc::new(AtomicU64::new(1)) }
++        StdioOutput { next_id: Arc::new(AtomicU32::new(1).into()) }
+     }
+ }
+ 
+@@ -194,7 +194,7 @@ impl Output for StdioOutput {
+     }
+ 
+     fn provide_id(&self) -> RequestId {
+-        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst))
++        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst).into())
+     }
+ }
+ 
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..341b39fafcc 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,116 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
-
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
-	fi
+	local _rust_root _local_rebuild
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+		_rust_root="/usr"
+		_local_rebuild="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build              = "${RUST_BUILD}"
+		host               = [ "${RUST_TARGET}" ]
+		target             = [ "${RUST_TARGET}" ]
+		cargo              = "${_rust_root}/bin/cargo"
+		rustc              = "${_rust_root}/bin/rustc"
+		submodules         = false
+		python             = "python3"
+		locked-deps        = true
+		vendor             = true
+		full-bootstrap     = false
+		local-rebuild      = ${_local_rebuild}
+		extended           = false
+		docs               = false
+		tools              = []
+		[install]
+		prefix             = "/usr"
+		[rust]
+		codegen-units      = 1
+		debuginfo          = true
+		debuginfo-lines    = true
+		debuginfo-only-std = true
+		debuginfo-tools    = true
+		backtrace          = true
+		channel            = "stable"
+		rpath              = false
+		jemalloc           = false
+		codegen-tests      = false
+		[target.${RUST_BUILD}]
+		llvm-config        = "/usr/bin/llvm-config"
+		crt-static         = false
+		cc                 = "${CC_host:-$CC}"
+		cxx                = "${CXX_host:-$CXX}"
+		ar                 = "${AR_host:-$AR}"
+		linker             = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config    = "/usr/bin/llvm-config"
+			crt-static     = false
+			cc             = "${CC}"
+			cxx            = "${CXX}"
+			ar             = "${AR}"
+			linker         = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" python3 x.py dist ${makejobs}
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
@ 2019-07-06 16:20 ` voidlinux-github
  2019-07-06 16:20 ` voidlinux-github
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 16:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 76529 bytes --]

From 83c87fc64cbf14719a4b4efbb2625dc5e78da055 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 ...-Don-t-pass-CFLAGS-to-the-C-compiler.patch |  26 ++
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 srcpkgs/rust/patches/0040-rls-atomics.patch   |  58 +++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 352 +++++++++-------
 23 files changed, 1167 insertions(+), 308 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 create mode 100644 srcpkgs/rust/patches/0040-rls-atomics.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
new file mode 100644
index 00000000000..fc3d3c10945
--- /dev/null
+++ b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
@@ -0,0 +1,26 @@
+From aa432f281344baa87c69add2229dd8d81acee967 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Wed, 10 Jan 2018 13:36:41 -0600
+Subject: [PATCH 01/12] Don't pass CFLAGS to the C++ compiler
+
+---
+ src/bootstrap/builder.rs | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
+index 51663e931..af4b47192 100644
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -1116,8 +1116,7 @@ impl<'a> Builder<'a> {
+             if let Ok(cxx) = self.cxx(target) {
+                 let cxx = ccacheify(&cxx);
+                 cargo
+-                    .env(format!("CXX_{}", target), &cxx)
+-                    .env(format!("CXXFLAGS_{}", target), cflags);
++                    .env(format!("CXX_{}", target), &cxx);
+             }
+         }
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/0040-rls-atomics.patch b/srcpkgs/rust/patches/0040-rls-atomics.patch
new file mode 100644
index 00000000000..8d061b8af8e
--- /dev/null
+++ b/srcpkgs/rust/patches/0040-rls-atomics.patch
@@ -0,0 +1,58 @@
+--- rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
+@@ -7,7 +7,7 @@ use crate::config::Config;
+ use crate::server::{self, LsService, Notification, Request, RequestId};
+ use rls_analysis::{AnalysisHost, Target};
+ use rls_vfs::Vfs;
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ 
+ use lsp_types::{
+     ClientCapabilities, CodeActionContext, CodeActionParams, CompletionItem,
+@@ -314,8 +314,8 @@ fn url(file_name: &str) -> Url {
+ }
+ 
+ fn next_id() -> RequestId {
+-    static ID: AtomicU64 = AtomicU64::new(1);
+-    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst))
++    static ID: AtomicU32 = AtomicU32::new(1);
++    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst).into())
+ }
+ 
+ // Custom reader and output for the RLS server.
+--- rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
+@@ -7,7 +7,7 @@ use crate::lsp_data::{LSPNotification, LSPRequest};
+ 
+ use std::fmt;
+ use std::io::{self, BufRead, Write};
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ use std::sync::Arc;
+ 
+ use jsonrpc_core::{self as jsonrpc, response, version, Id};
+@@ -171,13 +171,13 @@ pub trait Output: Sync + Send + Clone + 'static {
+ /// An output that sends notifications and responses on `stdout`.
+ #[derive(Clone)]
+ pub(super) struct StdioOutput {
+-    next_id: Arc<AtomicU64>,
++    next_id: Arc<AtomicU32>,
+ }
+ 
+ impl StdioOutput {
+     /// Constructs a new `stdout` output.
+     pub(crate) fn new() -> StdioOutput {
+-        StdioOutput { next_id: Arc::new(AtomicU64::new(1)) }
++        StdioOutput { next_id: Arc::new(AtomicU32::new(1).into()) }
+     }
+ }
+ 
+@@ -194,7 +194,7 @@ impl Output for StdioOutput {
+     }
+ 
+     fn provide_id(&self) -> RequestId {
+-        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst))
++        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst).into())
+     }
+ }
+ 
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..341b39fafcc 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,116 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
-
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
-	fi
+	local _rust_root _local_rebuild
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+		_rust_root="/usr"
+		_local_rebuild="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build              = "${RUST_BUILD}"
+		host               = [ "${RUST_TARGET}" ]
+		target             = [ "${RUST_TARGET}" ]
+		cargo              = "${_rust_root}/bin/cargo"
+		rustc              = "${_rust_root}/bin/rustc"
+		submodules         = false
+		python             = "python3"
+		locked-deps        = true
+		vendor             = true
+		full-bootstrap     = false
+		local-rebuild      = ${_local_rebuild}
+		extended           = false
+		docs               = false
+		tools              = []
+		[install]
+		prefix             = "/usr"
+		[rust]
+		codegen-units      = 1
+		debuginfo          = true
+		debuginfo-lines    = true
+		debuginfo-only-std = true
+		debuginfo-tools    = true
+		backtrace          = true
+		channel            = "stable"
+		rpath              = false
+		jemalloc           = false
+		codegen-tests      = false
+		[target.${RUST_BUILD}]
+		llvm-config        = "/usr/bin/llvm-config"
+		crt-static         = false
+		cc                 = "${CC_host:-$CC}"
+		cxx                = "${CXX_host:-$CXX}"
+		ar                 = "${AR_host:-$AR}"
+		linker             = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config    = "/usr/bin/llvm-config"
+			crt-static     = false
+			cc             = "${CC}"
+			cxx            = "${CXX}"
+			ar             = "${AR}"
+			linker         = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" python3 x.py dist ${makejobs}
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
  2019-07-06 16:20 ` [PR PATCH] [Updated] " voidlinux-github
@ 2019-07-06 16:20 ` voidlinux-github
  2019-07-06 21:53 ` voidlinux-github
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 16:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 76529 bytes --]

From 83c87fc64cbf14719a4b4efbb2625dc5e78da055 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 ...-Don-t-pass-CFLAGS-to-the-C-compiler.patch |  26 ++
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 srcpkgs/rust/patches/0040-rls-atomics.patch   |  58 +++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 352 +++++++++-------
 23 files changed, 1167 insertions(+), 308 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 create mode 100644 srcpkgs/rust/patches/0040-rls-atomics.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
new file mode 100644
index 00000000000..fc3d3c10945
--- /dev/null
+++ b/srcpkgs/rust/patches/0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
@@ -0,0 +1,26 @@
+From aa432f281344baa87c69add2229dd8d81acee967 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Wed, 10 Jan 2018 13:36:41 -0600
+Subject: [PATCH 01/12] Don't pass CFLAGS to the C++ compiler
+
+---
+ src/bootstrap/builder.rs | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
+index 51663e931..af4b47192 100644
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -1116,8 +1116,7 @@ impl<'a> Builder<'a> {
+             if let Ok(cxx) = self.cxx(target) {
+                 let cxx = ccacheify(&cxx);
+                 cargo
+-                    .env(format!("CXX_{}", target), &cxx)
+-                    .env(format!("CXXFLAGS_{}", target), cflags);
++                    .env(format!("CXX_{}", target), &cxx);
+             }
+         }
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/0040-rls-atomics.patch b/srcpkgs/rust/patches/0040-rls-atomics.patch
new file mode 100644
index 00000000000..8d061b8af8e
--- /dev/null
+++ b/srcpkgs/rust/patches/0040-rls-atomics.patch
@@ -0,0 +1,58 @@
+--- rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/cmd.rs
+@@ -7,7 +7,7 @@ use crate::config::Config;
+ use crate::server::{self, LsService, Notification, Request, RequestId};
+ use rls_analysis::{AnalysisHost, Target};
+ use rls_vfs::Vfs;
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ 
+ use lsp_types::{
+     ClientCapabilities, CodeActionContext, CodeActionParams, CompletionItem,
+@@ -314,8 +314,8 @@ fn url(file_name: &str) -> Url {
+ }
+ 
+ fn next_id() -> RequestId {
+-    static ID: AtomicU64 = AtomicU64::new(1);
+-    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst))
++    static ID: AtomicU32 = AtomicU32::new(1);
++    RequestId::Num(ID.fetch_add(1, Ordering::SeqCst).into())
+ }
+ 
+ // Custom reader and output for the RLS server.
+--- rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
++++ rustc-1.36.0-src/src/tools/rls/rls/src/server/io.rs
+@@ -7,7 +7,7 @@ use crate::lsp_data::{LSPNotification, LSPRequest};
+ 
+ use std::fmt;
+ use std::io::{self, BufRead, Write};
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ use std::sync::Arc;
+ 
+ use jsonrpc_core::{self as jsonrpc, response, version, Id};
+@@ -171,13 +171,13 @@ pub trait Output: Sync + Send + Clone + 'static {
+ /// An output that sends notifications and responses on `stdout`.
+ #[derive(Clone)]
+ pub(super) struct StdioOutput {
+-    next_id: Arc<AtomicU64>,
++    next_id: Arc<AtomicU32>,
+ }
+ 
+ impl StdioOutput {
+     /// Constructs a new `stdout` output.
+     pub(crate) fn new() -> StdioOutput {
+-        StdioOutput { next_id: Arc::new(AtomicU64::new(1)) }
++        StdioOutput { next_id: Arc::new(AtomicU32::new(1).into()) }
+     }
+ }
+ 
+@@ -194,7 +194,7 @@ impl Output for StdioOutput {
+     }
+ 
+     fn provide_id(&self) -> RequestId {
+-        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst))
++        RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst).into())
+     }
+ }
+ 
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..341b39fafcc 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,116 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
-
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
-	fi
+	local _rust_root _local_rebuild
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+		_rust_root="/usr"
+		_local_rebuild="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build              = "${RUST_BUILD}"
+		host               = [ "${RUST_TARGET}" ]
+		target             = [ "${RUST_TARGET}" ]
+		cargo              = "${_rust_root}/bin/cargo"
+		rustc              = "${_rust_root}/bin/rustc"
+		submodules         = false
+		python             = "python3"
+		locked-deps        = true
+		vendor             = true
+		full-bootstrap     = false
+		local-rebuild      = ${_local_rebuild}
+		extended           = false
+		docs               = false
+		tools              = []
+		[install]
+		prefix             = "/usr"
+		[rust]
+		codegen-units      = 1
+		debuginfo          = true
+		debuginfo-lines    = true
+		debuginfo-only-std = true
+		debuginfo-tools    = true
+		backtrace          = true
+		channel            = "stable"
+		rpath              = false
+		jemalloc           = false
+		codegen-tests      = false
+		[target.${RUST_BUILD}]
+		llvm-config        = "/usr/bin/llvm-config"
+		crt-static         = false
+		cc                 = "${CC_host:-$CC}"
+		cxx                = "${CXX_host:-$CXX}"
+		ar                 = "${AR_host:-$AR}"
+		linker             = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config    = "/usr/bin/llvm-config"
+			crt-static     = false
+			cc             = "${CC}"
+			cxx            = "${CXX}"
+			ar             = "${AR}"
+			linker         = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" python3 x.py dist ${makejobs}
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
  2019-07-06 16:20 ` [PR PATCH] [Updated] " voidlinux-github
  2019-07-06 16:20 ` voidlinux-github
@ 2019-07-06 21:53 ` voidlinux-github
  2019-07-06 21:53 ` voidlinux-github
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 21:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72904 bytes --]

From cd102f1f065e0f63e9a80c6b05c8bf05f4184ded Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 364 +++++++++-------
 21 files changed, 1096 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..499b04133aa 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,130 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_extended
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# build the extended toolset, disabled by default
+	_use_extended="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = ${_use_extended}
+		docs = false
+		tools = [ "cargo" ]
+		cargo-native-static = true
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = false
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (2 preceding siblings ...)
  2019-07-06 21:53 ` voidlinux-github
@ 2019-07-06 21:53 ` voidlinux-github
  2019-07-06 21:53 ` voidlinux-github
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 21:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72904 bytes --]

From cd102f1f065e0f63e9a80c6b05c8bf05f4184ded Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 364 +++++++++-------
 21 files changed, 1096 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..499b04133aa 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,130 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_extended
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# build the extended toolset, disabled by default
+	_use_extended="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = ${_use_extended}
+		docs = false
+		tools = [ "cargo" ]
+		cargo-native-static = true
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = false
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (4 preceding siblings ...)
  2019-07-06 21:53 ` voidlinux-github
@ 2019-07-06 21:53 ` voidlinux-github
  2019-07-07  3:03 ` voidlinux-github
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 21:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72915 bytes --]

From 0df47bd6fb8e783bfca1dd7601b9a90aa36a8933 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 364 +++++++++-------
 21 files changed, 1096 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..499b04133aa 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,130 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_extended
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# build the extended toolset, disabled by default
+	_use_extended="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = ${_use_extended}
+		docs = false
+		tools = [ "cargo" ]
+		cargo-native-static = true
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = false
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (3 preceding siblings ...)
  2019-07-06 21:53 ` voidlinux-github
@ 2019-07-06 21:53 ` voidlinux-github
  2019-07-06 21:53 ` voidlinux-github
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-06 21:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72915 bytes --]

From 0df47bd6fb8e783bfca1dd7601b9a90aa36a8933 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 364 +++++++++-------
 21 files changed, 1096 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..499b04133aa 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,119 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+ 
+		# need to make sure linkage is correct for bootstrap compiler
+		# but also need to make sure this does not leak around the place
+		pushd "${wrksrc}/${_bootstrap_dir}/bin"
+		mv rustc rustc.real
+		mv cargo cargo.real
+		cat > rustc <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/rustc.real" "\$@"
+		EOF
+		cat > cargo <<- EOF
+			#!/bin/sh
+			export LD_LIBRARY_PATH="${wrksrc}/${_bootstrap_dir}/lib"
+			exec "${wrksrc}/${_bootstrap_dir}/bin/cargo.real" "\$@"
+		EOF
+		chmod +x rustc
+		chmod +x cargo
+		popd
 	fi
 }
 
@@ -149,85 +148,130 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_extended
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# build the extended toolset, disabled by default
+	_use_extended="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = ${_use_extended}
+		docs = false
+		tools = [ "cargo" ]
+		cargo-native-static = true
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = false
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (5 preceding siblings ...)
  2019-07-06 21:53 ` voidlinux-github
@ 2019-07-07  3:03 ` voidlinux-github
  2019-07-07  3:03 ` voidlinux-github
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07  3:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72425 bytes --]

From 70eebbb29a61b4be02cd205df3a6627f12a9beb6 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 346 +++++++++-------
 21 files changed, 1078 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..4795553a798 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,100 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
 	fi
 }
 
@@ -149,85 +129,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (6 preceding siblings ...)
  2019-07-07  3:03 ` voidlinux-github
@ 2019-07-07  3:03 ` voidlinux-github
  2019-07-07 12:16 ` voidlinux-github
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07  3:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [ ] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72425 bytes --]

From 70eebbb29a61b4be02cd205df3a6627f12a9beb6 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 346 +++++++++-------
 21 files changed, 1078 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..4795553a798 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,100 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../cargo-${_cargo_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
 	fi
 }
 
@@ -149,85 +129,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (7 preceding siblings ...)
  2019-07-07  3:03 ` voidlinux-github
@ 2019-07-07 12:16 ` voidlinux-github
  2019-07-07 12:16 ` voidlinux-github
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 12:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72448 bytes --]

From 3d081448f7ab98d08a50eae295751b84b58b3024 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..c226c7ce1c5 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		# cargo may not be packaged like the rest
+		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (8 preceding siblings ...)
  2019-07-07 12:16 ` voidlinux-github
@ 2019-07-07 12:16 ` voidlinux-github
  2019-07-07 12:19 ` voidlinux-github
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 12:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72448 bytes --]

From 3d081448f7ab98d08a50eae295751b84b58b3024 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..c226c7ce1c5 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		# cargo may not be packaged like the rest
+		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (9 preceding siblings ...)
  2019-07-07 12:16 ` voidlinux-github
@ 2019-07-07 12:19 ` voidlinux-github
  2019-07-07 12:19 ` voidlinux-github
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72448 bytes --]

From a5c6bf88e6d60c1e00168012df10795475cfc60c Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..f9568e9a4c6 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		# cargo may not be packaged like the rest
+		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (10 preceding siblings ...)
  2019-07-07 12:19 ` voidlinux-github
@ 2019-07-07 12:19 ` voidlinux-github
  2019-07-07 16:10 ` voidlinux-github
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 72448 bytes --]

From a5c6bf88e6d60c1e00168012df10795475cfc60c Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

[ci skip]
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..f9568e9a4c6 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
+			 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
+			 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
+			;;
+		ppc64)
+			checksum+="
+			 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
+			 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
+			 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
+			;;
+		ppc64-musl)
+			checksum+="
+			 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
+			 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
+			 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
+			 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
+			 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		# cargo may not be packaged like the rest
+		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (11 preceding siblings ...)
  2019-07-07 12:19 ` voidlinux-github
@ 2019-07-07 16:10 ` voidlinux-github
  2019-07-07 16:10 ` voidlinux-github
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 16:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 77383 bytes --]

From 5ec1e76b6982aa4c2c2346c8076dd4ad7c22448b Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH 1/2] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..45ad7d98411 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 e04239f9c0f230249412ca814f2f954e269c9724fe5741d87f6dc76ddaa15251
+			 98e8b4e6335bdb8cd387c8681686e20d9aa230bcf16ba0ea7cf3c1818d964425
+			 d2690135522db9fdc6efa2f432e5719b8b70abc94e91db278b84be834a75bf72"
+			;;
+		ppc64)
+			checksum+="
+			 4328cd52d37df39b78c6223a7a6d07129ef9861efa67dbdadbcfe6c991e0febf
+			 800f27805adef749219f9507497dbadebdac2d5c50f951ca1426d4d447e7f318
+			 8b2f7d5da611a21dd7e0b4238b9aca6ee32f1e49d8fe831435301f11a29b12de"
+			;;
+		ppc64-musl)
+			checksum+="
+			 7cef3f67652607e4f6ed09ff6eb54ee0a7485ae5491a2c015ef9357aadc40295
+			 6f2dc455113a12b2f5fcefbda6e225ad568e750b8f900de5d326cf2c05e45ec9
+			 131db0127366665b2ae55327155c171e99c2eddfb4bcdd7e5cd2663ada109bd5"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 181c81346bc75d6316d08efa242f49c3d3e70fa0c480e673c9bc7209c63ca6e6
+			 4449b886359efe7fb39d75a086fc25520730f96932588e120abbf04387ac8aad
+			 119dba3538f6c1d1164b720b238acac598e1924d943ebbdf3c7113ec3cbd8a2a"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		# cargo may not be packaged like the rest
+		cp ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

From ba006ce061c92788fc613bc31aa6a6a1e977636c Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sun, 7 Jul 2019 18:04:41 +0200
Subject: [PATCH 2/2] cargo: update to 0.37.0

[ci skip]
---
 srcpkgs/cargo/template | 112 +++++++++++++++++++----------------------
 1 file changed, 53 insertions(+), 59 deletions(-)

diff --git a/srcpkgs/cargo/template b/srcpkgs/cargo/template
index 4acc541fd6a..a0bca421f61 100644
--- a/srcpkgs/cargo/template
+++ b/srcpkgs/cargo/template
@@ -1,7 +1,7 @@
 # Template file for 'cargo'
 pkgname=cargo
-version=0.36.0
-revision=3
+version=0.37.0
+revision=1
 build_helper=rust
 hostmakedepends="rust python curl cmake pkg-config"
 makedepends="libcurl-devel libgit2-devel"
@@ -11,69 +11,62 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://crates.io/"
 distfiles="https://github.com/rust-lang/cargo/archive/${version}.tar.gz"
-checksum=532a39ce9acc1436c5d33ce0643d050bc29183c46abe69934622c4f24f4c6831
-_cargo_dist_version=0.36.0
+checksum=377e1090e9ce21206270576193746499a26e8ffbd8b89ccd5f8eb1085ca00e3b
+_cargo_dist_version=0.37.0
 build_options="static"
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo"
 	makedepends+=" rust"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
+	case "$XBPS_MACHINE" in
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.gz"
-		checksum+="
-		 7a84d006688ffe9e292db59690e7fc99616d6d1a6d981affb93d121fca9e8bb5"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 77586f2fb5b6f6caef0cb6d3cc32a18559d4fcd6a6db4e75f4b3fb7adb050437"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 6ef32560bfa7c85dee6ef932a5e35994457f3e05e2cf8979c19971b8a5b805e4"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 d196e4e506c89653c533e34c77fb5be7928a1667bca64a3fd866dd0d1aecfc6d"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 821b4acd67c438b533436e1a57d11e9e267f6641493c9d49650ace657f59e106"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		i686)
+			checksum+="
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 d2690135522db9fdc6efa2f432e5719b8b70abc94e91db278b84be834a75bf72"
+			;;
+		ppc64)
+			checksum+="
+			 8b2f7d5da611a21dd7e0b4238b9aca6ee32f1e49d8fe831435301f11a29b12de"
+			;;
+		ppc64-musl)
+			checksum+="
+			 131db0127366665b2ae55327155c171e99c2eddfb4bcdd7e5cd2663ada109bd5"
+			;;
+		ppc)
+			checksum+="
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 119dba3538f6c1d1164b720b238acac598e1924d943ebbdf3c7113ec3cbd8a2a"
+			;;
 	esac
 fi
 
@@ -114,7 +107,8 @@ do_install() {
 	for f in src/etc/man/*.?; do
 		vman $f
 	done
-	vinstall src/etc/cargo.bashcomp.sh 0644 usr/share/bash-completion/completions cargo
+	vinstall src/etc/cargo.bashcomp.sh 0644 \
+	 usr/share/bash-completion/completions cargo
 	vinstall src/etc/_cargo 0644 usr/share/zsh/site-functions
 
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (12 preceding siblings ...)
  2019-07-07 16:10 ` voidlinux-github
@ 2019-07-07 16:10 ` voidlinux-github
  2019-07-07 16:10 ` voidlinux-github
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 16:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/void-power/void-packages rust136
https://github.com/void-linux/void-packages/pull/12843

[WIP] rust: update to 1.36.0
This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [ ] generate bootstrap binaries for stuff rust doesn't ship
- [ ] get the binaries uploaded and update their checksums
- [ ] test on more archs
- [ ] test building big rust programs (firefox, gxi, ...)

@jnbr

A patch file from https://github.com/void-linux/void-packages/pull/12843.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rust136-12843.patch --]
[-- Type: application/text/x-diff, Size: 77383 bytes --]

From 5ec1e76b6982aa4c2c2346c8076dd4ad7c22448b Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 5 Jul 2019 20:33:28 +0200
Subject: [PATCH 1/2] rust: update to 1.36.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes
---
 .../rust/patches/0002-Fix-LLVM-build.patch    |  26 ++
 ...to-work-when-cross-compiling-on-musl.patch |  45 ++
 ...ative-libraries-when-linking-static-.patch |  56 +++
 ...dlib-and-musl_root-from-musl-targets.patch | 392 ++++++++++++++++++
 ...er-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 ...t-Fix-proc-macro-tests-on-musl-hosts.patch |  39 ++
 ...rn-for-plugins-Don-t-assume-multilib.patch |  30 ++
 ...tes-are-unstable-Fix-test-when-rpath.patch |  25 ++
 ...nore-broken-and-non-applicable-tests.patch | 104 +++++
 ...-stage-2-tools-dynamically-to-libstd.patch |  27 ++
 ...e-debugger-scripts-to-usr-share-rust.patch |  53 +++
 ...ch => 0029-musl-dont-use-crt-static.patch} |  11 +-
 srcpkgs/rust/patches/0030-libc-linkage.patch  |  27 ++
 srcpkgs/rust/patches/0031-typenum-pmmx.patch  |  28 ++
 ...atch => 0091-lzma-sys-cross-ldflags.patch} |   6 +-
 ...atch => 0092-use-correct-llvm-cross.patch} |   7 +-
 ....patch => 0093-use-elfv2-everywhere.patch} |   8 +-
 srcpkgs/rust/patches/libunwind.patch          |  64 ---
 .../rust/patches/limit-internalization.patch  |  27 --
 .../rust/patches/link-musl-dynamically.patch  |  40 --
 srcpkgs/rust/template                         | 347 +++++++++-------
 21 files changed, 1079 insertions(+), 307 deletions(-)
 create mode 100644 srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
 create mode 100644 srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
 create mode 100644 srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
 create mode 100644 srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 create mode 100644 srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
 create mode 100644 srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
 create mode 100644 srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
 create mode 100644 srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
 create mode 100644 srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
 create mode 100644 srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
 create mode 100644 srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
 rename srcpkgs/rust/patches/{musl-dont-use-crt-static.patch => 0029-musl-dont-use-crt-static.patch} (51%)
 create mode 100644 srcpkgs/rust/patches/0030-libc-linkage.patch
 create mode 100644 srcpkgs/rust/patches/0031-typenum-pmmx.patch
 rename srcpkgs/rust/patches/{lzma-sys-cross-ldflags.patch => 0091-lzma-sys-cross-ldflags.patch} (73%)
 rename srcpkgs/rust/patches/{use-correct-llvm-when-cross.patch => 0092-use-correct-llvm-cross.patch} (75%)
 rename srcpkgs/rust/patches/{use-elfv2-everywhere.patch => 0093-use-elfv2-everywhere.patch} (85%)
 delete mode 100644 srcpkgs/rust/patches/libunwind.patch
 delete mode 100644 srcpkgs/rust/patches/limit-internalization.patch
 delete mode 100644 srcpkgs/rust/patches/link-musl-dynamically.patch

diff --git a/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
new file mode 100644
index 00000000000..95e261df034
--- /dev/null
+++ b/srcpkgs/rust/patches/0002-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 59faa3f7b9b07d986bcd810d750daad956bd612b Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 02/12] Fix LLVM build
+
+---
+ src/bootstrap/lib.rs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index ca4489655..7618a6e6d 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -774,7 +774,8 @@ impl Build {
+         // cc-rs because the build scripts will determine that for themselves.
+         let mut base = self.cc[&target].args().iter()
+                            .map(|s| s.to_string_lossy().into_owned())
+-                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
++                           .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")
++                                   && !s.starts_with("-static"))
+                            .collect::<Vec<String>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
new file mode 100644
index 00000000000..55c4ab799ee
--- /dev/null
+++ b/srcpkgs/rust/patches/0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
@@ -0,0 +1,45 @@
+From 681f46ea92719a419c3dadbe3376062cc5bde8b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 03/12] Allow rustdoc to work when cross-compiling on musl
+
+musl can't handle foreign-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 1c9f6e1ab..7e90be8d8 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -23,9 +23,6 @@ fn main() {
+         Err(_) => 0,
+     };
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir.clone()));
+-
+     //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
+     //arguments here
+     let mut cmd = Command::new(rustdoc);
+@@ -37,7 +34,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(&sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir.clone()));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+@@ -86,7 +83,7 @@ fn main() {
+         eprintln!(
+             "rustdoc command: {:?}={:?} {:?}",
+             bootstrap::util::dylib_path_var(),
+-            env::join_paths(&dylib_path).unwrap(),
++            PathBuf::from(libdir.clone()),
+             cmd,
+         );
+         eprintln!("sysroot: {:?}", sysroot);
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 00000000000..58aa482d6fb
--- /dev/null
+++ b/srcpkgs/rust/patches/0004-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,56 @@
+From b0de26f4cef75c63a7901990ed92fe0616a971fc Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/12] Require static native libraries when linking static
+ executables
+
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
+
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index d5a56f6a0..bb06d80d8 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -1548,9 +1548,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1593,7 +1591,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // On some targets, like Linux, linking a static executable inhibits using
++                    // dylibs at all. Force native libraries to be static, even if for example
++                    // an upstream rlib was originally linked against a native shared library.
++                    if crate_type == config::CrateType::Executable
++                        && sess.crt_static()
++                        && !sess.target.target.options.crt_static_allows_dylibs
++                    {
++                        cmd.link_staticlib(&name.as_str())
++                    } else {
++                        cmd.link_dylib(&name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate they originate from
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 00000000000..7f524b1eabf
--- /dev/null
+++ b/srcpkgs/rust/patches/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,392 @@
+From 9e646efacc9459f05bcefe9ad6d8e65dd06ba2d7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 05/12] Remove -nostdlib and musl_root from musl targets
+
+---
+ config.toml.example                           |  6 ----
+ src/bootstrap/bin/rustc.rs                    | 10 -------
+ src/bootstrap/cc_detect.rs                    | 27 ++----------------
+ src/bootstrap/compile.rs                      | 21 +-------------
+ src/bootstrap/config.rs                       |  7 -----
+ src/bootstrap/configure.py                    | 22 ---------------
+ src/bootstrap/lib.rs                          |  8 ------
+ src/bootstrap/sanity.rs                       | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile   |  2 --
+ src/ci/docker/dist-various-1/Dockerfile       |  7 -----
+ src/ci/docker/dist-x86_64-musl/Dockerfile     |  1 -
+ src/ci/docker/test-various/Dockerfile         |  1 -
+ src/librustc_target/spec/linux_musl_base.rs   | 16 -----------
+ 13 files changed, 4 insertions(+), 152 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index 556625b53..3c6f18728 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -474,12 +474,6 @@
+ # only use static libraries. If unset, the target's default linkage is used.
+ #crt-static = false
+ 
+-# The root location of the MUSL installation directory. The library directory
+-# will also need to contain libunwind.a for an unwinding implementation. Note
+-# that this option only makes sense for MUSL targets that produce statically
+-# linked binaries
+-#musl-root = "..."
+-
+ # The root location of the `wasm32-wasi` sysroot.
+ #wasi-root = "..."
+ 
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 821c37dc2..906af787f 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -122,16 +122,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding various
+-        // sysroot native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            if target.contains("musl") {
+-                let mut root = OsString::from("native=");
+-                root.push(&s);
+-                root.push("/lib");
+-                cmd.arg("-L").arg(&root);
+-            }
+-        }
+         if let Some(s) = env::var_os("WASI_ROOT") {
+             let mut root = OsString::from("native=");
+             root.push(&s);
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index dfc243b70..848d1d4b2 100644
+--- a/src/bootstrap/cc_detect.rs
++++ b/src/bootstrap/cc_detect.rs
+@@ -84,7 +84,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
+             cfg.compiler(cc);
+         } else {
+-            set_compiler(&mut cfg, Language::C, target, config, build);
++            set_compiler(&mut cfg, Language::C, target, config);
+         }
+ 
+         let compiler = cfg.get_compiler();
+@@ -113,7 +113,7 @@ pub fn find(build: &mut Build) {
+         if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+             cfg.compiler(cxx);
+         } else {
+-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
++            set_compiler(&mut cfg, Language::CPlusPlus, host, config);
+         }
+         let compiler = cfg.get_compiler();
+         build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
+@@ -124,8 +124,7 @@ pub fn find(build: &mut Build) {
+ fn set_compiler(cfg: &mut cc::Build,
+                 compiler: Language,
+                 target: Interned<String>,
+-                config: Option<&Target>,
+-                build: &Build) {
++                config: Option<&Target>) {
+     match &*target {
+         // When compiling for android we may have the NDK configured in the
+         // config.toml in which case we look there. Otherwise the default
+@@ -165,26 +164,6 @@ fn set_compiler(cfg: &mut cc::Build,
+             }
+         }
+ 
+-        "mips-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mips-linux-musl-gcc");
+-            }
+-        }
+-        "mipsel-unknown-linux-musl" => {
+-            if cfg.get_compiler().path().to_str() == Some("gcc") {
+-                cfg.compiler("mipsel-linux-musl-gcc");
+-            }
+-        }
+-
+-        t if t.contains("musl") => {
+-            if let Some(root) = build.musl_root(target) {
+-                let guess = root.join("bin/musl-gcc");
+-                if guess.exists() {
+-                    cfg.compiler(guess);
+-                }
+-            }
+-        }
+-
+         _ => {}
+     }
+ }
+diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
+index e1cdd226f..05442c6c6 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -115,20 +115,7 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
+     let libdir = builder.sysroot_libdir(*compiler, target);
+ 
+-    // Copies the crt(1,i,n).o startup objects
+-    //
+-    // Since musl supports fully static linking, we can cross link for it even
+-    // with a glibc-targeting toolchain, given we have the appropriate startup
+-    // files. As those shipped with glibc won't work, copy the ones provided by
+-    // musl so we have them on linux-gnu hosts.
+-    if target.contains("musl") {
+-        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-            builder.copy(
+-                &builder.musl_root(target).unwrap().join("lib").join(obj),
+-                &libdir.join(obj),
+-            );
+-        }
+-    } else if target.ends_with("-wasi") {
++    if target.ends_with("-wasi") {
+         for &obj in &["crt1.o"] {
+             builder.copy(
+                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
+@@ -191,12 +178,6 @@ pub fn std_cargo(builder: &Builder<'_>,
+             .arg("--manifest-path")
+             .arg(builder.src.join("src/libstd/Cargo.toml"));
+ 
+-        if target.contains("musl") {
+-            if let Some(p) = builder.musl_root(target) {
+-                cargo.env("MUSL_ROOT", p);
+-            }
+-        }
+-
+         if target.ends_with("-wasi") {
+             if let Some(p) = builder.wasi_root(target) {
+                 cargo.env("WASI_ROOT", p);
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index b1d009a67..cc567839f 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -135,8 +135,6 @@ pub struct Config {
+     pub print_step_timings: bool,
+     pub missing_tools: bool,
+ 
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub datadir: Option<PathBuf>,
+@@ -171,7 +169,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub wasi_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+     pub no_std: bool,
+@@ -308,7 +305,6 @@ struct Rust {
+     backtrace: Option<bool>,
+     default_linker: Option<String>,
+     channel: Option<String>,
+-    musl_root: Option<String>,
+     rpath: Option<bool>,
+     optimize_tests: Option<bool>,
+     debuginfo_tests: Option<bool>,
+@@ -348,7 +344,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     wasi_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+@@ -568,7 +563,6 @@ impl Config {
+             set(&mut config.llvm_tools_enabled, rust.llvm_tools);
+             config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+             config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+             set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
+             set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
+@@ -611,7 +605,6 @@ impl Config {
+                 target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
+                 target.linker = cfg.linker.clone().map(PathBuf::from);
+                 target.crt_static = cfg.crt_static.clone();
+-                target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
+                 target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
+                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index ade8afee7..f9ccf7aed 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -111,28 +111,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+   "aarch64-linux-android NDK standalone path")
+ v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
+   "x86_64-linux-android NDK standalone path")
+-v("musl-root", "target.x86_64-unknown-linux-musl.musl-root",
+-  "MUSL root installation directory (deprecated)")
+-v("musl-root-x86_64", "target.x86_64-unknown-linux-musl.musl-root",
+-  "x86_64-unknown-linux-musl install directory")
+-v("musl-root-i586", "target.i586-unknown-linux-musl.musl-root",
+-  "i586-unknown-linux-musl install directory")
+-v("musl-root-i686", "target.i686-unknown-linux-musl.musl-root",
+-  "i686-unknown-linux-musl install directory")
+-v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root",
+-  "arm-unknown-linux-musleabi install directory")
+-v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
+-  "arm-unknown-linux-musleabihf install directory")
+-v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
+-  "armv5te-unknown-linux-musleabi install directory")
+-v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
+-  "armv7-unknown-linux-musleabihf install directory")
+-v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
+-  "aarch64-unknown-linux-musl install directory")
+-v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
+-  "mips-unknown-linux-musl install directory")
+-v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
+-  "mipsel-unknown-linux-musl install directory")
+ v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
+   "rootfs in qemu testing, you probably don't want to use this")
+ v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
+diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
+index 7618a6e6d..49cdb526e 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -852,14 +852,6 @@ impl Build {
+         }
+     }
+ 
+-    /// Returns the "musl root" for this `target`, if defined
+-    fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
+-        self.config.target_config.get(&target)
+-            .and_then(|t| t.musl_root.as_ref())
+-            .or(self.config.musl_root.as_ref())
+-            .map(|p| &**p)
+-    }
+-
+     /// Returns the sysroot for the wasi target, if defined
+     fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
+         self.config.target_config.get(&target)
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index dc65fb9b7..060ba6d9e 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -176,34 +176,6 @@ pub fn check(build: &mut Build) {
+             }
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") {
+-            // If this is a native target (host is also musl) and no musl-root is given,
+-            // fall back to the system toolchain in /usr before giving up
+-            if build.musl_root(*target).is_none() && build.config.build == *target {
+-                let target = build.config.target_config.entry(target.clone())
+-                    .or_default();
+-                target.musl_root = Some("/usr".into());
+-            }
+-            match build.musl_root(*target) {
+-                Some(root) => {
+-                    if fs::metadata(root.join("lib/libc.a")).is_err() {
+-                        panic!("couldn't find libc.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
+-                        panic!("couldn't find libunwind.a in musl dir: {}",
+-                               root.join("lib").display());
+-                    }
+-                }
+-                None => {
+-                    panic!("when targeting MUSL either the rust.musl-root \
+-                            option or the target.$TARGET.musl-root option must \
+-                            be specified in config.toml")
+-                }
+-            }
+-        }
+-
+         if target.contains("msvc") {
+             // There are three builds of cmake on windows: MSVC, MinGW, and
+             // Cygwin. The Cygwin build does not have generators for Visual
+diff --git a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+index ba2d32a92..412c37fdd 100644
+--- a/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile
+@@ -30,8 +30,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-i586=/musl-i586 \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
+index a722a4183..44e6728de 100644
+--- a/src/ci/docker/dist-various-1/Dockerfile
++++ b/src/ci/docker/dist-various-1/Dockerfile
+@@ -132,13 +132,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+     CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+     
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-armv5te=/musl-armv5te \
+-      --musl-root-arm=/musl-arm \
+-      --musl-root-armhf=/musl-armhf \
+-      --musl-root-armv7=/musl-armv7 \
+-      --musl-root-aarch64=/musl-aarch64 \
+-      --musl-root-mips=/musl-mips \
+-      --musl-root-mipsel=/musl-mipsel \
+       --enable-emscripten \
+       --disable-docs
+ 
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 385eefde8..81d4f7737 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -31,7 +31,6 @@ RUN sh /scripts/sccache.sh
+ ENV HOSTS=x86_64-unknown-linux-musl
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-      --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+       --enable-extended \
+       --disable-docs \
+       --set target.x86_64-unknown-linux-musl.crt-static=false \
+diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile
+index 611a24a69..99c2b866b 100644
+--- a/src/ci/docker/test-various/Dockerfile
++++ b/src/ci/docker/test-various/Dockerfile
+@@ -31,7 +31,6 @@ COPY scripts/sccache.sh /scripts/
+ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+-  --musl-root-x86_64=/usr/local/x86_64-linux-musl \
+   --set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
+   --set rust.lld
+ 
+diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
+index e294e6398..58ae91a96 100644
+--- a/src/librustc_target/spec/linux_musl_base.rs
++++ b/src/librustc_target/spec/linux_musl_base.rs
+@@ -3,28 +3,12 @@ use crate::spec::{LinkerFlavor, TargetOptions};
+ pub fn opts() -> TargetOptions {
+     let mut base = super::linux_base::opts();
+ 
+-    // Make sure that the linker/gcc really don't pull in anything, including
+-    // default objects, libs, etc.
+-    base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
+-    base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
+-
+     // At least when this was tested, the linker would not add the
+     // `GNU_EH_FRAME` program header to executables generated, which is required
+     // when unwinding to locate the unwinding information. I'm not sure why this
+     // argument is *not* necessary for normal builds, but it can't hurt!
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
+-    // When generating a statically linked executable there's generally some
+-    // small setup needed which is listed in these files. These are provided by
+-    // a musl toolchain and are linked by default by the `musl-gcc` script. Note
+-    // that `gcc` also does this by default, it just uses some different files.
+-    //
+-    // Each target directory for musl has these object files included in it so
+-    // they'll be included from there.
+-    base.pre_link_objects_exe_crt.push("crt1.o".to_string());
+-    base.pre_link_objects_exe_crt.push("crti.o".to_string());
+-    base.post_link_objects_crt.push("crtn.o".to_string());
+-
+     // These targets statically link libc by default
+     base.crt_static_default = true;
+     // These targets allow the user to choose between static and dynamic linking.
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 00000000000..4a06be304f1
--- /dev/null
+++ b/srcpkgs/rust/patches/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From b8815ecb4ec9ecf7c2469703005bede91c0f6f82 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/12] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 0ccffea31..935175dd8 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -26,6 +26,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
new file mode 100644
index 00000000000..c04cb295d65
--- /dev/null
+++ b/srcpkgs/rust/patches/0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
@@ -0,0 +1,39 @@
+From 0401335b6e3724d4868c9c4b556f586c7fcf60b8 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:49:18 +0200
+Subject: [PATCH 07/12] runtest: Fix proc-macro tests on musl hosts
+
+---
+ src/tools/compiletest/src/runtest.rs | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
+index 2082de7cb..03c7a4c58 100644
+--- a/src/tools/compiletest/src/runtest.rs
++++ b/src/tools/compiletest/src/runtest.rs
+@@ -1649,9 +1649,6 @@ impl<'test> TestCx<'test> {
+                 (true, None)
+             } else if self.config.target.contains("cloudabi")
+                 || self.config.target.contains("emscripten")
+-                || (self.config.target.contains("musl")
+-                    && !aux_props.force_host
+-                    && !self.config.host.contains("musl"))
+                 || self.config.target.contains("wasm32")
+                 || self.config.target.contains("nvptx")
+             {
+@@ -1660,10 +1657,8 @@ impl<'test> TestCx<'test> {
+                 // for the test suite (otherwise including libstd statically in all
+                 // executables takes up quite a bit of space).
+                 //
+-                // For targets like MUSL or Emscripten, however, there is no support for
+-                // dynamic libraries so we just go back to building a normal library. Note,
+-                // however, that for MUSL if the library is built with `force_host` then
+-                // it's ok to be a dylib as the host should always support dylibs.
++                // For targets like Emscripten, however, there is no support for
++                // dynamic libraries so we just go back to building a normal library.
+                 (false, Some("lib"))
+             } else {
+                 (true, Some("dylib"))
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
new file mode 100644
index 00000000000..ab6a75d5c43
--- /dev/null
+++ b/srcpkgs/rust/patches/0008-test-use-extern-for-plugins-Don-t-assume-multilib.patch
@@ -0,0 +1,30 @@
+From a10b846716f923b3c5c28fc86e9b07103600ed52 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 6 Jul 2019 17:50:54 +0200
+Subject: [PATCH 08/12] test/use-extern-for-plugins: Don't assume multilib
+
+---
+ src/test/run-make-fulldeps/use-extern-for-plugins/Makefile | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+index 838b1a271..94fa9f6d0 100644
+--- a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
++++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile
+@@ -4,12 +4,7 @@
+ # ignore-openbsd
+ # ignore-sunos
+ 
+-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+-ifeq ($(findstring i686,$(HOST)),i686)
+-TARGET := $(subst i686,x86_64,$(HOST))
+-else
+-TARGET := $(subst x86_64,i686,$(HOST))
+-endif
++TARGET := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
+ 
+ all:
+ 	$(RUSTC) foo.rs -C extra-filename=-host
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
new file mode 100644
index 00000000000..442571fdd45
--- /dev/null
+++ b/srcpkgs/rust/patches/0009-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
@@ -0,0 +1,25 @@
+From 9f457d208f0e916a5fb61401f6558e1302b97fd5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 01:32:20 +0000
+Subject: [PATCH 09/12] test/sysroot-crates-are-unstable: Fix test when rpath
+ is disabled
+
+Without this environment var, the test can't run rustc to find
+the sysroot path.
+---
+ .../run-make-fulldeps/sysroot-crates-are-unstable/Makefile    | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index a35174b3c..9e7707068 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,2 +1,4 @@
++-include ../tools.mk
++
+ all:
+-	python2.7 test.py
++	env '$(HOST_RPATH_ENV)' python2.7 test.py
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
new file mode 100644
index 00000000000..f0c8df9f2b5
--- /dev/null
+++ b/srcpkgs/rust/patches/0010-Ignore-broken-and-non-applicable-tests.patch
@@ -0,0 +1,104 @@
+From 8c4cc90bccacf5ebbb837e5c72de47ab862238f4 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 16 Sep 2018 16:38:48 +0000
+Subject: [PATCH 10/12] Ignore broken and non-applicable tests
+
+c-link-to-rust-va-list-fn: unstable feature, broken on aarch64, #56475
+env-funky-keys: can't handle LD_PRELOAD (e.g. sandbox)
+long-linker-command-lines: takes >10 minutes to run (but still passes)
+simd-intrinsic-generic-bitmask.rs: broken on BE, #59356
+simd-intrinsic-generic-select.rs: broken on BE, #59356
+sparc-struct-abi: no sparc target
+sysroot-crates-are-unstable: can't run rustc without RPATH
+---
+ src/test/codegen/sparc-struct-abi.rs                            | 1 +
+ src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile   | 2 ++
+ src/test/run-make-fulldeps/long-linker-command-lines/Makefile   | 2 ++
+ src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile | 2 ++
+ src/test/run-pass/env-funky-keys.rs                             | 1 +
+ src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs        | 2 ++
+ src/test/run-pass/simd/simd-intrinsic-generic-select.rs         | 2 ++
+ 7 files changed, 12 insertions(+)
+
+diff --git a/src/test/codegen/sparc-struct-abi.rs b/src/test/codegen/sparc-struct-abi.rs
+index 78e5b14a2..6f93e9328 100644
+--- a/src/test/codegen/sparc-struct-abi.rs
++++ b/src/test/codegen/sparc-struct-abi.rs
+@@ -4,6 +4,7 @@
+ 
+ // only-sparc64
+ // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
++// ignore-test
+ #![feature(no_core, lang_items)]
+ #![no_core]
+ 
+diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+index f124ca2ab..363b18f09 100644
+--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
++++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile
+@@ -1,3 +1,5 @@
++# ignore-aarch64
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+index 5876fbc94..5f167ece1 100644
+--- a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
++++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+index 9e7707068..6d92ec5ce 100644
+--- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
++++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile
+@@ -1,3 +1,5 @@
++# ignore-test
++
+ -include ../tools.mk
+ 
+ all:
+diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
+index 3b236e2b3..7284d25de 100644
+--- a/src/test/run-pass/env-funky-keys.rs
++++ b/src/test/run-pass/env-funky-keys.rs
+@@ -1,5 +1,6 @@
+ // Ignore this test on Android, because it segfaults there.
+ 
++// ignore-test
+ // ignore-android
+ // ignore-windows
+ // ignore-cloudabi no execve
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+index b28f742a9..3ee4ccce7 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-bitmask.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_bitmask intrinsic produces correct results.
+ 
+diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+index f79b14049..39080c8c9 100644
+--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
++++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+@@ -2,6 +2,8 @@
+ #![allow(non_camel_case_types)]
+ 
+ // ignore-emscripten
++// ignore-powerpc
++// ignore-powerpc64
+ 
+ // Test that the simd_select intrinsics produces correct results.
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 00000000000..47696bcf24f
--- /dev/null
+++ b/srcpkgs/rust/patches/0011-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,27 @@
+From 7171338ff6f967b6f2c30bdb8804c8f49670a0de Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 24 Sep 2018 23:42:23 +0000
+Subject: [PATCH 11/12] Link stage 2 tools dynamically to libstd
+
+---
+ src/bootstrap/tool.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
+index edcd68d01..b5acf43bb 100644
+--- a/src/bootstrap/tool.rs
++++ b/src/bootstrap/tool.rs
+@@ -209,7 +209,9 @@ pub fn prepare_tool_cargo(
+ 
+     // We don't want to build tools dynamically as they'll be running across
+     // stages and such and it's just easier if they're not dynamically linked.
+-    cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    if compiler.stage < 2 {
++        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
++    }
+ 
+     if source_type == SourceType::Submodule {
+         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
new file mode 100644
index 00000000000..7060a1cb894
--- /dev/null
+++ b/srcpkgs/rust/patches/0012-Move-debugger-scripts-to-usr-share-rust.patch
@@ -0,0 +1,53 @@
+From 6b0dc5093cc23c74dcf1d3bf3a0772b08426785a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Mon, 17 Sep 2018 02:09:10 +0000
+Subject: [PATCH 12/12] Move debugger scripts to /usr/share/rust
+
+---
+ src/bootstrap/dist.rs | 2 +-
+ src/etc/rust-gdb      | 2 +-
+ src/etc/rust-lldb     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index b0616ff66..7a1225a93 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -597,7 +597,7 @@ impl Step for DebuggerScripts {
+     fn run(self, builder: &Builder<'_>) {
+         let host = self.host;
+         let sysroot = self.sysroot;
+-        let dst = sysroot.join("lib/rustlib/etc");
++        let dst = sysroot.join("share/rust");
+         t!(fs::create_dir_all(&dst));
+         let cp_debugger_script = |file: &str| {
+             builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
+diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
+index 23ba93da8..dc51b16c5 100755
+--- a/src/etc/rust-gdb
++++ b/src/etc/rust-gdb
+@@ -4,7 +4,7 @@ set -e
+ 
+ # Find out where the pretty printer Python module is
+ RUSTC_SYSROOT=`rustc --print=sysroot`
+-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
++GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust"
+ 
+ # Run GDB with the additional arguments that load the pretty printers
+ # Set the environment variable `RUST_GDB` to overwrite the call to a
+diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb
+index 424302d49..460e11921 100755
+--- a/src/etc/rust-lldb
++++ b/src/etc/rust-lldb
+@@ -26,7 +26,7 @@ display the contents of local variables!"
+ fi
+ 
+ # Prepare commands that will be loaded before any file on the command line has been loaded
+-script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
++script_import="command script import \"$RUSTC_SYSROOT/share/rust/lldb_rust_formatters.py\""
+ category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
+ category_enable="type category enable Rust"
+ 
+-- 
+2.22.0
+
diff --git a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
similarity index 51%
rename from srcpkgs/rust/patches/musl-dont-use-crt-static.patch
rename to srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
index b180a9fd05d..b2c663fc060 100644
--- a/srcpkgs/rust/patches/musl-dont-use-crt-static.patch
+++ b/srcpkgs/rust/patches/0029-musl-dont-use-crt-static.patch
@@ -1,11 +1,12 @@
 Reason: https://gist.github.com/ab75b3796a9383423deecc0828494ac5
---- rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs.orig   2018-10-08 21:02:21.588611506 +0200
-+++ rustc-1.28.0-src/src/librustc_target/spec/linux_musl_base.rs        2018-10-08 21:02:40.846454873 +0200
-@@ -61,7 +61,7 @@
-     base.post_link_objects_crt.push("crtn.o".to_string());
-
+--- rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/linux_musl_base.rs
+@@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
+     base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
+ 
      // These targets statically link libc by default
 -    base.crt_static_default = true;
 +    base.crt_static_default = false;
      // These targets allow the user to choose between static and dynamic linking.
      base.crt_static_respected = true;
+ 
diff --git a/srcpkgs/rust/patches/0030-libc-linkage.patch b/srcpkgs/rust/patches/0030-libc-linkage.patch
new file mode 100644
index 00000000000..3d3ed67a309
--- /dev/null
+++ b/srcpkgs/rust/patches/0030-libc-linkage.patch
@@ -0,0 +1,27 @@
+--- rustc-1.36.0-src/vendor/libc/src/lib.rs
++++ rustc-1.36.0-src/vendor/libc/src/lib.rs
+@@ -26,6 +26,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ 
+ #[macro_use]
+ mod macros;
+--- rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.36.0-src/vendor/libc/src/unix/mod.rs
+@@ -307,11 +307,11 @@ cfg_if! {
+         // cargo build, don't pull in anything extra as the libstd dep
+         // already pulls in all libs.
+     } else if #[cfg(target_env = "musl")] {
++        #[link(name = "c")]
++        extern {}
+         #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", kind = "static",
++                   link(name = "gcc", kind = "static-nobundle",
+                         cfg(target_feature = "crt-static")))]
+-        #[cfg_attr(feature = "rustc-dep-of-std",
+-                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
+         extern {}
+     } else if #[cfg(target_os = "emscripten")] {
+         #[link(name = "c")]
diff --git a/srcpkgs/rust/patches/0031-typenum-pmmx.patch b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
new file mode 100644
index 00000000000..56165f35ffb
--- /dev/null
+++ b/srcpkgs/rust/patches/0031-typenum-pmmx.patch
@@ -0,0 +1,28 @@
+From a2062b2ec252bb8be9337a6d5b384c8cdda4463d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson@canonical.com>
+Date: Wed, 13 Mar 2019 15:55:30 +1300
+Subject: [PATCH] round result of (highest as f64).log(2.0)
+
+Even though (1024f64).log(2.0) has an exact, representable, value, with
+rustc 1.32 on i386 it comes out as +9.999999999999999985 with
+optimization enabled. And the rustc doesn't like having two defintions
+for U1024 etc.
+---
+ vendor/typenum/build/main.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git rustc-1.36.0-src/vendor/typenum/build/main.rs rustc-1.36.0-src/vendor/typenum/build/main.rs
+index 9c9f237cd..153031a2f 100644
+--- rustc-1.36.0-src/vendor/typenum/build/main.rs
++++ rustc-1.36.0-src/vendor/typenum/build/main.rs
+@@ -77,7 +77,7 @@ pub fn no_std() {}
+ fn main() {
+     let highest: u64 = 1024;
+ 
+-    let first2: u32 = (highest as f64).log(2.0) as u32 + 1;
++    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
+     let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+     let uints = (0..(highest + 1))
+         .chain((first2..64).map(|i| 2u64.pow(i)))
+-- 
+2.22.0
diff --git a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
similarity index 73%
rename from srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
rename to srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
index 82a2fc18864..cc2ead3d414 100644
--- a/srcpkgs/rust/patches/lzma-sys-cross-ldflags.patch
+++ b/srcpkgs/rust/patches/0091-lzma-sys-cross-ldflags.patch
@@ -1,7 +1,7 @@
 This allows lzma-sys to build in a cross-compiling environment.
---- rustc-1.33.0-src/vendor/lzma-sys/build.rs
-+++ rustc-1.33.0-src/vendor/lzma-sys/build.rs
-@@ -101,6 +101,7 @@
+--- rustc-1.36.0-src/vendor/lzma-sys/build.rs
++++ rustc-1.36.0-src/vendor/lzma-sys/build.rs
+@@ -101,6 +101,7 @@ fn main() {
          }
          cmd.env("CC", compiler.path())
             .env("CFLAGS", cflags)
diff --git a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
similarity index 75%
rename from srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
rename to srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
index 54f37167fd8..cce4b59ea66 100644
--- a/srcpkgs/rust/patches/use-correct-llvm-when-cross.patch
+++ b/srcpkgs/rust/patches/0092-use-correct-llvm-cross.patch
@@ -1,7 +1,7 @@
 Reason: rustc_codegen_llvm attempts to link against the host's llvm without this patch
---- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
-+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
-@@ -227,8 +227,8 @@
+--- rustc-1.36.0-src/src/librustc_llvm/build.rs
++++ rustc-1.36.0-src/src/librustc_llvm/build.rs
+@@ -224,8 +224,8 @@ fn main() {
              println!("cargo:rustc-link-search=native={}", &lib[9..]);
          } else if is_crossed {
              if lib.starts_with("-L") {
@@ -12,4 +12,3 @@ Reason: rustc_codegen_llvm attempts to link against the host's llvm without this
              }
          } else if lib.starts_with("-l") {
              println!("cargo:rustc-link-lib={}", &lib[2..]);
-
diff --git a/srcpkgs/rust/patches/use-elfv2-everywhere.patch b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
similarity index 85%
rename from srcpkgs/rust/patches/use-elfv2-everywhere.patch
rename to srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
index 200b0334525..84f8186f01a 100644
--- a/srcpkgs/rust/patches/use-elfv2-everywhere.patch
+++ b/srcpkgs/rust/patches/0093-use-elfv2-everywhere.patch
@@ -3,8 +3,8 @@ LLVM. While this is not perfect (it does not allow rustc to compile legacy
 binaries), rustc never requests specific ABI from llvm in the first place,
 so at least match the environment we have.
 
---- rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
-+++ rustc-1.35.0-src/src/librustc_target/abi/call/powerpc64.rs
+--- rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
++++ rustc-1.36.0-src/src/librustc_target/abi/call/powerpc64.rs
 @@ -124,7 +124,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
      where Ty: TyLayoutMethods<'a, C> + Copy,
            C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
@@ -14,8 +14,8 @@ so at least match the environment we have.
          ELFv2
      } else {
          match cx.data_layout().endian {
---- rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
-+++ rustc-1.35.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
+--- rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
++++ rustc-1.36.0-src/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
 @@ -1,4 +1,4 @@
 -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, RelroLevel};
 +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
diff --git a/srcpkgs/rust/patches/libunwind.patch b/srcpkgs/rust/patches/libunwind.patch
deleted file mode 100644
index fbc6b1c1cde..00000000000
--- a/srcpkgs/rust/patches/libunwind.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-we use libgcc_s for unwind, no need for libunwind.a
-https://github.com/void-linux/void-packages/issues/3605
---- rustc-1.35.0-src/src/libunwind/build.rs
-+++ rustc-1.35.0-src/src/libunwind/build.rs
-@@ -11,9 +11,7 @@ fn main() {
-         #[cfg(feature = "llvm-libunwind")]
-         llvm_libunwind::compile();
-     } else if target.contains("linux") {
--        if target.contains("musl") {
--            // musl is handled in lib.rs
--        } else if !target.contains("android") {
-+        if !target.contains("android") {
-             println!("cargo:rustc-link-lib=gcc_s");
-         }
-     } else if target.contains("freebsd") {
---- rustc-1.35.0-src/src/libunwind/lib.rs
-+++ rustc-1.35.0-src/src/libunwind/lib.rs
-@@ -24,8 +24,3 @@ cfg_if! {
-         pub use libunwind::*;
-     }
- }
--
--#[cfg(target_env = "musl")]
--#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
--#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
--extern {}
-
---- rustc-1.35.0-src/src/bootstrap/sanity.rs
-+++ rustc-1.35.0-src/src/bootstrap/sanity.rs
-@@ -171,34 +171,6 @@ pub fn check(build: &mut Build) {
-             }
-         }
- 
--        // Make sure musl-root is valid
--        if target.contains("musl") {
--            // If this is a native target (host is also musl) and no musl-root is given,
--            // fall back to the system toolchain in /usr before giving up
--            if build.musl_root(*target).is_none() && build.config.build == *target {
--                let target = build.config.target_config.entry(target.clone())
--                    .or_default();
--                target.musl_root = Some("/usr".into());
--            }
--            match build.musl_root(*target) {
--                Some(root) => {
--                    if fs::metadata(root.join("lib/libc.a")).is_err() {
--                        panic!("couldn't find libc.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                    if fs::metadata(root.join("lib/libunwind.a")).is_err() {
--                        panic!("couldn't find libunwind.a in musl dir: {}",
--                               root.join("lib").display());
--                    }
--                }
--                None => {
--                    panic!("when targeting MUSL either the rust.musl-root \
--                            option or the target.$TARGET.musl-root option must \
--                            be specified in config.toml")
--                }
--            }
--        }
--
-         if target.contains("msvc") {
-             // There are three builds of cmake on windows: MSVC, MinGW, and
-             // Cygwin. The Cygwin build does not have generators for Visual
diff --git a/srcpkgs/rust/patches/limit-internalization.patch b/srcpkgs/rust/patches/limit-internalization.patch
deleted file mode 100644
index c876df02cc8..00000000000
--- a/srcpkgs/rust/patches/limit-internalization.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From b4131e297e18fde119f6f461b3e622218166b009 Mon Sep 17 00:00:00 2001
-From: Josh Stone <jistone@redhat.com>
-Date: Fri, 26 Apr 2019 08:58:14 -0700
-Subject: [PATCH] Limit internalization in LLVM 8 ThinLTO
-
----
- src/rustllvm/PassWrapper.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
-index 319c66a21f17..0ebef82d3768 100644
---- a/src/rustllvm/PassWrapper.cpp
-+++ b/src/rustllvm/PassWrapper.cpp
-@@ -873,8 +873,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
-     return PrevailingType::Unknown;
-   };
- #if LLVM_VERSION_GE(8, 0)
-+  // We don't have a complete picture in our use of ThinLTO, just our immediate
-+  // crate, so we need `ImportEnabled = false` to limit internalization.
-+  // Otherwise, we sometimes lose `static` values -- see #60184.
-   computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
--                                  deadIsPrevailing, /* ImportEnabled = */ true);
-+                                  deadIsPrevailing, /* ImportEnabled = */ false);
- #else
-   computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
- #endif
-
diff --git a/srcpkgs/rust/patches/link-musl-dynamically.patch b/srcpkgs/rust/patches/link-musl-dynamically.patch
deleted file mode 100644
index 94c9e2ad20d..00000000000
--- a/srcpkgs/rust/patches/link-musl-dynamically.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
-     let libdir = builder.sysroot_libdir(*compiler, target);
- 
--    // Copies the crt(1,i,n).o startup objects
--    //
--    // Since musl supports fully static linking, we can cross link for it even
--    // with a glibc-targeting toolchain, given we have the appropriate startup
--    // files. As those shipped with glibc won't work, copy the ones provided by
--    // musl so we have them on linux-gnu hosts.
--    if target.contains("musl") {
--        for &obj in &["crt1.o", "crti.o", "crtn.o"] {
--            builder.copy(
--                &builder.musl_root(target).unwrap().join("lib").join(obj),
--                &libdir.join(obj),
--            );
--        }
--    } else if target.ends_with("-wasi") {
-+    if target.ends_with("-wasi") {
-         for &obj in &["crt1.o"] {
-             builder.copy(
-                 &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
-     } else if #[cfg(feature = "use_std")] {
-         // cargo build, don't pull in anything extra as the libstd dep
-         // already pulls in all libs.
--    } else if #[cfg(target_env = "musl")] {
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", kind = "static",
--                        cfg(target_feature = "crt-static")))]
--        #[cfg_attr(feature = "rustc-dep-of-std",
--                   link(name = "c", cfg(not(target_feature = "crt-static"))))]
--        extern {}
-     } else if #[cfg(target_os = "emscripten")] {
-         #[link(name = "c")]
-         extern {}
diff --git a/srcpkgs/rust/template b/srcpkgs/rust/template
index 44933d5cfce..45ad7d98411 100644
--- a/srcpkgs/rust/template
+++ b/srcpkgs/rust/template
@@ -1,15 +1,14 @@
 # Template file for 'rust'
+# partially adapted from Alpine/Adélie's Rust APKBUILD
 pkgname=rust
-version=1.35.0
-revision=2
-_rust_dist_version=1.35.0
-_cargo_dist_version=0.36.0
+version=1.36.0
+revision=1
+_rust_dist_version=1.36.0
+_cargo_dist_version=0.37.0
 # Always make sure custom distfiles used for bootstrap are
 # uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
 wrksrc="rustc-${version}-src"
-build_style=configure
-make_build_args="dist VERBOSE=1"
-hostmakedepends="cmake curl pkg-config python"
+hostmakedepends="cmake curl pkg-config python3"
 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
 depends="rust-std"
 short_desc="Safe, concurrent, practical systems language"
@@ -17,119 +16,101 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://www.rust-lang.org/"
 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
-checksum=5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d
+checksum=04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b
 lib32disabled=yes
 patch_args="-Np1"
 
 build_options="static_llvm"
 
+_bootstrap_dir="stage0-bootstrap"
+
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo llvm"
 	# These are required for building the buildhost's stage0/1
 	hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 961df84a116c7b1b11eb912d33c8edb233b76980f97983f9ed3989621f9f90c3
-		 3574e0d43b2746ea0cb9f8084670699f5cb920cee646026cec1da152818c51ba
-		 0466ed241c44d137ee65aa7dbba8fc1cc94e56b252c323c387523b5cb430210e"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e
-		 5dfa92661ff1a22680785bd6999b6117ae66841e2bd9e5318eb97002956131e4
-		 ab5a6ff1947463dbd2477ca5dac2012494dae821112098ae0c54add652adfdc3"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 b05ca05cfb6f106f92283bb06158845f29abb3c1145a8dc306d2aa210f42d106
-		 ab41c886af02a16a9a38780043d7f3da24c637629afa222b38f616fe6de86402
-		 4c1521691a22e24e40aac18e75ea95957477284adda9ad79df64d56861aec610"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 fd7709e00ff49d8e388f52c92a386cef075897b4363e76bec1c850d8d5d67145
-		 b09fe43521f1e50d4b40eb8b4803a5d49dc9c5447eb0ef4da1ab723c093877ba
-		 46419ba92849bcf8f4970ae042c333c1d82c1e18fda0531a745f88baee0e7f22"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 1e2831db0a45c3e3bd44f375678a1738407cf8f7d44af9fd3444248bc1b5d574
-		 0bf05a5d0521dec481d67ea3a74626e884fd18f8215b774ba89d818bbdb3d8c0
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-gnu.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 7ba9b81bdc3bda8e0945d37424c5a47364961f90c4765d5223afe8c7ae865d78
-		 abb807fbb6c3ca86f9f05014581b84a8105e2fc4ecdac33817093ba6fdb5c613
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 fa843921197f51a9c5042528789531daef0e89b7b861cf94116d079bbfc2a523
-		 01145b57d2e11ca7bd06dd57a8582ac5d34c683a9cd827920f2489dbdbc51539
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc-unknown-linux-gnu.tar.xz
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 194ae7493942b5b291870c5857a1e3126b95b6f3b028d5cbfe997f10875a78c4
-		 901b169e011b6d2f675939c014165330756acd5bf2233c4c770229712cd9f19e
-		 42b997dc8b562241d563993b11c070394cf48ced55c6cf86c387d0a15ff0847e"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc-unknown-linux-musl.tar.xz
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 163dfdeaeda1237a37c59b436d0288529da3277098286d7d92aa577a3e658433
-		 e47a378ddd4d54520c2ae1a8aba74ec2933ce33a5ce30687ef14ef0303085207
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
+	# checksums must be specified per arch
+	case "$XBPS_MACHINE" in
+		i686)
+			checksum+="
+			 ad86a75cc8a02a0129df480ccb28082985215f4b5558a42881777691ae1d3ff3
+			 a78f7bdbce0a960f3334c6c639cbe96f05b9b74df26cda9a5161834098119217
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 fff0158da6f5af2a89936dc3e0c361077c06c2983eb310615e02f81ebbde1416
+			 ce8e12684b568a8a4f7d346a743383429849cf3f028f5712ad3d3e31590c8db3
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 04c15e34bdfd17136b924baa4f93cfbfe64739964b57f5a13ada8e91f9239076
+			 70d0cc38cc829603c81812c59435ef85456a93962bea20deb12f0634e87fbaf7
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 702818334ed9f01f60a433aa424784ec9b3785826cdaf03b0f69d03aded98df6
+			 db7a9a06b8b1b84d6fe10bc1e2e136234e31bfaa77499b9df36e2d441ef1b856
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 e04239f9c0f230249412ca814f2f954e269c9724fe5741d87f6dc76ddaa15251
+			 98e8b4e6335bdb8cd387c8681686e20d9aa230bcf16ba0ea7cf3c1818d964425
+			 d2690135522db9fdc6efa2f432e5719b8b70abc94e91db278b84be834a75bf72"
+			;;
+		ppc64)
+			checksum+="
+			 4328cd52d37df39b78c6223a7a6d07129ef9861efa67dbdadbcfe6c991e0febf
+			 800f27805adef749219f9507497dbadebdac2d5c50f951ca1426d4d447e7f318
+			 8b2f7d5da611a21dd7e0b4238b9aca6ee32f1e49d8fe831435301f11a29b12de"
+			;;
+		ppc64-musl)
+			checksum+="
+			 7cef3f67652607e4f6ed09ff6eb54ee0a7485ae5491a2c015ef9357aadc40295
+			 6f2dc455113a12b2f5fcefbda6e225ad568e750b8f900de5d326cf2c05e45ec9
+			 131db0127366665b2ae55327155c171e99c2eddfb4bcdd7e5cd2663ada109bd5"
+			;;
+		ppc)
+			checksum+="
+			 6c47ae44afc4567fd5584ff8f23c6d0ee1680e66b2ce91cc891571e973097a99
+			 b22c7104c1bea83aef920140a25be974c3e08dd600431901346908916be46f43
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 181c81346bc75d6316d08efa242f49c3d3e70fa0c480e673c9bc7209c63ca6e6
+			 4449b886359efe7fb39d75a086fc25520730f96932588e120abbf04387ac8aad
+			 119dba3538f6c1d1164b720b238acac598e1924d943ebbdf3c7113ec3cbd8a2a"
+			;;
 	esac
 fi
 
 post_extract() {
 	if [ -z "$CROSS_BUILD" ]; then
-		mkdir -p stage0
-		rm ../rustc-*/rustc/manifest.in
-		cp -bflr ../rustc-*/rustc/* stage0
-		rm ../rust-std-*/rust-std-*/manifest.in
-		cp -bflr ../rust-std-*/rust-std-*/* stage0
-		cp -bflr ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo stage0/bin
+		mkdir -p "${wrksrc}/${_bootstrap_dir}"
+		../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
+		 --destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
+		# cargo may not be packaged like the rest
+		cp ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
+		 "${wrksrc}/${_bootstrap_dir}/bin"
 	fi
 }
 
@@ -149,85 +130,131 @@ post_patch() {
 		done
 	fi
 
-	sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
-
 	# clear out all the checksum nonsense of patched vendor crates
 	_clear_vendor_checksums libc
 	_clear_vendor_checksums lzma-sys
+	_clear_vendor_checksums typenum
+	_clear_vendor_checksums backtrace-sys
 }
 
 do_configure() {
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-
-	configure_args="
-		--prefix=/usr
-		--host=${RUST_TARGET}
-		--target=${RUST_TARGET}
-		--build=${RUST_BUILD}
-		--disable-full-bootstrap
-		--release-channel=stable
-		--disable-rpath
-		--disable-docs
-		--disable-codegen-tests
-		--enable-vendor
-		--llvm-root=/usr
-		--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
-		--set=target.${RUST_TARGET}.crt-static=false
-	"
+	local _rust_root _local_rebuild _use_debug _use_rpath
 
-	if [ ! "$build_option_static_llvm" ]; then
-		configure_args+="
-			--enable-llvm-link-shared
-		"
+	if [ "$CROSS_BUILD" ]; then
+		_rust_root="/usr"
+		_local_rebuild="true"
+	else
+		_rust_root="${wrksrc}/${_bootstrap_dir}"
+		_local_rebuild="false"
 	fi
 
-	if [ "$CROSS_BUILD" ]; then
-		configure_args+="
-			--local-rust-root=/usr
-			--enable-local-rebuild
-		"
-
-		# Set the appropriate values for the native compilation tools
-		configure_args+="
-			--set=target.${RUST_BUILD}.cc=${CC_host}
-			--set=target.${RUST_BUILD}.cxx=${CXX_host}
-			--set=target.${RUST_BUILD}.ar=${AR_host}
-			--set=target.${RUST_BUILD}.linker=${CC_host}
-		"
+	# emit debug info, enabled when generating debug packages
+	if [ -n "$XBPS_DEBUG_PKGS" ]; then
+		_use_debug="true"
 	else
-		configure_args+=" --local-rust-root=$wrksrc/stage0"
+		_use_debug="false"
 	fi
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
-		;;
-	esac
+	# if true, the binaries will be built with rpath, so the binaries will be
+	# usable directly from the build directory, this is not desirable for
+	# packaging but is useful when building bootstrap binaries
+	_use_rpath="false"
 
-	./configure $configure_args
-}
+	cat > config.toml <<- EOF
+		[build]
+		build = "${RUST_BUILD}"
+		host = [ "${RUST_TARGET}" ]
+		target = [ "${RUST_TARGET}" ]
+		cargo = "${_rust_root}/bin/cargo"
+		rustc = "${_rust_root}/bin/rustc"
+		submodules = false
+		python = "python3"
+		locked-deps = true
+		vendor = true
+		full-bootstrap = false
+		local-rebuild = ${_local_rebuild}
+		extended = false
+		docs = false
+		tools = []
+		[install]
+		prefix = "/usr"
+		[rust]
+		codegen-units = 1
+		debuginfo = ${_use_debug}
+		debuginfo-lines = ${_use_debug}
+		debuginfo-only-std = ${_use_debug}
+		debuginfo-tools = ${_use_debug}
+		backtrace = true
+		channel = "stable"
+		rpath = ${_use_rpath}
+		jemalloc = false
+		codegen-tests = false
+		[target.${RUST_BUILD}]
+		llvm-config = "/usr/bin/llvm-config"
+		crt-static = false
+		cc = "${CC_host:-$CC}"
+		cxx = "${CXX_host:-$CXX}"
+		ar = "${AR_host:-$AR}"
+		linker = "${CC_host:-$CC}"
+	EOF
 
-pre_build() {
-	export CARGO_HOME="$wrksrc/.cargo"
-	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-	export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
-	export PATH="$wrksrc/stage0/bin:$PATH"
-	export MUSL_ROOT=/usr
-	export RUST_BACKTRACE=1
-	export RUSTFLAGS="-C linker=${CC}"
+	if [ "$CROSS_BUILD" ]; then
+		cat >> config.toml <<- EOF
+			[target.${RUST_TARGET}]
+			llvm-config = "/usr/bin/llvm-config"
+			crt-static = false
+			cc = "${CC}"
+			cxx = "${CXX}"
+			ar = "${AR}"
+			linker = "${CC}"
+		EOF
+	fi
 }
 
 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
 # of the cross host.
 do_build() {
-	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
+	if [ ! "$build_option_static_llvm" ]; then
+		export LLVM_LINK_SHARED=1
+	fi
+	export RUST_BACKTRACE=1
+	export CARGO_HOME="$wrksrc/.cargo"
+	export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
+	# prevent sysroot from leaking in
+	export RUSTFLAGS=""
+
+	env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
+	 python3 x.py dist --jobs $XBPS_MAKEJOBS
+}
+
+do_check() {
+	export RUST_BACKTRACE=1
+
+	python3 x.py test ${makejobs} --no-doc --no-fail-fast \
+		src/test/codegen \
+		src/test/codegen-units \
+		src/test/compile-fail \
+		src/test/incremental \
+		src/test/mir-opt \
+		src/test/pretty \
+		src/test/run-fail \
+		src/test/run-fail/pretty \
+		src/test/run-make \
+		src/test/run-make-fulldeps \
+		src/test/run-pass \
+		src/test/run-pass/pretty \
+		src/test/run-pass-fulldeps \
+		src/test/run-pass-fulldeps/pretty \
+		src/test/ui \
+		src/test/ui-fulldeps
 }
 
 do_install() {
 	vmkdir usr
-	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
-	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
+	tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
+	tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
+	 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
 
 	vlicense COPYRIGHT
 	vlicense LICENSE-APACHE

From ba006ce061c92788fc613bc31aa6a6a1e977636c Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sun, 7 Jul 2019 18:04:41 +0200
Subject: [PATCH 2/2] cargo: update to 0.37.0

[ci skip]
---
 srcpkgs/cargo/template | 112 +++++++++++++++++++----------------------
 1 file changed, 53 insertions(+), 59 deletions(-)

diff --git a/srcpkgs/cargo/template b/srcpkgs/cargo/template
index 4acc541fd6a..a0bca421f61 100644
--- a/srcpkgs/cargo/template
+++ b/srcpkgs/cargo/template
@@ -1,7 +1,7 @@
 # Template file for 'cargo'
 pkgname=cargo
-version=0.36.0
-revision=3
+version=0.37.0
+revision=1
 build_helper=rust
 hostmakedepends="rust python curl cmake pkg-config"
 makedepends="libcurl-devel libgit2-devel"
@@ -11,69 +11,62 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT, Apache-2.0"
 homepage="https://crates.io/"
 distfiles="https://github.com/rust-lang/cargo/archive/${version}.tar.gz"
-checksum=532a39ce9acc1436c5d33ce0643d050bc29183c46abe69934622c4f24f4c6831
-_cargo_dist_version=0.36.0
+checksum=377e1090e9ce21206270576193746499a26e8ffbd8b89ccd5f8eb1085ca00e3b
+_cargo_dist_version=0.37.0
 build_options="static"
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" cargo"
 	makedepends+=" rust"
 else
+	_bootstrap_url="https://static.rust-lang.org/dist"
+
+	case "$XBPS_MACHINE" in
+		x86_64*|i686|ppc64le|ppc) ;;
+		ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
+		*) broken="unsupported host: ${XBPS_MACHINE}" ;;
+	esac
+
+	distfiles+="
+	 ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
+
 	case "$XBPS_MACHINE" in
-	x86_64-musl)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.gz"
-		checksum+="
-		 7a84d006688ffe9e292db59690e7fc99616d6d1a6d981affb93d121fca9e8bb5"
-		;;
-	x86_64)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 77586f2fb5b6f6caef0cb6d3cc32a18559d4fcd6a6db4e75f4b3fb7adb050437"
-		;;
-	i686)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 6ef32560bfa7c85dee6ef932a5e35994457f3e05e2cf8979c19971b8a5b805e4"
-		;;
-	ppc64le)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 d196e4e506c89653c533e34c77fb5be7928a1667bca64a3fd866dd0d1aecfc6d"
-		;;
-	ppc64le-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
-		checksum+="
-		 9347f6c8b391e0142cda60988690f7bc9a877f8012ea2e71c35343a4cb9b7ee4"
-		;;
-	ppc64)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-gnu.tar.xz"
-		checksum+="
-		 512c69762fe2a18b6d9781186e77f76333f7ac179e76135cb85ba19e703afaca"
-		;;
-	ppc64-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
-		checksum+="
-		 9b8cdacbb4859addfe63cf8ea1df9eb32343e25a18bef2a6422f990728d0e78a"
-		;;
-	ppc)
-		distfiles+="
-		 https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-powerpc-unknown-linux-gnu.tar.gz"
-		checksum+="
-		 821b4acd67c438b533436e1a57d11e9e267f6641493c9d49650ace657f59e106"
-		;;
-	ppc-musl)
-		distfiles+="
-		 https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc-unknown-linux-musl.tar.xz"
-		checksum+="
-		 eee6637b48d9bbf6375a2de75e36b8670fae26d8da9c53a9890380b9a29d0bcf"
-		;;
+		i686)
+			checksum+="
+			 6835a73e2ce17e11eda5393133dd7c78bc41bae5a09784e5327648f14340fd48"
+			;;
+		x86_64)
+			checksum+="
+			 d20fa121951339d5492cf8862f8a7af59efc99d18f3c27b95ab6d4658b6a7d67"
+			;;
+		x86_64-musl)
+			checksum+="
+			 53975d91e11569f2255d8e30176f05f6976cd810725197a527b0e7ad547ca70c"
+			;;
+		ppc64le)
+			checksum+="
+			 4cda7686160f6981e936229703e8e2e756c74f390245f2ad9e356bbbed28a2c9"
+			;;
+		ppc64le-musl)
+			checksum+="
+			 d2690135522db9fdc6efa2f432e5719b8b70abc94e91db278b84be834a75bf72"
+			;;
+		ppc64)
+			checksum+="
+			 8b2f7d5da611a21dd7e0b4238b9aca6ee32f1e49d8fe831435301f11a29b12de"
+			;;
+		ppc64-musl)
+			checksum+="
+			 131db0127366665b2ae55327155c171e99c2eddfb4bcdd7e5cd2663ada109bd5"
+			;;
+		ppc)
+			checksum+="
+			 856fcb63f6ebeab67038fe3fc96ee0911353b1ee19cabcb0496c7d419de0d531"
+			;;
+		ppc-musl)
+			checksum+="
+			 119dba3538f6c1d1164b720b238acac598e1924d943ebbdf3c7113ec3cbd8a2a"
+			;;
 	esac
 fi
 
@@ -114,7 +107,8 @@ do_install() {
 	for f in src/etc/man/*.?; do
 		vman $f
 	done
-	vinstall src/etc/cargo.bashcomp.sh 0644 usr/share/bash-completion/completions cargo
+	vinstall src/etc/cargo.bashcomp.sh 0644 \
+	 usr/share/bash-completion/completions cargo
 	vinstall src/etc/_cargo 0644 usr/share/zsh/site-functions
 
 	vlicense LICENSE-APACHE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (13 preceding siblings ...)
  2019-07-07 16:10 ` voidlinux-github
@ 2019-07-07 16:10 ` voidlinux-github
  2019-07-07 16:10 ` voidlinux-github
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 16:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/12843#issuecomment-509011852
Comment:
@Gottox updated distfiles to upload at https://void-power.octaforge.org/distfiles/

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (14 preceding siblings ...)
  2019-07-07 16:10 ` voidlinux-github
@ 2019-07-07 16:10 ` voidlinux-github
  2019-07-07 17:31 ` voidlinux-github
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 16:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/12843#issuecomment-509011863
Comment:
Also added cargo update.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [WIP] rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (15 preceding siblings ...)
  2019-07-07 16:10 ` voidlinux-github
@ 2019-07-07 17:31 ` voidlinux-github
  2019-07-09 19:33 ` voidlinux-github
  2019-07-09 19:54 ` [PR PATCH] [Closed]: " voidlinux-github
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-07 17:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

New comment by Gottox on void-packages repository

https://github.com/void-linux/void-packages/pull/12843#issuecomment-509017245
Comment:
Done

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (16 preceding siblings ...)
  2019-07-07 17:31 ` voidlinux-github
@ 2019-07-09 19:33 ` voidlinux-github
  2019-07-09 19:54 ` [PR PATCH] [Closed]: " voidlinux-github
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-09 19:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

New comment by jnbr on void-packages repository

https://github.com/void-linux/void-packages/pull/12843#issuecomment-509777164
Comment:
merged: 432783a249e9a8d27164b9da9f911b095893098e

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PR PATCH] [Closed]: rust: update to 1.36.0
  2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
                   ` (17 preceding siblings ...)
  2019-07-09 19:33 ` voidlinux-github
@ 2019-07-09 19:54 ` voidlinux-github
  18 siblings, 0 replies; 20+ messages in thread
From: voidlinux-github @ 2019-07-09 19:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 720 bytes --]

There's a closed pull request on the void-packages repository

rust: update to 1.36.0
https://github.com/void-linux/void-packages/pull/12843
Description: This brings in a batch of template changes, including:

- We are now using python3
- Cleaned up distfiles fetching section (clearer, shorter)
- Binary distfiles now use standard install.sh scripts
- Imported various patches from Adélie Linux
- We are now using config.toml instead of configure
- Other assorted changes

TODO:

- [x] test crosscompiling
- [x] generate bootstrap binaries for stuff rust doesn't ship
- [x] get the binaries uploaded and update their checksums
- [x] test on more archs (pending @jnbr)
- [x] test firefox, etc

@jnbr

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-07-09 19:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-06 16:19 [PR PATCH] [WIP] rust: update to 1.36.0 voidlinux-github
2019-07-06 16:20 ` [PR PATCH] [Updated] " voidlinux-github
2019-07-06 16:20 ` voidlinux-github
2019-07-06 21:53 ` voidlinux-github
2019-07-06 21:53 ` voidlinux-github
2019-07-06 21:53 ` voidlinux-github
2019-07-06 21:53 ` voidlinux-github
2019-07-07  3:03 ` voidlinux-github
2019-07-07  3:03 ` voidlinux-github
2019-07-07 12:16 ` voidlinux-github
2019-07-07 12:16 ` voidlinux-github
2019-07-07 12:19 ` voidlinux-github
2019-07-07 12:19 ` voidlinux-github
2019-07-07 16:10 ` voidlinux-github
2019-07-07 16:10 ` voidlinux-github
2019-07-07 16:10 ` voidlinux-github
2019-07-07 16:10 ` voidlinux-github
2019-07-07 17:31 ` voidlinux-github
2019-07-09 19:33 ` voidlinux-github
2019-07-09 19:54 ` [PR PATCH] [Closed]: " voidlinux-github

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).