cbcbe2
From 8e0007f829661e57d008d2e908c95f6e84b04b25 Mon Sep 17 00:00:00 2001
cbcbe2
From: bors <bors@rust-lang.org>
cbcbe2
Date: Thu, 24 Oct 2019 07:27:00 +0000
cbcbe2
Subject: [PATCH] Auto merge of #65474 - Mark-Simulacrum:rustc-dev-split,
cbcbe2
 r=pietroalbini
cbcbe2
cbcbe2
Split the rustc target libraries into separate rustc-dev component
cbcbe2
cbcbe2
This is re-applies a squashed version of #64823 as well as including #65337 to fix bugs noted after merging the first PR.
cbcbe2
cbcbe2
The second PR is confirmed as fixing windows-gnu, and presumably also fixes other platforms, such as musl (i.e. #65335 should be fixed); `RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup toolchain install nightly-2019-10-16` can be installed to confirm that this is indeed the case.
cbcbe2
cbcbe2
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
cbcbe2
index b8071b98f707..2748903f2d47 100644
cbcbe2
--- a/src/bootstrap/builder.rs
cbcbe2
+++ b/src/bootstrap/builder.rs
cbcbe2
@@ -443,6 +443,7 @@ impl<'a> Builder<'a> {
cbcbe2
                 dist::Rustc,
cbcbe2
                 dist::DebuggerScripts,
cbcbe2
                 dist::Std,
cbcbe2
+                dist::RustcDev,
cbcbe2
                 dist::Analysis,
cbcbe2
                 dist::Src,
cbcbe2
                 dist::PlainSourceTarball,
cbcbe2
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
cbcbe2
index cadb9a7e441f..df1c72575846 100644
cbcbe2
--- a/src/bootstrap/check.rs
cbcbe2
+++ b/src/bootstrap/check.rs
cbcbe2
@@ -55,6 +55,7 @@ impl Step for Std {
cbcbe2
                   cargo,
cbcbe2
                   args(builder.kind),
cbcbe2
                   &libstd_stamp(builder, compiler, target),
cbcbe2
+                  vec![],
cbcbe2
                   true);
cbcbe2
 
cbcbe2
         let libdir = builder.sysroot_libdir(compiler, target);
cbcbe2
@@ -103,6 +104,7 @@ impl Step for Rustc {
cbcbe2
                   cargo,
cbcbe2
                   args(builder.kind),
cbcbe2
                   &librustc_stamp(builder, compiler, target),
cbcbe2
+                  vec![],
cbcbe2
                   true);
cbcbe2
 
cbcbe2
         let libdir = builder.sysroot_libdir(compiler, target);
cbcbe2
@@ -155,6 +157,7 @@ impl Step for CodegenBackend {
cbcbe2
                   cargo,
cbcbe2
                   args(builder.kind),
cbcbe2
                   &codegen_backend_stamp(builder, compiler, target, backend),
cbcbe2
+                  vec![],
cbcbe2
                   true);
cbcbe2
     }
cbcbe2
 }
cbcbe2
@@ -199,6 +202,7 @@ impl Step for Rustdoc {
cbcbe2
                   cargo,
cbcbe2
                   args(builder.kind),
cbcbe2
                   &rustdoc_stamp(builder, compiler, target),
cbcbe2
+                  vec![],
cbcbe2
                   true);
cbcbe2
 
cbcbe2
         let libdir = builder.sysroot_libdir(compiler, target);
cbcbe2
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
cbcbe2
index 5074b035789a..da8d43ed49b7 100644
cbcbe2
--- a/src/bootstrap/compile.rs
cbcbe2
+++ b/src/bootstrap/compile.rs
cbcbe2
@@ -69,7 +69,7 @@ impl Step for Std {
cbcbe2
             return;
cbcbe2
         }
cbcbe2
 
cbcbe2
-        builder.ensure(StartupObjects { compiler, target });
cbcbe2
+        let mut target_deps = builder.ensure(StartupObjects { compiler, target });
cbcbe2
 
cbcbe2
         let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
