commit:     79829bb772f3a7fe32784745b72f2e956d2bfe95
Author:     Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Wed Jan 24 22:06:55 2018 +0000
Commit:     Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Wed Jan 24 22:06:55 2018 +0000
URL:        https://gitweb.gentoo.org/proj/musl.git/commit/?id=79829bb7

dev-lang/rust: version bump to 1.23.0

yet another hybrid ebuild between ::gentoo and ::smauel

 dev-lang/rust/Manifest                             |   9 +
 ...tic-native-libraries-when-linking-static-.patch |  44 +++
 ...-nostdlib-and-musl_root-from-musl-targets.patch | 408 +++++++++++++++++++++
 ...sl-targets-to-link-dynamically-by-default.patch |  25 ++
 ...-Prefer-libgcc_eh-over-libunwind-for-musl.patch |  24 ++
 dev-lang/rust/files/0005-Fix-LLVM-build.patch      |  26 ++
 .../files/0006-Fix-rustdoc-for-cross-targets.patch |  36 ++
 ...dd-openssl-configuration-for-musl-targets.patch |  41 +++
 .../0008-Don-t-pass-CFLAGS-to-the-C-compiler.patch |  36 ++
 dev-lang/rust/metadata.xml                         |   3 +-
 dev-lang/rust/rust-1.23.0.ebuild                   | 247 +++++++++++++
 11 files changed, 898 insertions(+), 1 deletion(-)

diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest
index ef6f419..71e99e1 100644
--- a/dev-lang/rust/Manifest
+++ b/dev-lang/rust/Manifest
@@ -6,4 +6,13 @@ DIST rust-1.20.0-i686-unknown-linux-gnu.tar.xz 64411000 
BLAKE2B bc5aaece728f2d58
 DIST rust-1.20.0-i686-unknown-linux-musl.tar.xz 59060784 BLAKE2B 
5633d0e86e7d47ebdd7fb6e324193221fc33320480e310102faa8d6b113fcbd0f2b21f7e071bd8f320cc4678fcd3c09bf64315f746dbb5775480d65b021c4c87
 SHA512 
602fc7c656e9c44c8a2b591a276bb68624862d6b1e48746ad4e04d11d33198b7c07b3266b1a0c551c2ae03137cb185593ed077126f57ff3a1c6059ec0dae5c2f
 DIST rust-1.20.0-x86_64-unknown-linux-gnu.tar.xz 68410500 BLAKE2B 
777bf0c248f86da0eb75bd38f1069652b1637692ed4d96921b8c3d62a2711cae60586f23ba4f0c48f5a42678fd77629b8dc3a27c7141d5fe8653ad3891943e8b
 SHA512 
5e397b1d3f7ef2ef7f11a7d48ad309f17220751246d5bf3e7301cca1c1a81864be49a7b78e122bb3bc66938971b73c8db443ba9e969880544e61af4061a5d96e
 DIST rust-1.20.0-x86_64-unknown-linux-musl.tar.xz 56417968 BLAKE2B 
12b5b32226f944672e3ce535cb046e627e7781840f8680193b1aa10746f03e8e1efe43bd3ca2abfc65daabeac93eef10b3b9107cbaa4e04eb2824cbc26eeaefa
 SHA512 
32f9e36b84606879a91b802a8f73502fbc4f3079177b13d3c0fbe4a784745526e0eab2ba93ae2f0c38042c8fe434370774080223c7fa3d839cb4666c3f26c0b1
+DIST rust-1.23.0-arm-unknown-linux-gnueabi.tar.xz 76055908 BLAKE2B 
bf4cdb7e270bf6589c03f0fea3e1280b01b575179bb38b6f0f4058df3adf1576aafb91be09b9971f5c7b071ecd0aa4793505f2cdbe7bd426aec11f74fc793afa
 SHA512 
8701d72cdbb5ffc1bd5cb279be493bb31ce5741a139185f2976939c84eccd950ac976c23a8d622e5a58c5511f94b775b99c82f697a30896fadf790a7aab844c4
+DIST rust-1.23.0-arm-unknown-linux-musleabi.tar.xz 73839144 BLAKE2B 
d4bb7dd08c57375daa8b39a10bae42109863d37321e5ecfc284b13b09e1dd2cb09265ba130b5e698fc5862c7b80237f5d7e8057e286c806aa41545ef3507b111
 SHA512 
a4dc1df817d700954897b2476e794923cb9ff9c2e1c5b1b18ee41f02d8ba1161c136183ee7d8487364bb2e82a3cfdb119f28828f40a4cac8c417c73f71d26b5a
+DIST rust-1.23.0-armv7-unknown-linux-gnueabihf.tar.xz 76508532 BLAKE2B 
5c42972bdf9da7fdf6eee7389a4604290249e8077523e1eb50175453672c24766f4e4a6e0c2ab17a60a233ed4059758a791c02da905680498ec3bd3986221796
 SHA512 
2ef07187d78060005e99676cf1f168e7a8861e9f104c95056cfe8784a7fa35b14f0b69ba4adc8be4173ef8d4ce7554f92487385a09602343ab65fcf749fbe35c
+DIST rust-1.23.0-armv7-unknown-linux-musleabihf.tar.xz 73651660 BLAKE2B 
bf710fb93c1d7756a00fbc33991b15e6a6ada4d5bc10bb0fc3370fafe9cdb41c65efec6d6f15a53d6a77c543234efaad069c4579fa29d65e206126e173f3961d
 SHA512 
