Skip to content

Commit facf5a9

Browse files
Build rustdoc only at the top stage
1 parent ad4acba commit facf5a9

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

src/bootstrap/builder.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -407,22 +407,19 @@ impl<'a> Builder<'a> {
407407
}
408408
}
409409

410-
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
411-
self.ensure(tool::Rustdoc { target_compiler: compiler })
410+
pub fn rustdoc(&self, host: Interned<String>) -> PathBuf {
411+
self.ensure(tool::Rustdoc { host })
412412
}
413413

414-
pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command {
414+
pub fn rustdoc_cmd(&self, host: Interned<String>) -> Command {
415415
let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc"));
416+
let compiler = self.compiler(self.top_stage, host);
416417
cmd
417418
.env("RUSTC_STAGE", compiler.stage.to_string())
418-
.env("RUSTC_SYSROOT", if compiler.is_snapshot(&self.build) {
419-
INTERNER.intern_path(self.build.rustc_snapshot_libdir())
420-
} else {
421-
self.sysroot(compiler)
422-
})
423-
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
419+
.env("RUSTC_SYSROOT", self.sysroot(compiler))
420+
.env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
424421
.env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
425-
.env("RUSTDOC_REAL", self.rustdoc(compiler));
422+
.env("RUSTDOC_REAL", self.rustdoc(host));
426423
cmd
427424
}
428425

@@ -476,7 +473,7 @@ impl<'a> Builder<'a> {
476473
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
477474
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
478475
.env("RUSTDOC_REAL", if cmd == "doc" || cmd == "test" {
479-
self.rustdoc(compiler)
476+
self.rustdoc(compiler.host)
480477
} else {
481478
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
482479
})

src/bootstrap/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Step for Cargotest {
164164
try_run(build, cmd.arg(&build.initial_cargo)
165165
.arg(&out_dir)
166166
.env("RUSTC", builder.rustc(compiler))
167-
.env("RUSTDOC", builder.rustdoc(compiler)));
167+
.env("RUSTDOC", builder.rustdoc(compiler.host)));
168168
}
169169
}
170170

@@ -565,7 +565,7 @@ impl Step for Compiletest {
565565

566566
// Avoid depending on rustdoc when we don't need it.
567567
if mode == "rustdoc" || mode == "run-make" {
568-
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
568+
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
569569
}
570570

571571
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
@@ -814,7 +814,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
814814
}
815815

816816
println!("doc tests for: {}", markdown.display());
817-
let mut cmd = builder.rustdoc_cmd(compiler);
817+
let mut cmd = builder.rustdoc_cmd(compiler.host);
818818
build.add_rust_test_threads(&mut cmd);
819819
cmd.arg("--test");
820820
cmd.arg(markdown);

src/bootstrap/dist.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ impl Step for Rustc {
413413
t!(fs::create_dir_all(image.join("bin")));
414414
cp_r(&src.join("bin"), &image.join("bin"));
415415

416-
install(&builder.ensure(tool::Rustdoc { target_compiler: compiler }),
417-
&image.join("bin"), 0o755);
416+
install(&builder.rustdoc(compiler.host), &image.join("bin"), 0o755);
418417

419418
// Copy runtime DLLs needed by the compiler
420419
if libdir != "bin" {

src/bootstrap/doc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned<String
260260
t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
261261
}
262262

263-
let mut cmd = builder.rustdoc_cmd(compiler);
263+
let mut cmd = builder.rustdoc_cmd(compiler.host);
264264

265265
let out = out.join("book");
266266

@@ -343,7 +343,7 @@ impl Step for Standalone {
343343
}
344344

345345
let html = out.join(filename).with_extension("html");
346-
let rustdoc = builder.rustdoc(compiler);
346+
let rustdoc = builder.rustdoc(compiler.host);
347347
if up_to_date(&path, &html) &&
348348
up_to_date(&footer, &html) &&
349349
up_to_date(&favicon, &html) &&
@@ -353,7 +353,7 @@ impl Step for Standalone {
353353
continue
354354
}
355355

356-
let mut cmd = builder.rustdoc_cmd(compiler);
356+
let mut cmd = builder.rustdoc_cmd(compiler.host);
357357
cmd.arg("--html-after-content").arg(&footer)
358358
.arg("--html-before-content").arg(&version_info)
359359
.arg("--html-in-header").arg(&favicon)
@@ -408,7 +408,7 @@ impl Step for Std {
408408
let out = build.doc_out(target);
409409
t!(fs::create_dir_all(&out));
410410
let compiler = builder.compiler(stage, build.build);
411-
let rustdoc = builder.rustdoc(compiler);
411+
let rustdoc = builder.rustdoc(compiler.host);
412412
let compiler = if build.force_use_stage1(compiler, target) {
413413
builder.compiler(1, compiler.host)
414414
} else {
@@ -493,7 +493,7 @@ impl Step for Test {
493493
let out = build.doc_out(target);
494494
t!(fs::create_dir_all(&out));
495495
let compiler = builder.compiler(stage, build.build);
496-
let rustdoc = builder.rustdoc(compiler);
496+
let rustdoc = builder.rustdoc(compiler.host);
497497
let compiler = if build.force_use_stage1(compiler, target) {
498498
builder.compiler(1, compiler.host)
499499
} else {
@@ -554,7 +554,7 @@ impl Step for Rustc {
554554
let out = build.doc_out(target);
555555
t!(fs::create_dir_all(&out));
556556
let compiler = builder.compiler(stage, build.build);
557-
let rustdoc = builder.rustdoc(compiler);
557+
let rustdoc = builder.rustdoc(compiler.host);
558558
let compiler = if build.force_use_stage1(compiler, target) {
559559
builder.compiler(1, compiler.host)
560560
} else {

src/bootstrap/tool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl Step for RemoteTestServer {
236236

237237
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
238238
pub struct Rustdoc {
239-
pub target_compiler: Compiler,
239+
pub host: Interned<String>,
240240
}
241241

242242
impl Step for Rustdoc {
@@ -250,13 +250,13 @@ impl Step for Rustdoc {
250250

251251
fn make_run(run: RunConfig) {
252252
run.builder.ensure(Rustdoc {
253-
target_compiler: run.builder.compiler(run.builder.top_stage, run.host),
253+
host: run.host,
254254
});
255255
}
256256

257257
fn run(self, builder: &Builder) -> PathBuf {
258258
let build = builder.build;
259-
let target_compiler = self.target_compiler;
259+
let target_compiler = builder.compiler(builder.top_stage, self.host);
260260
let target = target_compiler.host;
261261
let build_compiler = if target_compiler.stage == 0 {
262262
builder.compiler(0, builder.build.build)

0 commit comments

Comments
 (0)