Skip to content

Commit 9175f27

Browse files
committed
add dist::RustcDev for unstable compiler libraries
1 parent dc8ee51 commit 9175f27

File tree

2 files changed

+46
-58
lines changed

2 files changed

+46
-58
lines changed

src/bootstrap/builder.rs

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

src/bootstrap/dist.rs

+45-57
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,28 @@ impl Step for DebuggerScripts {
637637
}
638638
}
639639

640+
fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool {
641+
// The only true set of target libraries came from the build triple, so
642+
// let's reduce redundant work by only producing archives from that host.
643+
if compiler.host != builder.config.build {
644+
builder.info("\tskipping, not a build host");
645+
true
646+
} else {
647+
false
648+
}
649+
}
650+
651+
/// Copy stamped files into an image's `target/lib` directory.
652+
fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &Path) {
653+
let dst = image.join("lib/rustlib").join(target).join("lib");
654+
t!(fs::create_dir_all(&dst));
655+
for (path, host) in builder.read_stamp_file(stamp) {
656+
if !host || builder.config.build == target {
657+
builder.copy(&path, &dst.join(path.file_name().unwrap()));
658+
}
659+
}
660+
}
661+
640662
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
641663
pub struct Std {
642664
pub compiler: Compiler,
@@ -667,29 +689,19 @@ impl Step for Std {
667689
let target = self.target;
668690

669691
let name = pkgname(builder, "rust-std");
670-
671-
// The only true set of target libraries came from the build triple, so
672-
// let's reduce redundant work by only producing archives from that host.
673-
if compiler.host != builder.config.build {
674-
builder.info("\tskipping, not a build host");
675-
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
692+
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target));
693+
if skip_host_target_lib(builder, compiler) {
694+
return archive;
676695
}
677696

678697
builder.ensure(compile::Std { compiler, target });
679698

680699
let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
681700
let _ = fs::remove_dir_all(&image);
682701

683-
let dst = image.join("lib/rustlib").join(target).join("lib");
684-
t!(fs::create_dir_all(&dst));
685-
686702
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
687-
let stamp = dbg!(compile::libstd_stamp(builder, compiler_to_use, 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-
}
703+
let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
704+
copy_target_libs(builder, &target, &image, &stamp);
693705

694706
let mut cmd = rust_installer(builder);
695707
cmd.arg("generate")
@@ -708,26 +720,27 @@ impl Step for Std {
708720
let _time = timeit(builder);
709721
builder.run(&mut cmd);
710722
builder.remove_dir(&image);
711-
distdir(builder).join(format!("{}-{}.tar.gz", name, target))
723+
archive
712724
}
713725
}
714726

715727
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
716-
pub struct StdZ {
728+
pub struct RustcDev {
717729
pub compiler: Compiler,
718730
pub target: Interned<String>,
719731
}
720732

721-
impl Step for StdZ {
733+
impl Step for RustcDev {
722734
type Output = PathBuf;
723735
const DEFAULT: bool = true;
736+
const ONLY_HOSTS: bool = true;
724737

725738
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
726-
run.path("src/libstdZ")
739+
run.path("rustc-dev")
727740
}
728741

729742
fn make_run(run: RunConfig<'_>) {
730-
run.builder.ensure(StdZ {
743+
run.builder.ensure(RustcDev {
731744
compiler: run.builder.compiler_for(
732745
run.builder.top_stage,
733746
run.builder.config.build,
@@ -741,64 +754,39 @@ impl Step for StdZ {
741754
let compiler = self.compiler;
742755
let target = self.target;
743756

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));
757+
let name = pkgname(builder, "rustc-dev");
758+
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target));
759+
if skip_host_target_lib(builder, compiler) {
760+
return archive;
751761
}
752762

753-
// We want to package up as many target libraries as possible
754-
// for the `rust-std` package, so if this is a host target we
755-
// depend on librustc and otherwise we just depend on libtest.
756-
if builder.hosts.iter().any(|t| t == target) {
757-
builder.ensure(compile::Rustc { compiler, target });
758-
} else {
759-
builder.ensure(compile::Std { compiler, target });
760-
}
763+
builder.ensure(compile::Rustc { compiler, target });
761764

762765
let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
763766
let _ = fs::remove_dir_all(&image);
764767

765-
let dst = image.join("lib/rustlib").join(target);
766-
t!(fs::create_dir_all(&dst));
767-
let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
768-
src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
769-
builder.cp_filtered(&src, &dst, &|path| {
770-
if let Some(name) = path.file_name().and_then(|s| s.to_str()) {
771-
if name == builder.config.rust_codegen_backends_dir.as_str() {
772-
return false
773-
}
774-
if name == "bin" {
775-
return false
776-
}
777-
if name.contains("LLVM") {
778-
return false
779-
}
780-
}
781-
true
782-
});
768+
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
769+
let stamp = compile::librustc_stamp(builder, compiler_to_use, target);
770+
copy_target_libs(builder, &target, &image, &stamp);
783771

784772
let mut cmd = rust_installer(builder);
785773
cmd.arg("generate")
786774
.arg("--product-name=Rust")
787775
.arg("--rel-manifest-dir=rustlib")
788-
.arg("--success-message=stdZ-is-standing-at-the-ready.")
776+
.arg("--success-message=Rust-is-ready-to-develop.")
789777
.arg("--image-dir").arg(&image)
790778
.arg("--work-dir").arg(&tmpdir(builder))
791779
.arg("--output-dir").arg(&distdir(builder))
792780
.arg(format!("--package-name={}-{}", name, target))
793-
.arg(format!("--component-name=rust-stdZ-{}", target))
781+
.arg(format!("--component-name=rustc-dev-{}", target))
794782
.arg("--legacy-manifest-dirs=rustlib,cargo");
795783

796-
builder.info(&format!("Dist std stage{} ({} -> {})",
784+
builder.info(&format!("Dist rustc-dev stage{} ({} -> {})",
797785
compiler.stage, &compiler.host, target));
798786
let _time = timeit(builder);
799787
builder.run(&mut cmd);
800788
builder.remove_dir(&image);
801-
distdir(builder).join(format!("{}-{}.tar.gz", name, target))
789+
archive
802790
}
803791
}
804792

0 commit comments

Comments
 (0)