Skip to content

Commit b8a5001

Browse files
committed
Auto merge of rust-lang#112256 - jyn514:faster-mingw-check, r=Mark-Simulacrum
Don't compile rustc to self-test compiletest This was changed from stage 0 to 1 in rust-lang#108905, but I'm not sure why. Change it to `top_stage` instead to allow people to choose the stage. This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`. Note that this also fixes a latent bug that depended on running `x build compiler` before `x doc compiler`, as well as a couple cleanups related to symlinks (which made the latent bug easier to find). cc `@pietroalbini`
2 parents 7820972 + d613134 commit b8a5001

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/bootstrap/doc.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//! `rustdoc`.
99
1010
use std::fs;
11-
use std::io;
1211
use std::path::{Path, PathBuf};
1312

1413
use crate::builder::crate_description;
@@ -694,11 +693,12 @@ impl Step for Rustc {
694693
// rustc. rustdoc needs to be able to see everything, for example when
695694
// merging the search index, or generating local (relative) links.
696695
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target.triple).join("doc");
697-
t!(symlink_dir_force(&builder.config, &out, &out_dir));
696+
t!(fs::create_dir_all(out_dir.parent().unwrap()));
697+
symlink_dir_force(&builder.config, &out, &out_dir);
698698
// Cargo puts proc macros in `target/doc` even if you pass `--target`
699699
// explicitly (https://github.com/rust-lang/cargo/issues/7677).
700700
let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc");
701-
t!(symlink_dir_force(&builder.config, &out, &proc_macro_out_dir));
701+
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
702702

703703
// Build cargo command.
704704
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
@@ -821,7 +821,7 @@ macro_rules! tool_doc {
821821
];
822822
for out_dir in out_dirs {
823823
t!(fs::create_dir_all(&out_dir));
824-
t!(symlink_dir_force(&builder.config, &out, &out_dir));
824+
symlink_dir_force(&builder.config, &out, &out_dir);
825825
}
826826

827827
// Build cargo command.
@@ -964,21 +964,24 @@ impl Step for UnstableBookGen {
964964
}
965965
}
966966

967-
fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
967+
fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
968968
if config.dry_run() {
969-
return Ok(());
969+
return;
970970
}
971-
if let Ok(m) = fs::symlink_metadata(dst) {
971+
if let Ok(m) = fs::symlink_metadata(link) {
972972
if m.file_type().is_dir() {
973-
fs::remove_dir_all(dst)?;
973+
t!(fs::remove_dir_all(link));
974974
} else {
975975
// handle directory junctions on windows by falling back to
976976
// `remove_dir`.
977-
fs::remove_file(dst).or_else(|_| fs::remove_dir(dst))?;
977+
t!(fs::remove_file(link).or_else(|_| fs::remove_dir(link)));
978978
}
979979
}
980980

981-
symlink_dir(config, src, dst)
981+
t!(
982+
symlink_dir(config, original, link),
983+
format!("failed to create link from {} -> {}", link.display(), original.display())
984+
);
982985
}
983986

984987
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]

src/bootstrap/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl Step for CompiletestTest {
700700
/// Runs `cargo test` for compiletest.
701701
fn run(self, builder: &Builder<'_>) {
702702
let host = self.host;
703-
let compiler = builder.compiler(1, host);
703+
let compiler = builder.compiler(builder.top_stage, host);
704704

705705
// We need `ToolStd` for the locally-built sysroot because
706706
// compiletest uses unstable features of the `test` crate.

src/bootstrap/util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ pub(crate) fn program_out_of_date(stamp: &Path, key: &str) -> bool {
134134

135135
/// Symlinks two directories, using junctions on Windows and normal symlinks on
136136
/// Unix.
137-
pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
137+
pub fn symlink_dir(config: &Config, original: &Path, link: &Path) -> io::Result<()> {
138138
if config.dry_run() {
139139
return Ok(());
140140
}
141-
let _ = fs::remove_dir(dest);
142-
return symlink_dir_inner(src, dest);
141+
let _ = fs::remove_dir(link);
142+
return symlink_dir_inner(original, link);
143143

144144
#[cfg(not(windows))]
145-
fn symlink_dir_inner(src: &Path, dest: &Path) -> io::Result<()> {
145+
fn symlink_dir_inner(original: &Path, link: &Path) -> io::Result<()> {
146146
use std::os::unix::fs;
147-
fs::symlink(src, dest)
147+
fs::symlink(original, link)
148148
}
149149

150150
#[cfg(windows)]

0 commit comments

Comments
 (0)