Skip to content

Commit faee5fd

Browse files
committed
[WIP] minimize the rust-std component
1 parent 59a31c8 commit faee5fd

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ impl<'a> Builder<'a> {
443443
dist::Rustc,
444444
dist::DebuggerScripts,
445445
dist::Std,
446+
dist::StdZ,
446447
dist::Analysis,
447448
dist::Src,
448449
dist::PlainSourceTarball,

src/bootstrap/dist.rs

+77-2
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,81 @@ impl Step for Std {
675675
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
676676
}
677677

678+
builder.ensure(compile::Std { compiler, target });
679+
680+
let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
681+
let _ = fs::remove_dir_all(&image);
682+
683+
684+
let dst = image.join("lib/rustlib").join(target).join("lib");
685+
t!(fs::create_dir_all(&dst));
686+
687+
let stamp = dbg!(compile::libstd_stamp(builder, compiler, target));
688+
for (path, host) in builder.read_stamp_file(&stamp) {
689+
if !host {
690+
builder.copy(&path, &dst.join(path.file_name().unwrap()));
691+
}
692+
}
693+
694+
let mut cmd = rust_installer(builder);
695+
cmd.arg("generate")
696+
.arg("--product-name=Rust")
697+
.arg("--rel-manifest-dir=rustlib")
698+
.arg("--success-message=std-is-standing-at-the-ready.")
699+
.arg("--image-dir").arg(&image)
700+
.arg("--work-dir").arg(&tmpdir(builder))
701+
.arg("--output-dir").arg(&distdir(builder))
702+
.arg(format!("--package-name={}-{}", name, target))
703+
.arg(format!("--component-name=rust-std-{}", target))
704+
.arg("--legacy-manifest-dirs=rustlib,cargo");
705+
706+
builder.info(&format!("Dist std stage{} ({} -> {})",
707+
compiler.stage, &compiler.host, target));
708+
let _time = timeit(builder);
709+
builder.run(&mut cmd);
710+
builder.remove_dir(&image);
711+
distdir(builder).join(format!("{}-{}.tar.gz", name, target))
712+
}
713+
}
714+
715+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
716+
pub struct StdZ {
717+
pub compiler: Compiler,
718+
pub target: Interned<String>,
719+
}
720+
721+
impl Step for StdZ {
722+
type Output = PathBuf;
723+
const DEFAULT: bool = true;
724+
725+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
726+
run.path("src/libstdZ")
727+
}
728+
729+
fn make_run(run: RunConfig<'_>) {
730+
run.builder.ensure(StdZ {
731+
compiler: run.builder.compiler_for(
732+
run.builder.top_stage,
733+
run.builder.config.build,
734+
run.target,
735+
),
736+
target: run.target,
737+
});
738+
}
739+
740+
fn run(self, builder: &Builder<'_>) -> PathBuf {
741+
let compiler = self.compiler;
742+
let target = self.target;
743+
744+
let name = pkgname(builder, "rust-stdZ");
745+
746+
// The only true set of target libraries came from the build triple, so
747+
// let's reduce redundant work by only producing archives from that host.
748+
if compiler.host != builder.config.build {
749+
builder.info("\tskipping, not a build host");
750+
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
751+
}
752+
678753
// We want to package up as many target libraries as possible
679754
// for the `rust-std` package, so if this is a host target we
680755
// depend on librustc and otherwise we just depend on libtest.
@@ -710,12 +785,12 @@ impl Step for Std {
710785
cmd.arg("generate")
711786
.arg("--product-name=Rust")
712787
.arg("--rel-manifest-dir=rustlib")
713-
.arg("--success-message=std-is-standing-at-the-ready.")
788+
.arg("--success-message=stdZ-is-standing-at-the-ready.")
714789
.arg("--image-dir").arg(&image)
715790
.arg("--work-dir").arg(&tmpdir(builder))
716791
.arg("--output-dir").arg(&distdir(builder))
717792
.arg(format!("--package-name={}-{}", name, target))
718-
.arg(format!("--component-name=rust-std-{}", target))
793+
.arg(format!("--component-name=rust-stdZ-{}", target))
719794
.arg("--legacy-manifest-dirs=rustlib,cargo");
720795

721796
builder.info(&format!("Dist std stage{} ({} -> {})",

0 commit comments

Comments
 (0)