e5493ba5867dfcdd545b866342c066a719252e0edf2f84122ec2bea425ab6126eab3ecd168c0e07b6e8b3244e62db77a3ee230a9181bbc2eac5e2122305e53a5
+DIST rust-1.23.0-i686-unknown-linux-gnu.tar.xz 79540368 BLAKE2B 
5df0fb0fa904e7daa871968c752bc8ac0375eed67c76129a188bc5bd663b18c6735e5118e283109a5581f948ccaa52ab7a88e7ebc1d6b4f6fdf5e24a48ac0c58
 SHA512 
6863a512100ae0369d0a5c4242d45fda9b83a2ad6c3e6691f4f0d1e071dca7003c55873cc03a9d09305adae24667e654bda66a8ad3246f4df2d7a2fc0fc4d7a7
+DIST rust-1.23.0-i686-unknown-linux-musl.tar.xz 77706812 BLAKE2B 
d30d4359c94ce8c44a2654e9a41a8fcb5d98d330d46e6e0a98500745895f8ded97a8395970c278078b325648d6ee13af7b538a58b41a6d3b027533a40e270767
 SHA512 
2127391e224c5a286fdadfd46125373b13a406833634c990f94f256fa0dbf6cdf2536b93206332b1ca2c55c893c2cfbc735e96a6c1439fddf8bba87359cab313
+DIST rust-1.23.0-x86_64-unknown-linux-gnu.tar.xz 82693116 BLAKE2B 
e327f7b97f7c359f88b4f5a678d8c110c9b50183c96bc8efe767114c83bffcf86a6632d22e9148c48ce97687393f5d5cb5439d66c0ee53853f007b2f730881f0
 SHA512 
a5a3aa11d04e81305d33ed50fe657dcebb8c3a1f71a0a2b54372439ff6b1b4b7d2abd9c579b27950be67921cbb41586346824faf71495fb4f3f505ed8a48ccc9
+DIST rust-1.23.0-x86_64-unknown-linux-musl.tar.xz 74604492 BLAKE2B 
6ba1c3e850f4dd3202c0a24fdc13ebce588152eaf61054d5a2f0ed8fffc4ef66a7507400dbb5156b3422cd45e6cbe6bf73a2a21e35bf0df93acf1dceed3c04c7
 SHA512 
3d3e864691c74c94b79e459ec47f3d4e2f7d2bb1cecb20f7469ac09bf8e0385a8803848c66c5834c1e95bf2888bed883deff236da4fa3c6d854099f57d2e3998
 DIST rustc-1.21.0-src.tar.xz 34212448 BLAKE2B 
608fa85f4391f3f15db2d1b6f88df8f6811ba460d727c2ed366972f884dd3856711ed50ab0320d939885004d72a8d604be0aa8a65e6d61bd2e1ce33b5aee01be
 SHA512 
63b5c247ef7028c59bb246b96cb9917476d6d13cf68b37956e290248a1e53de3e4dbfad1dcae3c5c2cacc73c9dd212c50e45902c7d913fadeaac81db630bc951
+DIST rustc-1.23.0-src.tar.xz 38490016 BLAKE2B 
85baeb5535cb95f7d4ceff71580d59d5ce3a5b13adaa067ffbfc7db26e947d1c0b939dad4846c279cc8d174cbf61bd331b9298236ce03630cedffcd6cc8a4e8c
 SHA512 
2e605121dd5152c1a898b263d634b0ac55c7ea79c7fbc9f72c432e68fb397618a267283f3dfb0f77d5e189720d788b1937e8114a1f71bdb10ddd4cbaae92fa80

diff --git 
a/dev-lang/rust/files/0001-Require-static-native-libraries-when-linking-static-.patch
 
