about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2019-09-26 14:44:08 -0700
committerJosh Stone <jistone@redhat.com>2019-10-07 13:48:16 -0700
commitfaee5fd388a564febc56aa642241f221c0ac1cd1 (patch)
tree6c760500aee21ca0ec05daa03f83fb1556b2e139
parent59a31c8c676bdc9f50490d5798b1b4e884b7d7ae (diff)
downloadrust-faee5fd388a564febc56aa642241f221c0ac1cd1.tar.gz
rust-faee5fd388a564febc56aa642241f221c0ac1cd1.zip
[WIP] minimize the rust-std component
-rw-r--r--src/bootstrap/builder.rs1
-rw-r--r--src/bootstrap/dist.rs79
2 files changed, 78 insertions, 2 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 5d586f0c461..afdcabc0830 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -443,6 +443,7 @@ impl<'a> Builder<'a> {
                 dist::Rustc,
                 dist::DebuggerScripts,
                 dist::Std,
+                dist::StdZ,
                 dist::Analysis,
                 dist::Src,
                 dist::PlainSourceTarball,
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index d9dff77a30e..ceb7acb83e7 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -675,6 +675,81 @@ impl Step for Std {
             return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
         }
 
+        builder.ensure(compile::Std { compiler, target });
+
+        let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
+        let _ = fs::remove_dir_all(&image);
+
+
+        let dst = image.join("lib/rustlib").join(target).join("lib");
+        t!(fs::create_dir_all(&dst));
+
+        let stamp = dbg!(compile::libstd_stamp(builder, compiler, target));
+        for (path, host) in builder.read_stamp_file(&stamp) {
+            if !host {
+                builder.copy(&path, &dst.join(path.file_name().unwrap()));
+            }
+        }
+
+        let mut cmd = rust_installer(builder);
+        cmd.arg("generate")
+           .arg("--product-name=Rust")
+           .arg("--rel-manifest-dir=rustlib")
+           .arg("--success-message=std-is-standing-at-the-ready.")
+           .arg("--image-dir").arg(&image)
+           .arg("--work-dir").arg(&tmpdir(builder))
+           .arg("--output-dir").arg(&distdir(builder))
+           .arg(format!("--package-name={}-{}", name, target))
+           .arg(format!("--component-name=rust-std-{}", target))
+           .arg("--legacy-manifest-dirs=rustlib,cargo");
+
+        builder.info(&format!("Dist std stage{} ({} -> {})",
+            compiler.stage, &compiler.host, target));
+        let _time = timeit(builder);
+        builder.run(&mut cmd);
+        builder.remove_dir(&image);
+        distdir(builder).join(format!("{}-{}.tar.gz", name, target))
+    }
+}
+
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct StdZ {
+    pub compiler: Compiler,
+    pub target: Interned<String>,
+}
+
+impl Step for StdZ {
+    type Output = PathBuf;
+    const DEFAULT: bool = true;
+
+    fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+        run.path("src/libstdZ")
+    }
+
+    fn make_run(run: RunConfig<'_>) {
+        run.builder.ensure(StdZ {
+            compiler: run.builder.compiler_for(
+                run.builder.top_stage,
+                run.builder.config.build,
+                run.target,
+            ),
+            target: run.target,
+        });
+    }
+
+    fn run(self, builder: &Builder<'_>) -> PathBuf {
+        let compiler = self.compiler;
+        let target = self.target;
+
+        let name = pkgname(builder, "rust-stdZ");
+
+        // The only true set of target libraries came from the build triple, so
+        // let's reduce redundant work by only producing archives from that host.
+        if compiler.host != builder.config.build {
+            builder.info("\tskipping, not a build host");
+            return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
+        }
+
         // We want to package up as many target libraries as possible
         // for the `rust-std` package, so if this is a host target we
         // depend on librustc and otherwise we just depend on libtest.
@@ -710,12 +785,12 @@ impl Step for Std {
         cmd.arg("generate")
            .arg("--product-name=Rust")
            .arg("--rel-manifest-dir=rustlib")
-           .arg("--success-message=std-is-standing-at-the-ready.")
+           .arg("--success-message=stdZ-is-standing-at-the-ready.")
            .arg("--image-dir").arg(&image)
            .arg("--work-dir").arg(&tmpdir(builder))
            .arg("--output-dir").arg(&distdir(builder))
            .arg(format!("--package-name={}-{}", name, target))
-           .arg(format!("--component-name=rust-std-{}", target))
+           .arg(format!("--component-name=rust-stdZ-{}", target))
            .arg("--legacy-manifest-dirs=rustlib,cargo");
 
         builder.info(&format!("Dist std stage{} ({} -> {})",