cbcbe2
         if compiler_to_use != compiler {
cbcbe2
@@ -91,7 +91,7 @@ impl Step for Std {
cbcbe2
             return;
cbcbe2
         }
cbcbe2
 
cbcbe2
-        copy_third_party_objects(builder, &compiler, target);
cbcbe2
+        target_deps.extend(copy_third_party_objects(builder, &compiler, target).into_iter());
cbcbe2
 
cbcbe2
         let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
cbcbe2
         std_cargo(builder, &compiler, target, &mut cargo);
cbcbe2
@@ -102,6 +102,7 @@ impl Step for Std {
cbcbe2
                   cargo,
cbcbe2
                   vec![],
cbcbe2
                   &libstd_stamp(builder, compiler, target),
cbcbe2
+                  target_deps,
cbcbe2
                   false);
cbcbe2
 
cbcbe2
         builder.ensure(StdLink {
cbcbe2
@@ -113,9 +114,22 @@ impl Step for Std {
cbcbe2
 }
cbcbe2
 
cbcbe2
 /// Copies third pary objects needed by various targets.
cbcbe2
-fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
cbcbe2
+fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>)
cbcbe2
+    -> Vec<PathBuf>
cbcbe2
+{
cbcbe2
     let libdir = builder.sysroot_libdir(*compiler, target);
cbcbe2
 
cbcbe2
+    let mut target_deps = vec![];
cbcbe2
+
cbcbe2
+    let mut copy_and_stamp = |sourcedir: &Path, name: &str| {
cbcbe2
+        let target = libdir.join(name);
cbcbe2
+        builder.copy(
cbcbe2
+            &sourcedir.join(name),
cbcbe2
+            &target,
cbcbe2
+        );
cbcbe2
+        target_deps.push(target);
cbcbe2
+    };
cbcbe2
+
cbcbe2
     // Copies the crt(1,i,n).o startup objects
cbcbe2
     //
cbcbe2
     // Since musl supports fully static linking, we can cross link for it even
cbcbe2
@@ -123,19 +137,13 @@ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target:
cbcbe2
     // files. As those shipped with glibc won't work, copy the ones provided by
cbcbe2
     // musl so we have them on linux-gnu hosts.
cbcbe2
     if target.contains("musl") {
cbcbe2
+        let srcdir = builder.musl_root(target).unwrap().join("lib");
cbcbe2
         for &obj in &["crt1.o", "crti.o", "crtn.o"] {
cbcbe2
-            builder.copy(
cbcbe2
-                &builder.musl_root(target).unwrap().join("lib").join(obj),
cbcbe2
-                &libdir.join(obj),
cbcbe2
-            );
cbcbe2
+            copy_and_stamp(&srcdir, obj);
cbcbe2
         }
cbcbe2
     } else if target.ends_with("-wasi") {
cbcbe2
-        for &obj in &["crt1.o"] {
cbcbe2
-            builder.copy(
cbcbe2
-                &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
cbcbe2
-                &libdir.join(obj),
cbcbe2
-            );
cbcbe2
-        }
cbcbe2
+        let srcdir = builder.wasi_root(target).unwrap().join("lib/wasm32-wasi");
cbcbe2
+        copy_and_stamp(&srcdir, "crt1.o");
cbcbe2
     }
cbcbe2
 
cbcbe2
     // Copies libunwind.a compiled to be linked wit x86_64-fortanix-unknown-sgx.
cbcbe2
@@ -145,11 +153,11 @@ fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target:
cbcbe2
     // which is provided by std for this target.
cbcbe2
     if target == "x86_64-fortanix-unknown-sgx" {
cbcbe2
         let src_path_env = "X86_FORTANIX_SGX_LIBS";
cbcbe2
-        let obj = "libunwind.a";
cbcbe2
         let src = env::var(src_path_env).expect(&format!("{} not found in env", src_path_env));
cbcbe2
-        let src = Path::new(&src).join(obj);
cbcbe2
-        builder.copy(&src, &libdir.join(obj));
cbcbe2
+        copy_and_stamp(Path::new(&src), "libunwind.a");
cbcbe2
     }
cbcbe2
+
cbcbe2
+    target_deps
cbcbe2
 }
cbcbe2
 
cbcbe2
 /// Configure cargo to compile the standard library, adding appropriate env vars
cbcbe2
@@ -306,7 +314,7 @@ pub struct StartupObjects {
cbcbe2
 }
cbcbe2
 
cbcbe2
 impl Step for StartupObjects {
cbcbe2
-    type Output = ();
cbcbe2
+    type Output = Vec<PathBuf>;
cbcbe2
 
cbcbe2
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
cbcbe2
         run.path("src/rtstartup")
cbcbe2
@@ -325,13 +333,15 @@ impl Step for StartupObjects {
cbcbe2
     /// They don't require any library support as they're just plain old object
cbcbe2
     /// files, so we just use the nightly snapshot compiler to always build them (as
cbcbe2
     /// no other compilers are guaranteed to be available).
cbcbe2
-    fn run(self, builder: &Builder<'_>) {
cbcbe2
+    fn run(self, builder: &Builder<'_>) -> Vec<PathBuf> {
cbcbe2
         let for_compiler = self.compiler;
cbcbe2
         let target = self.target;
cbcbe2
         if !target.contains("windows-gnu") {
cbcbe2
-            return
cbcbe2
+            return vec![]
cbcbe2
         }
cbcbe2
 
cbcbe2
+        let mut target_deps = vec![];
cbcbe2
+
cbcbe2
         let src_dir = &builder.src.join("src/rtstartup");
cbcbe2
         let dst_dir = &builder.native_dir(target).join("rtstartup");
cbcbe2
         let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
cbcbe2
@@ -350,7 +360,9 @@ impl Step for StartupObjects {
cbcbe2
                             .arg(src_file));
cbcbe2
             }
cbcbe2
 
cbcbe2
-            builder.copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
cbcbe2
+            let target = sysroot_dir.join(file.to_string() + ".o");
cbcbe2
+            builder.copy(dst_file, &target);
cbcbe2
+            target_deps.push(target);
cbcbe2
         }
cbcbe2
 
cbcbe2
         for obj in ["crt2.o", "dllcrt2.o"].iter() {
cbcbe2
@@ -358,8 +370,12 @@ impl Step for StartupObjects {
cbcbe2
                                     builder.cc(target),
cbcbe2
                                     target,
cbcbe2
                                     obj);
cbcbe2
-            builder.copy(&src, &sysroot_dir.join(obj));
cbcbe2
+            let target = sysroot_dir.join(obj);
cbcbe2
+            builder.copy(&src, &target);
cbcbe2
+            target_deps.push(target);
cbcbe2
         }
cbcbe2
+
cbcbe2
+        target_deps
cbcbe2
     }
cbcbe2
 }
cbcbe2
 
cbcbe2
@@ -437,6 +453,7 @@ impl Step for Rustc {
cbcbe2
                   cargo,
cbcbe2
                   vec![],
cbcbe2
                   &librustc_stamp(builder, compiler, target),
cbcbe2
+                  vec![],
cbcbe2
                   false);
cbcbe2
 
cbcbe2
         builder.ensure(RustcLink {
cbcbe2
@@ -585,7 +602,7 @@ impl Step for CodegenBackend {
cbcbe2
 
cbcbe2
         let tmp_stamp = out_dir.join(".tmp.stamp");
cbcbe2
 
cbcbe2
-        let files = run_cargo(builder, cargo, vec![], &tmp_stamp, false);
cbcbe2
+        let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false);
cbcbe2
         if builder.config.dry_run {
cbcbe2
             return;
cbcbe2
         }
cbcbe2
@@ -941,6 +958,7 @@ pub fn run_cargo(builder: &Builder<'_>,
cbcbe2
                  cargo: Cargo,
cbcbe2
                  tail_args: Vec<String>,
cbcbe2
                  stamp: &Path,
cbcbe2
+                 additional_target_deps: Vec<PathBuf>,
cbcbe2
                  is_check: bool)
cbcbe2
     -> Vec<PathBuf>
cbcbe2
 {
cbcbe2
@@ -1057,6 +1075,7 @@ pub fn run_cargo(builder: &Builder<'_>,
cbcbe2
         deps.push((path_to_add.into(), false));
cbcbe2
     }
cbcbe2
 
cbcbe2
+    deps.extend(additional_target_deps.into_iter().map(|d| (d, false)));
cbcbe2
     deps.sort();
cbcbe2
     let mut new_contents = Vec::new();
cbcbe2
     for (dep, proc_macro) in deps.iter() {
cbcbe2
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
cbcbe2
index 514ad1144491..93143570b0fe 100644
cbcbe2
--- a/src/bootstrap/dist.rs
cbcbe2
+++ b/src/bootstrap/dist.rs
cbcbe2
@@ -637,6 +637,28 @@ impl Step for DebuggerScripts {
cbcbe2
     }
cbcbe2
 }
cbcbe2
 
cbcbe2
+fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool {
cbcbe2
+    // The only true set of target libraries came from the build triple, so
cbcbe2
+    // let's reduce redundant work by only producing archives from that host.
cbcbe2
+    if compiler.host != builder.config.build {
cbcbe2
+        builder.info("\tskipping, not a build host");
cbcbe2
+        true
cbcbe2
+    } else {
cbcbe2
+        false
cbcbe2
+    }
cbcbe2
+}
cbcbe2
+
cbcbe2
+/// Copy stamped files into an image's `target/lib` directory.
cbcbe2
+fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &Path) {
cbcbe2
+    let dst = image.join("lib/rustlib").join(target).join("lib");
cbcbe2
+    t!(fs::create_dir_all(&dst);;
cbcbe2
+    for (path, host) in builder.read_stamp_file(stamp) {
cbcbe2
+        if !host || builder.config.build == target {
cbcbe2
+            builder.copy(&path, &dst.join(path.file_name().unwrap()));
cbcbe2
+        }
cbcbe2
+    }
cbcbe2
+}
cbcbe2
+
cbcbe2
 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
cbcbe2
 pub struct Std {
cbcbe2
     pub compiler: Compiler,
cbcbe2
@@ -667,44 +689,19 @@ impl Step for Std {
cbcbe2
         let target = self.target;
cbcbe2
 
cbcbe2
         let name = pkgname(builder, "rust-std");
cbcbe2
-
cbcbe2
-        // The only true set of target libraries came from the build triple, so
cbcbe2
-        // let's reduce redundant work by only producing archives from that host.
cbcbe2
-        if compiler.host != builder.config.build {
cbcbe2
-            builder.info("\tskipping, not a build host");
cbcbe2
-            return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
cbcbe2
+        let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target));
cbcbe2
+        if skip_host_target_lib(builder, compiler) {
cbcbe2
+            return archive;
cbcbe2
         }
cbcbe2
 
cbcbe2
-        // We want to package up as many target libraries as possible
cbcbe2
-        // for the `rust-std` package, so if this is a host target we
cbcbe2
-        // depend on librustc and otherwise we just depend on libtest.
cbcbe2
-        if builder.hosts.iter().any(|t| t == target) {
cbcbe2
-            builder.ensure(compile::Rustc { compiler, target });
cbcbe2
-        } else {
cbcbe2
-            builder.ensure(compile::Std { compiler, target });
cbcbe2
-        }
cbcbe2
+        builder.ensure(compile::Std { compiler, target });
cbcbe2
 
cbcbe2
         let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
cbcbe2
         let _ = fs::remove_dir_all(&image);
cbcbe2
 
cbcbe2
-        let dst = image.join("lib/rustlib").join(target);
cbcbe2
-        t!(fs::create_dir_all(&dst);;
cbcbe2
-        let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
cbcbe2
-        src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
cbcbe2
-        builder.cp_filtered(&src, &dst, &|path| {
cbcbe2
-            if let Some(name) = path.file_name().and_then(|s| s.to_str()) {
cbcbe2
-                if name == builder.config.rust_codegen_backends_dir.as_str() {
cbcbe2
-                    return false
cbcbe2
-                }
cbcbe2
-                if name == "bin" {
cbcbe2
-                    return false
cbcbe2
-                }
cbcbe2
-                if name.contains("LLVM") {
cbcbe2
-                    return false
cbcbe2
-                }
cbcbe2
-            }
cbcbe2
-            true
cbcbe2
-        });
cbcbe2
+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
cbcbe2
+        let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
cbcbe2
+        copy_target_libs(builder, &target, &image, &stamp);
cbcbe2
 
cbcbe2
         let mut cmd = rust_installer(builder);
cbcbe2
         cmd.arg("generate")
cbcbe2
@@ -723,7 +720,73 @@ impl Step for Std {
cbcbe2
         let _time = timeit(builder);
cbcbe2
         builder.run(&mut cmd);
cbcbe2
         builder.remove_dir(&image);
cbcbe2
-        distdir(builder).join(format!("{}-{}.tar.gz", name, target))
cbcbe2
+        archive
cbcbe2
+    }
cbcbe2
+}
cbcbe2
+
cbcbe2
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
cbcbe2
+pub struct RustcDev {
cbcbe2
+    pub compiler: Compiler,
cbcbe2
+    pub target: Interned<String>,
cbcbe2
+}
cbcbe2
+
cbcbe2
+impl Step for RustcDev {
cbcbe2
+    type Output = PathBuf;
cbcbe2
+    const DEFAULT: bool = true;
cbcbe2
+    const ONLY_HOSTS: bool = true;
cbcbe2
+
cbcbe2
+    fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
cbcbe2
+        run.path("rustc-dev")
cbcbe2
+    }
cbcbe2
+
cbcbe2
+    fn make_run(run: RunConfig<'_>) {
cbcbe2
+        run.builder.ensure(RustcDev {
cbcbe2
+            compiler: run.builder.compiler_for(
cbcbe2
+                run.builder.top_stage,
cbcbe2
+                run.builder.config.build,
cbcbe2
+                run.target,
cbcbe2
+            ),
cbcbe2
+            target: run.target,
cbcbe2
+        });
cbcbe2
+    }
cbcbe2
+
cbcbe2
+    fn run(self, builder: &Builder<'_>) -> PathBuf {
cbcbe2
+        let compiler = self.compiler;
cbcbe2
+        let target = self.target;
cbcbe2
+
cbcbe2
+        let name = pkgname(builder, "rustc-dev");
cbcbe2
+        let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target));
cbcbe2
+        if skip_host_target_lib(builder, compiler) {
cbcbe2
+            return archive;
cbcbe2
+        }
cbcbe2
+
cbcbe2
+        builder.ensure(compile::Rustc { compiler, target });
cbcbe2
+
cbcbe2
+        let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
cbcbe2
+        let _ = fs::remove_dir_all(&image);
cbcbe2
+
cbcbe2
+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
cbcbe2
+        let stamp = compile::librustc_stamp(builder, compiler_to_use, target);
cbcbe2
+        copy_target_libs(builder, &target, &image, &stamp);
cbcbe2
+
cbcbe2
+        let mut cmd = rust_installer(builder);
cbcbe2
+        cmd.arg("generate")
cbcbe2
+           .arg("--product-name=Rust")
cbcbe2
+           .arg("--rel-manifest-dir=rustlib")
cbcbe2
+           .arg("--success-message=Rust-is-ready-to-develop.")
cbcbe2
+           .arg("--image-dir").arg(&image)
cbcbe2
+           .arg("--work-dir").arg(&tmpdir(builder))
cbcbe2
+           .arg("--output-dir").arg(&distdir(builder))
cbcbe2
+           .arg(format!("--package-name={}-{}", name, target))
cbcbe2
+           .arg(format!("--component-name=rustc-dev-{}", target))
cbcbe2
+           .arg("--legacy-manifest-dirs=rustlib,cargo");
cbcbe2
+
cbcbe2
+        builder.info(&format!("Dist rustc-dev stage{} ({} -> {})",
cbcbe2
+            compiler.stage, &compiler.host, target));
cbcbe2
+        let _time = timeit(builder);
cbcbe2
+        builder.run(&mut cmd);
cbcbe2
+        builder.remove_dir(&image);
cbcbe2
+        archive
cbcbe2
     }
cbcbe2
 }
cbcbe2
 
cbcbe2
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
cbcbe2
index a182405f3b2d..d1cf1cbca784 100644
cbcbe2
--- a/src/bootstrap/lib.rs
cbcbe2
+++ b/src/bootstrap/lib.rs
cbcbe2
@@ -1137,6 +1137,7 @@ impl Build {
cbcbe2
     pub fn copy(&self, src: &Path, dst: &Path) {
cbcbe2
         if self.config.dry_run { return; }
cbcbe2
         self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst));
cbcbe2
+        if src == dst { return; }
cbcbe2
         let _ = fs::remove_file(&dst);
cbcbe2
         let metadata = t!(src.symlink_metadata());
cbcbe2
         if metadata.file_type().is_symlink() {
cbcbe2
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
cbcbe2
index f41e7dd17ede..c0d2deab2f8b 100644
cbcbe2
--- a/src/tools/build-manifest/src/main.rs
cbcbe2
+++ b/src/tools/build-manifest/src/main.rs
cbcbe2
@@ -399,6 +399,7 @@ impl Builder {
cbcbe2
     fn add_packages_to(&mut self, manifest: &mut Manifest) {
cbcbe2
         let mut package = |name, targets| self.package(name, &mut manifest.pkg, targets);
cbcbe2
         package("rustc", HOSTS);
cbcbe2
+        package("rustc-dev", HOSTS);
cbcbe2
         package("cargo", HOSTS);
cbcbe2
         package("rust-mingw", MINGW);
cbcbe2
         package("rust-std", TARGETS);
cbcbe2
@@ -426,6 +427,13 @@ impl Builder {
cbcbe2
             "rls-preview", "rust-src", "llvm-tools-preview",
cbcbe2
             "lldb-preview", "rust-analysis", "miri-preview"
cbcbe2
         ]);
cbcbe2
+
cbcbe2
+        // The compiler libraries are not stable for end users, but `rustc-dev` was only recently
cbcbe2
+        // split out of `rust-std`. We'll include it by default as a transition for nightly users.
cbcbe2
+        if self.rust_release == "nightly" {
cbcbe2
+            self.extend_profile("default", &mut manifest.profiles, &["rustc-dev"]);
cbcbe2
+            self.extend_profile("complete", &mut manifest.profiles, &["rustc-dev"]);
cbcbe2
+        }
cbcbe2
     }
cbcbe2
 
cbcbe2
     fn add_renames_to(&self, manifest: &mut Manifest) {
cbcbe2
@@ -481,6 +489,15 @@ impl Builder {
cbcbe2
             components.push(host_component("rust-mingw"));
cbcbe2
         }
cbcbe2
 
cbcbe2
+        // The compiler libraries are not stable for end users, but `rustc-dev` was only recently
cbcbe2
+        // split out of `rust-std`. We'll include it by default as a transition for nightly users,
cbcbe2
+        // but ship it as an optional component on the beta and stable channels.
cbcbe2
+        if self.rust_release == "nightly" {
cbcbe2
+            components.push(host_component("rustc-dev"));
cbcbe2
+        } else {
cbcbe2
+            extensions.push(host_component("rustc-dev"));
cbcbe2
+        }
cbcbe2
+
cbcbe2
         // Tools are always present in the manifest,
cbcbe2
         // but might be marked as unavailable if they weren't built.
cbcbe2
         extensions.extend(vec![
cbcbe2
@@ -498,6 +515,11 @@ impl Builder {
cbcbe2
                 .filter(|&&target| target != host)
cbcbe2
                 .map(|target| Component::from_str("rust-std", target))
cbcbe2
         );
cbcbe2
+        extensions.extend(
cbcbe2
+            HOSTS.iter()
cbcbe2
+                .filter(|&&target| target != host)
cbcbe2
+                .map(|target| Component::from_str("rustc-dev", target))
cbcbe2
+        );
cbcbe2
         extensions.push(Component::from_str("rust-src", "*"));
cbcbe2
 
cbcbe2
         // If the components/extensions don't actually exist for this
cbcbe2
@@ -534,6 +556,14 @@ impl Builder {
cbcbe2
         dst.insert(profile_name.to_owned(), pkgs.iter().map(|s| (*s).to_owned()).collect());
cbcbe2
     }
cbcbe2
 
cbcbe2
+    fn extend_profile(&mut self,
cbcbe2
+               profile_name: &str,
cbcbe2
+               dst: &mut BTreeMap<String, Vec<String>>,
cbcbe2
+               pkgs: &[&str]) {
cbcbe2
+        dst.get_mut(profile_name).expect("existing profile")
cbcbe2
+            .extend(pkgs.iter().map(|s| (*s).to_owned()));
cbcbe2
+    }
cbcbe2
+
cbcbe2
     fn package(&mut self,
cbcbe2
                pkgname: &str,
cbcbe2
                dst: &mut BTreeMap<String, Package>,