b/dev-lang/rust/files/0001-Require-static-native-libraries-when-linking-static-.patch
new file mode 100644
index 0000000..8175c4c
--- /dev/null
+++ 
b/dev-lang/rust/files/0001-Require-static-native-libraries-when-linking-static-.patch
@@ -0,0 +1,44 @@
+From abd07ed6ab514ef00d450640a659861af06f308e Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 1/8] Require static native libraries when linking static
+ executables
+
+---
+ src/librustc_trans/back/link.rs | 13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
+index e0eef1f576..e46b25f987 100644
+--- a/src/librustc_trans/back/link.rs
++++ b/src/librustc_trans/back/link.rs
+@@ -1302,8 +1302,8 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
+     }
+ }
+ 
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
++// Link in all of our upstream crates' native dependencies. Remember that when
++// linking libraries, these upstream native dependencies are all non-static
+ // dependencies. We've got two cases then:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+@@ -1343,7 +1343,14 @@ fn add_upstream_native_libraries(cmd: &mut Linker,
+                 continue
+             }
+             match lib.kind {
+-                NativeLibraryKind::NativeUnknown => 
cmd.link_dylib(&lib.name.as_str()),
++                NativeLibraryKind::NativeUnknown => {
++                    // When creating executables, match library linkage to 
that of the executable.
++                    if crate_type == config::CrateTypeExecutable && 
sess.crt_static() {
++                        cmd.link_staticlib(&lib.name.as_str())
++                    } else {
++                        cmd.link_dylib(&lib.name.as_str())
++                    }
++                },
+                 NativeLibraryKind::NativeFramework => 
cmd.link_framework(&lib.name.as_str()),
+                 NativeLibraryKind::NativeStaticNobundle => {
+                     // Link "static-nobundle" native libs only if the crate 
they originate from
+-- 
+2.13.6
+

diff --git 
a/dev-lang/rust/files/0002-Remove-nostdlib-and-musl_root-from-musl-targets.patch
 
b/dev-lang/rust/files/0002-Remove-nostdlib-and-musl_root-from-musl-targets.patch
new file mode 100644
index 0000000..4c99e42
--- /dev/null
+++ 
b/dev-lang/rust/files/0002-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -0,0 +1,408 @@
+From 3f14fcbb1dc6a11ed82724d6c006325243122bfb Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Fri, 8 Sep 2017 22:11:14 -0500
+Subject: [PATCH 2/8] 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                         | 31 ------------------------
+ src/bootstrap/config.rs                          |  7 ------
+ src/bootstrap/configure.py                       | 14 -----------
+ src/bootstrap/lib.rs                             |  8 ------
+ src/bootstrap/sanity.rs                          | 29 ----------------------
+ src/ci/docker/cross/Dockerfile                   |  6 +----
+ src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile |  1 -
+ src/ci/docker/dist-x86_64-musl/Dockerfile        |  1 -
+ src/librustc_back/target/linux_musl_base.rs      | 15 ------------
+ 12 files changed, 4 insertions(+), 151 deletions(-)
+
+diff --git a/config.toml.example b/config.toml.example
+index df0142b8d4..9cb6fc5c9e 100644
+--- a/config.toml.example
++++ b/config.toml.example
+@@ -348,12 +348,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 = "..."
+-
+ # Used in testing for configuring where the QEMU images are located, you
+ # probably don't want to use this.
+ #qemu-rootfs = "..."
+diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
+index 16a23eb364..84b68dd9f4 100644
+--- a/src/bootstrap/bin/rustc.rs
++++ b/src/bootstrap/bin/rustc.rs
+@@ -30,7 +30,6 @@
+ extern crate bootstrap;
+ 
+ use std::env;
+-use std::ffi::OsString;
+ use std::str::FromStr;
+ use std::path::PathBuf;
+ use std::process::{Command, ExitStatus};
+@@ -111,15 +110,6 @@ fn main() {
+             cmd.arg("-Cprefer-dynamic");
+         }
+ 
+-        // Help the libc crate compile by assisting it in finding the MUSL
+-        // native libraries.
+-        if let Some(s) = env::var_os("MUSL_ROOT") {
+-            let mut root = OsString::from("native=");
+-            root.push(&s);
+-            root.push("/lib");
+-            cmd.arg("-L").arg(&root);
+-        }
+-
+         // Override linker if necessary.
+         if let Ok(target_linker) = env::var("RUSTC_TARGET_LINKER") {
+             cmd.arg(format!("-Clinker={}", target_linker));
+diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
+index e531fdaf29..3f49a2cfec 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();
+@@ -112,7 +112,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()));
+@@ -123,8 +123,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
+@@ -161,26 +160,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 db013691bb..9e9badab9b 100644
+--- a/src/bootstrap/compile.rs
++++ b/src/bootstrap/compile.rs
+@@ -78,13 +78,6 @@ impl Step for Std {
+             });
+             println!("Uplifting stage1 std ({} -> {})", from.host, target);
+ 
+-            // Even if we're not building std this stage, the new sysroot must
+-            // still contain the musl startup objects.
+-            if target.contains("musl") && !target.contains("mips") {
+-                let libdir = builder.sysroot_libdir(compiler, target);
+-                copy_musl_third_party_objects(build, target, &libdir);
+-            }
+-
+             builder.ensure(StdLink {
+                 compiler: from,
+                 target_compiler: compiler,
+@@ -97,11 +90,6 @@ impl Step for Std {
+         println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
+                 &compiler.host, target);
+ 
+-        if target.contains("musl") && !target.contains("mips") {
+-            let libdir = builder.sysroot_libdir(compiler, target);
+-            copy_musl_third_party_objects(build, target, &libdir);
+-        }
+-
+         let out_dir = build.stage_out(compiler, Mode::Libstd);
+         build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
+         let mut cargo = builder.cargo(compiler, Mode::Libstd, target, 
"build");
+@@ -118,20 +106,6 @@ impl Step for Std {
+     }
+ }
+ 
+-/// 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.
+-fn copy_musl_third_party_objects(build: &Build,
+-                                 target: Interned<String>,
+-                                 into: &Path) {
+-    for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+-        copy(&build.musl_root(target).unwrap().join("lib").join(obj), 
&into.join(obj));
+-    }
+-}
+-
+ /// Configure cargo to compile the standard library, adding appropriate env 
vars
+ /// and such.
+ pub fn std_cargo(build: &Build,
+@@ -173,11 +147,6 @@ pub fn std_cargo(build: &Build,
+             cargo.env("JEMALLOC_OVERRIDE", jemalloc);
+         }
+     }
+-    if target.contains("musl") {
+-        if let Some(p) = build.musl_root(target) {
+-            cargo.env("MUSL_ROOT", p);
+-        }
+-    }
+ }
+ 
+ #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
+index 35e62f17f2..cf85233c2c 100644
+--- a/src/bootstrap/config.rs
++++ b/src/bootstrap/config.rs
+@@ -112,8 +112,6 @@ pub struct Config {
+     pub channel: String,
+     pub quiet_tests: bool,
+     pub test_miri: bool,
+-    // Fallback musl-root for all targets
+-    pub musl_root: Option<PathBuf>,
+     pub prefix: Option<PathBuf>,
+     pub sysconfdir: Option<PathBuf>,
+     pub docdir: Option<PathBuf>,
+@@ -147,7 +145,6 @@ pub struct Target {
+     pub linker: Option<PathBuf>,
+     pub ndk: Option<PathBuf>,
+     pub crt_static: Option<bool>,
+-    pub musl_root: Option<PathBuf>,
+     pub qemu_rootfs: Option<PathBuf>,
+ }
+ 
+@@ -269,7 +266,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>,
+@@ -293,7 +289,6 @@ struct TomlTarget {
+     linker: Option<String>,
+     android_ndk: Option<String>,
+     crt_static: Option<bool>,
+-    musl_root: Option<String>,
+     qemu_rootfs: Option<String>,
+ }
+ 
+@@ -471,7 +466,6 @@ impl Config {
+             set(&mut config.quiet_tests, rust.quiet_tests);
+             set(&mut config.test_miri, rust.test_miri);
+             config.rustc_default_linker = rust.default_linker.clone();
+-            config.musl_root = rust.musl_root.clone().map(PathBuf::from);
+ 
+             match rust.codegen_units {
+                 Some(0) => config.rust_codegen_units = Some(num_cpus::get() 
as u32),
+@@ -498,7 +492,6 @@ impl Config {
+                 target.ar = cfg.ar.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.qemu_rootfs = 
cfg.qemu_rootfs.clone().map(PathBuf::from);
+ 
+                 
config.target_config.insert(INTERNER.intern_string(triple.clone()), target);
+diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
+index 579422c979..ff06a24d9c 100755
+--- a/src/bootstrap/configure.py
++++ b/src/bootstrap/configure.py
+@@ -103,20 +103,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-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-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("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 6832992259..edb7d3ce43 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -694,14 +694,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 whether the target will be tested using the 
`remote-test-client`
+     /// and `remote-test-server` binaries.
+     fn remote_tested(&self, target: Interned<String>) -> bool {
+diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
+index 8b23be69a8..187b30da9d 100644
+--- a/src/bootstrap/sanity.rs
++++ b/src/bootstrap/sanity.rs
+@@ -21,7 +21,6 @@
+ use std::collections::HashMap;
+ use std::env;
+ use std::ffi::{OsString, OsStr};
+-use std::fs;
+ use std::process::Command;
+ use std::path::PathBuf;
+ 
+@@ -168,34 +167,6 @@ pub fn check(build: &mut Build) {
+             panic!("the iOS target is only supported on macOS");
+         }
+ 
+-        // Make sure musl-root is valid
+-        if target.contains("musl") && !target.contains("mips") {
+-            // 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_insert(Default::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/cross/Dockerfile b/src/ci/docker/cross/Dockerfile
+index 05745709a0..3f5422b0ae 100644
+--- a/src/ci/docker/cross/Dockerfile
++++ b/src/ci/docker/cross/Dockerfile
+@@ -61,11 +61,7 @@ ENV STAGING_DIR=/tmp
+ 
+ ENV RUST_CONFIGURE_ARGS \
+       --enable-extended \
+-      --target=$TARGETS \
+-      --musl-root-arm=/usr/local/arm-linux-musleabi \
+-      --musl-root-armhf=/usr/local/arm-linux-musleabihf \
+-      --musl-root-armv7=/usr/local/armv7-linux-musleabihf \
+-      --musl-root-aarch64=/usr/local/aarch64-linux-musl
++      --target=$TARGETS
+ ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
+ 
+ # sccache
+diff --git a/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile 
b/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile
+index 2fb1219681..e2e3599be0 100644
+--- a/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile
++++ b/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile
+@@ -25,7 +25,6 @@ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+       --target=i686-unknown-linux-musl,i586-unknown-linux-gnu \
+-      --musl-root-i686=/musl-i686 \
+       --enable-extended
+ 
+ # Newer binutils broke things on some vms/distros (i.e., linking against
+diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile 
b/src/ci/docker/dist-x86_64-musl/Dockerfile
+index 91ed6bfe1f..9859cfeee9 100644
+--- a/src/ci/docker/dist-x86_64-musl/Dockerfile
++++ b/src/ci/docker/dist-x86_64-musl/Dockerfile
+@@ -25,7 +25,6 @@ RUN sh /scripts/sccache.sh
+ 
+ ENV RUST_CONFIGURE_ARGS \
+       --target=x86_64-unknown-linux-musl \
+-      --musl-root-x86_64=/musl-x86_64 \
+       --enable-extended
+ 
+ # Newer binutils broke things on some vms/distros (i.e., linking against
+diff --git a/src/librustc_back/target/linux_musl_base.rs 
b/src/librustc_back/target/linux_musl_base.rs
+index 6e5e139715..d99cb55cc5 100644
+--- a/src/librustc_back/target/linux_musl_base.rs
++++ b/src/librustc_back/target/linux_musl_base.rs
+@@ -14,10 +14,6 @@ use target::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.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
+@@ -49,17 +45,6 @@ pub fn opts() -> TargetOptions {
+     
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-(".to_string());
+     base.post_link_args.insert(LinkerFlavor::Gcc, vec!["-Wl,-)".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.push("crt1.o".to_string());
+-    base.pre_link_objects_exe.push("crti.o".to_string());
+-    base.post_link_objects.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.13.6
+

diff --git 
a/dev-lang/rust/files/0003-Switch-musl-targets-to-link-dynamically-by-default.patch
 
b/dev-lang/rust/files/0003-Switch-musl-targets-to-link-dynamically-by-default.patch
new file mode 100644
index 0000000..b3a0df9
--- /dev/null
+++ 
b/dev-lang/rust/files/0003-Switch-musl-targets-to-link-dynamically-by-default.patch
@@ -0,0 +1,25 @@
+From 77f657181d30e7195188b2d0c6cd55c11aa079ac Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Thu, 30 Nov 2017 08:15:51 -0600
+Subject: [PATCH 3/8] Switch musl targets to link dynamically by default
+
+---
+ src/librustc_back/target/linux_musl_base.rs | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/librustc_back/target/linux_musl_base.rs 
b/src/librustc_back/target/linux_musl_base.rs
+index d99cb55cc5..bb786bf0f3 100644
+--- a/src/librustc_back/target/linux_musl_base.rs
++++ b/src/librustc_back/target/linux_musl_base.rs
+@@ -45,8 +45,6 @@ pub fn opts() -> TargetOptions {
+     
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-(".to_string());
+     base.post_link_args.insert(LinkerFlavor::Gcc, vec!["-Wl,-)".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.
+     base.crt_static_respected = true;
+ 
+-- 
+2.13.6
+

diff --git 
a/dev-lang/rust/files/0004-Prefer-libgcc_eh-over-libunwind-for-musl.patch 
b/dev-lang/rust/files/0004-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 0000000..a15680f
--- /dev/null
+++ b/dev-lang/rust/files/0004-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,24 @@
+From 807918c554f688305ab4a2f7ee439652832e12df Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 4/8] 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 5bb1eb96dc..5be689f50f 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -36,6 +36,6 @@ cfg_if! {
+ }
+ 
+ #[cfg(all(target_env = "musl", not(target_arch = "mips")))]
+-#[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.13.6
+

diff --git a/dev-lang/rust/files/0005-Fix-LLVM-build.patch 
b/dev-lang/rust/files/0005-Fix-LLVM-build.patch
new file mode 100644
index 0000000..97e7f3b
--- /dev/null
+++ b/dev-lang/rust/files/0005-Fix-LLVM-build.patch
@@ -0,0 +1,26 @@
+From 1fa880e13931269c187319f0d535ef194c098894 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Fri, 8 Sep 2017 00:04:29 -0500
+Subject: [PATCH 5/8] 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 edb7d3ce43..7ee3cd3e22 100644
+--- a/src/bootstrap/lib.rs
++++ b/src/bootstrap/lib.rs
+@@ -636,7 +636,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<_>>();
+ 
+         // If we're compiling on macOS then we add a few unconditional flags
+-- 
+2.13.6
+

diff --git a/dev-lang/rust/files/0006-Fix-rustdoc-for-cross-targets.patch 
b/dev-lang/rust/files/0006-Fix-rustdoc-for-cross-targets.patch
new file mode 100644
index 0000000..390f202
--- /dev/null
+++ b/dev-lang/rust/files/0006-Fix-rustdoc-for-cross-targets.patch
@@ -0,0 +1,36 @@
+From da75097b4c83ee27358136c67cdf1c9c3ba795f7 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Sat, 2 Dec 2017 17:25:44 -0600
+Subject: [PATCH 6/8] Fix rustdoc for cross targets
+
+musl can't handle wrong-architecture libraries in LD_LIBRARY_PATH.
+---
+ src/bootstrap/bin/rustdoc.rs | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
+index 4e975adc97..a9df1b71ce 100644
+--- a/src/bootstrap/bin/rustdoc.rs
++++ b/src/bootstrap/bin/rustdoc.rs
+@@ -27,9 +27,6 @@ fn main() {
+     let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
+     let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not 
set");
+ 
+-    let mut dylib_path = bootstrap::util::dylib_path();
+-    dylib_path.insert(0, PathBuf::from(libdir));
+-
+     let mut cmd = Command::new(rustdoc);
+     cmd.args(&args)
+         .arg("--cfg")
+@@ -39,7 +36,7 @@ fn main() {
+         .arg("--sysroot")
+         .arg(sysroot)
+         .env(bootstrap::util::dylib_path_var(),
+-             env::join_paths(&dylib_path).unwrap());
++             PathBuf::from(libdir));
+ 
+     // Force all crates compiled by this compiler to (a) be unstable and (b)
+     // allow the `rustc_private` feature to link to other unstable crates
+-- 
+2.13.6
+

diff --git 
a/dev-lang/rust/files/0007-Add-openssl-configuration-for-musl-targets.patch 
b/dev-lang/rust/files/0007-Add-openssl-configuration-for-musl-targets.patch
new file mode 100644
index 0000000..82848c6
--- /dev/null
+++ b/dev-lang/rust/files/0007-Add-openssl-configuration-for-musl-targets.patch
@@ -0,0 +1,41 @@
+From c919f6ce3c9ac32dbad42946a62f97bd20fe607e Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Mon, 11 Sep 2017 11:21:56 -0500
+Subject: [PATCH 7/8] Add openssl configuration for musl targets
+
+---
+ src/bootstrap/native.rs | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
+index fce6755aea..22e03ff64a 100644
+--- a/src/bootstrap/native.rs
++++ b/src/bootstrap/native.rs
+@@ -430,8 +430,11 @@ impl Step for Openssl {
+             "arm-linux-androideabi" => "android",
+             "arm-unknown-linux-gnueabi" => "linux-armv4",
+             "arm-unknown-linux-gnueabihf" => "linux-armv4",
+-            "armv7-linux-androideabi" => "android-armv7",
++            "arm-unknown-linux-musleabi" => "linux-armv4",
++            "arm-unknown-linux-musleabihf" => "linux-armv4",
++            "armv7-linux-androideabi" => "android-armv4",
+             "armv7-unknown-linux-gnueabihf" => "linux-armv4",
++            "armv7-unknown-linux-musleabihf" => "linux-armv4",
+             "i686-apple-darwin" => "darwin-i386-cc",
+             "i686-linux-android" => "android-x86",
+             "i686-unknown-freebsd" => "BSD-x86-elf",
+@@ -439,9 +442,11 @@ impl Step for Openssl {
+             "i686-unknown-linux-musl" => "linux-elf",
+             "i686-unknown-netbsd" => "BSD-x86-elf",
+             "mips-unknown-linux-gnu" => "linux-mips32",
++            "mips-unknown-linux-musl" => "linux-mips32",
+             "mips64-unknown-linux-gnuabi64" => "linux64-mips64",
+             "mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
+             "mipsel-unknown-linux-gnu" => "linux-mips32",
++            "mipsel-unknown-linux-musl" => "linux-mips32",
+             "powerpc-unknown-linux-gnu" => "linux-ppc",
+             "powerpc64-unknown-linux-gnu" => "linux-ppc64",
+             "powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
+-- 
+2.13.6
+

diff --git a/dev-lang/rust/files/0008-Don-t-pass-CFLAGS-to-the-C-compiler.patch 
b/dev-lang/rust/files/0008-Don-t-pass-CFLAGS-to-the-C-compiler.patch
new file mode 100644
index 0000000..1d769b5
--- /dev/null
+++ b/dev-lang/rust/files/0008-Don-t-pass-CFLAGS-to-the-C-compiler.patch
@@ -0,0 +1,36 @@
+From c386995b5515ca3116e249876ec7916e64f18a90 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <sam...@sholland.org>
+Date: Wed, 10 Jan 2018 13:36:41 -0600
+Subject: [PATCH 8/8] Don't pass CFLAGS to the C++ compiler
+
+---
+ src/bootstrap/builder.rs | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
+index c76900882b..008a0a0410 100644
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -583,7 +583,7 @@ impl<'a> Builder<'a> {
+ 
+             let cflags = self.cflags(target).join(" ");
+             cargo.env(format!("CFLAGS_{}", target), cflags.clone())
+-                 .env("CFLAGS", cflags.clone());
++                 .env("CFLAGS", cflags);
+ 
+             if let Some(ar) = self.ar(target) {
+                 let ranlib = format!("{} s", ar.display());
+@@ -595,9 +595,7 @@ impl<'a> Builder<'a> {
+ 
+             if let Ok(cxx) = self.cxx(target) {
+                 cargo.env(format!("CXX_{}", target), cxx)
+-                     .env("CXX", cxx)
+-                     .env(format!("CXXFLAGS_{}", target), cflags.clone())
+-                     .env("CXXFLAGS", cflags);
++                     .env("CXX", cxx);
+             }
+         }
+ 
+-- 
+2.13.6
+

diff --git a/dev-lang/rust/metadata.xml b/dev-lang/rust/metadata.xml
index f170659..facbbab 100644
--- a/dev-lang/rust/metadata.xml
+++ b/dev-lang/rust/metadata.xml
@@ -6,8 +6,9 @@
     <name>Rust Project</name>
   </maintainer>
   <use>
-    <flag name="jemalloc">Use <pkg>dev-libs/jemalloc</pkg> for 
allocations</flag>
     <flag name="system-llvm">Use system <pkg>sys-devel/llvm</pkg> in
     place of the bundled one</flag>
+    <flag name="jemalloc">Use <pkg>sys-libs/jemalloc</pkg> as the
+    standard memory allocator</flag>
   </use>
 </pkgmetadata>

diff --git a/dev-lang/rust/rust-1.23.0.ebuild b/dev-lang/rust/rust-1.23.0.ebuild
new file mode 100644
index 0000000..cf9be2c
--- /dev/null
+++ b/dev-lang/rust/rust-1.23.0.ebuild
@@ -0,0 +1,247 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+LLVM_MAX_SLOT=4
+PYTHON_COMPAT=( python2_7 )
+
+inherit python-any-r1 versionator toolchain-funcs llvm
+
+if [[ ${PV} = *beta* ]]; then
+       betaver=${PV//*beta}
+       BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
+       MY_P="rustc-beta"
+       SLOT="beta/${PV}"
+       SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz"
+       KEYWORDS=""
+else
+       ABI_VER="$(get_version_component_range 1-2)"
+       SLOT="stable/${ABI_VER}"
+       MY_P="rustc-${PV}"
+       SRC="${MY_P}-src.tar.xz"
+       KEYWORDS="~amd64 ~arm ~x86"
+fi
+
+case "${CHOST}" in
+       armv7a-hardfloat-*)
+               RUSTARCH=armv7 ;;
+       arm*)
+               RUSTARCH=arm ;;
+       *)
+               RUSTARCH=${CHOST%%-*} ;;
+esac
+case "${CHOST}" in
+       armv7a-hardfloat-*)
+               RUSTLIBC=${ELIBC/glibc/gnu}eabihf ;;
+       arm*)
+               RUSTLIBC=${ELIBC/glibc/gnu}eabi ;;
+       *)
+               RUSTLIBC=${ELIBC/glibc/gnu} ;;
+esac
+RUSTHOST=${RUSTARCH}-unknown-${KERNEL}-${RUSTLIBC}
+STAGE0_VERSION="1.$(($(get_version_component_range 2) - 0)).0"
+CARGO_DEPEND_VERSION="0.$(($(get_version_component_range 2) + 1)).0"
+
+DESCRIPTION="Systems programming language from Mozilla"
+HOMEPAGE="http://www.rust-lang.org/";
+
+SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz
+       amd64? (
+               elibc_glibc? ( 
https://static.rust-lang.org/dist/rust-${STAGE0_VERSION}-x86_64-unknown-linux-gnu.tar.xz
 )
+               elibc_musl? ( 
https://portage.smaeul.xyz/distfiles/rust-${STAGE0_VERSION}-x86_64-unknown-linux-musl.tar.xz
 )
+       )
+       arm? (
+               elibc_glibc? (
+                       
https://static.rust-lang.org/dist/rust-${STAGE0_VERSION}-arm-unknown-linux-gnueabi.tar.xz
+                       
https://static.rust-lang.org/dist/rust-${STAGE0_VERSION}-armv7-unknown-linux-gnueabihf.tar.xz
+               )
+               elibc_musl? (
+                       
https://portage.smaeul.xyz/distfiles/rust-${STAGE0_VERSION}-arm-unknown-linux-musleabi.tar.xz
+                       
https://portage.smaeul.xyz/distfiles/rust-${STAGE0_VERSION}-armv7-unknown-linux-musleabihf.tar.xz
+               )
+       )
+       x86? (
+               elibc_glibc? ( 
https://static.rust-lang.org/dist/rust-${STAGE0_VERSION}-i686-unknown-linux-gnu.tar.xz
 )
+               elibc_musl? ( 
https://portage.smaeul.xyz/distfiles/rust-${STAGE0_VERSION}-i686-unknown-linux-musl.tar.xz
 )
+       )
+"
+
+LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
+
+IUSE="debug doc jemalloc system-llvm"
+
+RDEPEND=">=app-eselect/eselect-rust-0.3_pre20150425
+               jemalloc? ( dev-libs/jemalloc )
+               system-llvm? ( sys-devel/llvm:4 )
+"
+DEPEND="${RDEPEND}
+       ${PYTHON_DEPS}
+       || (
+               >=sys-devel/gcc-4.7
+               >=sys-devel/clang-3.5
+       )
+       !system-llvm? (
+               >=dev-util/cmake-3.4.3
+               dev-util/ninja
+       )
+"
+PDEPEND=">=dev-util/cargo-${CARGO_DEPEND_VERSION}"
+
+PATCHES=(
+       
"${FILESDIR}/0001-Require-static-native-libraries-when-linking-static-.patch"
+       "${FILESDIR}/0002-Remove-nostdlib-and-musl_root-from-musl-targets.patch"
+       
"${FILESDIR}/0003-Switch-musl-targets-to-link-dynamically-by-default.patch"
+       "${FILESDIR}/0004-Prefer-libgcc_eh-over-libunwind-for-musl.patch"
+       "${FILESDIR}/0005-Fix-LLVM-build.patch"
+       "${FILESDIR}/0006-Fix-rustdoc-for-cross-targets.patch"
+       "${FILESDIR}/0007-Add-openssl-configuration-for-musl-targets.patch"
+       "${FILESDIR}/0008-Don-t-pass-CFLAGS-to-the-C-compiler.patch"
+       "${FILESDIR}/0009-liblibc.patch"
+       "${FILESDIR}/llvm-musl-fixes.patch"
+)
+
+S="${WORKDIR}/${MY_P}-src"
+
+toml_usex() {
+       usex "$1" true false
+}
+
+pkg_setup() {
+       export RUST_BACKTRACE=1
+       if use system-llvm; then
+               llvm_pkg_setup
+               local llvm_config="$(get_llvm_prefix 
"$LLVM_MAX_SLOT")/bin/llvm-config"
+
+               export LLVM_LINK_SHARED=1
+               export RUSTFLAGS="$RUSTFLAGS -Lnative=$("$llvm_config" 
--libdir)"
+       fi
+
+       python-any-r1_pkg_setup
+}
+
+src_prepare() {
+       default
+
+       "${WORKDIR}/rust-${STAGE0_VERSION}-${RUSTHOST}/install.sh" \
+               --prefix="${WORKDIR}/stage0" \
+               --components=rust-std-${RUSTHOST},rustc,cargo \
+               --disable-ldconfig \
+               || die
+}
+
+src_configure() {
+       cat <<- EOF > "${S}"/config.toml
+               [llvm]
+               ninja = true
+               optimize = $(toml_usex !debug)
+               release-debuginfo = $(toml_usex debug)
+               assertions = $(toml_usex debug)
+               [build]
+               build = "${RUSTHOST}"
+               host = ["${RUSTHOST}"]
+               target = ["${RUSTHOST}"]
+               cargo = "${WORKDIR}/stage0/bin/cargo"
+               rustc = "${WORKDIR}/stage0/bin/rustc"
+               docs = $(toml_usex doc)
+               compiler-docs = $(toml_usex doc)
+               submodules = false
+               python = "${EPYTHON}"
+               locked-deps = true
+               vendor = true
+               verbose = 2
+               [install]
+               prefix = "${EPREFIX}/usr"
+               libdir = "$(get_libdir)"
+               docdir = "share/doc/${P}"
+               mandir = "share/${P}/man"
+               [rust]
+               optimize = $(toml_usex !debug)
+               debuginfo = $(toml_usex debug)
+               debug-assertions = $(toml_usex debug)
+               use-jemalloc = $(toml_usex jemalloc)
+               default-linker = "$(tc-getCC)"
+               channel = "${SLOT%%/*}"
+               rpath = false
+               optimize-tests = $(toml_usex !debug)
+               [dist]
+               src-tarball = false
+               [target.${RUSTHOST}]
+               cc = "$(tc-getBUILD_CC)"
+               cxx = "$(tc-getBUILD_CXX)"
+               linker = "$(tc-getCC)"
+               ar = "$(tc-getAR)"
+       EOF
+       use system-llvm && cat <<- EOF >> "${S}"/config.toml
+               llvm-config = "$(get_llvm_prefix 
"$LLVM_MAX_SLOT")/bin/llvm-config"
+       EOF
+}
+
+src_compile() {
+       ./x.py build || die
+}
+
+src_install() {
+       env DESTDIR="${D}" ./x.py install || die
+
+       rm "${D}/usr/$(get_libdir)/rustlib/components" || die
+       rm "${D}/usr/$(get_libdir)/rustlib/install.log" || die
+       rm "${D}/usr/$(get_libdir)/rustlib/manifest-rust-std-${RUSTHOST}" || die
+       rm "${D}/usr/$(get_libdir)/rustlib/manifest-rustc" || die
+       rm "${D}/usr/$(get_libdir)/rustlib/rust-installer-version" || die
+       rm "${D}/usr/$(get_libdir)/rustlib/uninstall.sh" || die
+
+       mv "${D}/usr/bin/rustc" "${D}/usr/bin/rustc-${PV}" || die
+       mv "${D}/usr/bin/rustdoc" "${D}/usr/bin/rustdoc-${PV}" || die
+       mv "${D}/usr/bin/rust-gdb" "${D}/usr/bin/rust-gdb-${PV}" || die
+       mv "${D}/usr/bin/rust-lldb" "${D}/usr/bin/rust-lldb-${PV}" || die
+
+       if use doc; then
+               rm "${D}/usr/$(get_libdir)/rustlib/manifest-rust-docs" || die
+               dodir "/usr/share/doc/${P}"
+               mv "${D}/usr/share/doc/rust"/* "${D}/usr/share/doc/${P}" || die
+               rmdir "${D}/usr/share/doc/rust" || die
+       fi
+
+       rm "${D}/usr/share/doc/${P}/LICENSE-APACHE" || die
+       rm "${D}/usr/share/doc/${P}/LICENSE-MIT" || die
+
+       docompress "/usr/share/${P}/man"
+
+       cat <<-EOF > "${T}"/50${P}
+       MANPATH="/usr/share/${P}/man"
+       EOF
+       doenvd "${T}"/50${P}
+
+       cat <<-EOF > "${T}/provider-${P}"
+       /usr/bin/rustdoc
+       /usr/bin/rust-gdb
+       /usr/bin/rust-lldb
+       EOF
+       dodir /etc/env.d/rust
+       insinto /etc/env.d/rust
+       doins "${T}/provider-${P}"
+}
+
+pkg_postinst() {
+       eselect rust update --if-unset
+
+       elog "Rust installs a helper script for calling GDB and LLDB,"
+       elog "for your convenience it is installed under 
/usr/bin/rust-{gdb,lldb}-${PV}."
+
+       if has_version app-editors/emacs || has_version app-editors/emacs-vcs; 
then
+               elog "install app-emacs/rust-mode to get emacs support for 
rust."
+       fi
+
+       if has_version app-editors/gvim || has_version app-editors/vim; then
+               elog "install app-vim/rust-vim to get vim support for rust."
+       fi
+
+       if has_version 'app-shells/zsh'; then
+               elog "install app-shells/rust-zshcomp to get zsh completion for 
rust."
+       fi
+}
+
+pkg_postrm() {
+       eselect rust unset --if-invalid
+}

Reply via email to