Skip to content

Commit 36d4506

Browse files
committed
Auto merge of #65342 - Mark-Simulacrum:revert-rustc-dev, r=pietroalbini
Revert "Auto merge of #64823 - cuviper:min-std, r=Mark-Simulacrum" This reverts commit 000d90b, reversing changes made to 898f36c. This turned out to break quite a few targets, cc #65335
2 parents c27f756 + fabba8f commit 36d4506

File tree

3 files changed

+33
-127
lines changed

3 files changed

+33
-127
lines changed

src/bootstrap/builder.rs

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

src/bootstrap/dist.rs

+33-96
Original file line numberDiff line numberDiff line change
@@ -637,28 +637,6 @@ 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-
662640
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
663641
pub struct Std {
664642
pub compiler: Compiler,
@@ -689,19 +667,44 @@ impl Step for Std {
689667
let target = self.target;
690668

691669
let name = pkgname(builder, "rust-std");
692-
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target));
693-
if skip_host_target_lib(builder, compiler) {
694-
return archive;
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));
695676
}
696677

697-
builder.ensure(compile::Std { compiler, target });
678+
// We want to package up as many target libraries as possible
679+
// for the `rust-std` package, so if this is a host target we
680+
// depend on librustc and otherwise we just depend on libtest.
681+
if builder.hosts.iter().any(|t| t == target) {
682+
builder.ensure(compile::Rustc { compiler, target });
683+
} else {
684+
builder.ensure(compile::Std { compiler, target });
685+
}
698686

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

702-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
703-
let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
704-
copy_target_libs(builder, &target, &image, &stamp);
690+
let dst = image.join("lib/rustlib").join(target);
691+
t!(fs::create_dir_all(&dst));
692+
let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
693+
src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
694+
builder.cp_filtered(&src, &dst, &|path| {
695+
if let Some(name) = path.file_name().and_then(|s| s.to_str()) {
696+
if name == builder.config.rust_codegen_backends_dir.as_str() {
697+
return false
698+
}
699+
if name == "bin" {
700+
return false
701+
}
702+
if name.contains("LLVM") {
703+
return false
704+
}
705+
}
706+
true
707+
});
705708

706709
let mut cmd = rust_installer(builder);
707710
cmd.arg("generate")
@@ -720,73 +723,7 @@ impl Step for Std {
720723
let _time = timeit(builder);
721724
builder.run(&mut cmd);
722725
builder.remove_dir(&image);
723-
archive
724-
}
725-
}
726-
727-
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
728-
pub struct RustcDev {
729-
pub compiler: Compiler,
730-
pub target: Interned<String>,
731-
}
732-
733-
impl Step for RustcDev {
734-
type Output = PathBuf;
735-
const DEFAULT: bool = true;
736-
const ONLY_HOSTS: bool = true;
737-
738-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
739-
run.path("rustc-dev")
740-
}
741-
742-
fn make_run(run: RunConfig<'_>) {
743-
run.builder.ensure(RustcDev {
744-
compiler: run.builder.compiler_for(
745-
run.builder.top_stage,
746-
run.builder.config.build,
747-
run.target,
748-
),
749-
target: run.target,
750-
});
751-
}
752-
753-
fn run(self, builder: &Builder<'_>) -> PathBuf {
754-
let compiler = self.compiler;
755-
let target = self.target;
756-
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;
761-
}
762-
763-
builder.ensure(compile::Rustc { compiler, target });
764-
765-
let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
766-
let _ = fs::remove_dir_all(&image);
767-
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);
771-
772-
let mut cmd = rust_installer(builder);
773-
cmd.arg("generate")
774-
.arg("--product-name=Rust")
775-
.arg("--rel-manifest-dir=rustlib")
776-
.arg("--success-message=Rust-is-ready-to-develop.")
777-
.arg("--image-dir").arg(&image)
778-
.arg("--work-dir").arg(&tmpdir(builder))
779-
.arg("--output-dir").arg(&distdir(builder))
780-
.arg(format!("--package-name={}-{}", name, target))
781-
.arg(format!("--component-name=rustc-dev-{}", target))
782-
.arg("--legacy-manifest-dirs=rustlib,cargo");
783-
784-
builder.info(&format!("Dist rustc-dev stage{} ({} -> {})",
785-
compiler.stage, &compiler.host, target));
786-
let _time = timeit(builder);
787-
builder.run(&mut cmd);
788-
builder.remove_dir(&image);
789-
archive
726+
distdir(builder).join(format!("{}-{}.tar.gz", name, target))
790727
}
791728
}
792729

src/tools/build-manifest/src/main.rs

-30
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ impl Builder {
399399
fn add_packages_to(&mut self, manifest: &mut Manifest) {
400400
let mut package = |name, targets| self.package(name, &mut manifest.pkg, targets);
401401
package("rustc", HOSTS);
402-
package("rustc-dev", HOSTS);
403402
package("cargo", HOSTS);
404403
package("rust-mingw", MINGW);
405404
package("rust-std", TARGETS);
@@ -427,13 +426,6 @@ impl Builder {
427426
"rls-preview", "rust-src", "llvm-tools-preview",
428427
"lldb-preview", "rust-analysis", "miri-preview"
429428
]);
430-
431-
// The compiler libraries are not stable for end users, but `rustc-dev` was only recently
432-
// split out of `rust-std`. We'll include it by default as a transition for nightly users.
433-
if self.rust_release == "nightly" {
434-
self.extend_profile("default", &mut manifest.profiles, &["rustc-dev"]);
435-
self.extend_profile("complete", &mut manifest.profiles, &["rustc-dev"]);
436-
}
437429
}
438430

439431
fn add_renames_to(&self, manifest: &mut Manifest) {
@@ -489,15 +481,6 @@ impl Builder {
489481
components.push(host_component("rust-mingw"));
490482
}
491483

492-
// The compiler libraries are not stable for end users, but `rustc-dev` was only recently
493-
// split out of `rust-std`. We'll include it by default as a transition for nightly users,
494-
// but ship it as an optional component on the beta and stable channels.
495-
if self.rust_release == "nightly" {
496-
components.push(host_component("rustc-dev"));
497-
} else {
498-
extensions.push(host_component("rustc-dev"));
499-
}
500-
501484
// Tools are always present in the manifest,
502485
// but might be marked as unavailable if they weren't built.
503486
extensions.extend(vec![
@@ -515,11 +498,6 @@ impl Builder {
515498
.filter(|&&target| target != host)
516499
.map(|target| Component::from_str("rust-std", target))
517500
);
518-
extensions.extend(
519-
HOSTS.iter()
520-
.filter(|&&target| target != host)
521-
.map(|target| Component::from_str("rustc-dev", target))
522-
);
523501
extensions.push(Component::from_str("rust-src", "*"));
524502

525503
// If the components/extensions don't actually exist for this
@@ -556,14 +534,6 @@ impl Builder {
556534
dst.insert(profile_name.to_owned(), pkgs.iter().map(|s| (*s).to_owned()).collect());
557535
}
558536

559-
fn extend_profile(&mut self,
560-
profile_name: &str,
561-
dst: &mut BTreeMap<String, Vec<String>>,
562-
pkgs: &[&str]) {
563-
dst.get_mut(profile_name).expect("existing profile")
564-
.extend(pkgs.iter().map(|s| (*s).to_owned()));
565-
}
566-
567537
fn package(&mut self,
568538
pkgname: &str,
569539
dst: &mut BTreeMap<String, Package>,

0 commit comments

Comments
 (0)