Skip to content

Commit 6fd4d67

Browse files
committed
rustbuild: Tweak where timing information goes
This commit tweaks where timing and step information is printed out as part of the build, ensuring that we do it as close to the location where work happens as possible. In rustbuild various functions may perform long blocking work as dependencies are assembled, so if we print out timing information early on we may accidentally time more than just the step we were intending to time!
1 parent 61b6bf5 commit 6fd4d67

File tree

4 files changed

+60
-54
lines changed

4 files changed

+60
-54
lines changed

src/bootstrap/check.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ impl Step for Std {
4040
let target = self.target;
4141
let compiler = builder.compiler(0, build.build);
4242

43-
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
44-
println!("Checking std artifacts ({} -> {})", &compiler.host, target);
45-
4643
let out_dir = build.stage_out(compiler, Mode::Libstd);
4744
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
4845
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
4946
std_cargo(builder, &compiler, target, &mut cargo);
47+
48+
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
49+
println!("Checking std artifacts ({} -> {})", &compiler.host, target);
5050
run_cargo(build,
5151
&mut cargo,
5252
&libstd_stamp(build, compiler, target),
5353
true);
54+
5455
let libdir = builder.sysroot_libdir(compiler, target);
5556
add_to_sysroot(&libdir, &libstd_stamp(build, compiler, target));
5657
}
@@ -86,19 +87,20 @@ impl Step for Rustc {
8687
let compiler = builder.compiler(0, build.build);
8788
let target = self.target;
8889

89-
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
90-
println!("Checking compiler artifacts ({} -> {})", &compiler.host, target);
91-
9290
let stage_out = builder.stage_out(compiler, Mode::Librustc);
9391
build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target));
9492
build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
9593

9694
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
9795
rustc_cargo(build, &mut cargo);
96+
97+
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
98+
println!("Checking compiler artifacts ({} -> {})", &compiler.host, target);
9899
run_cargo(build,
99100
&mut cargo,
100101
&librustc_stamp(build, compiler, target),
101102
true);
103+
102104
let libdir = builder.sysroot_libdir(compiler, target);
103105
add_to_sysroot(&libdir, &librustc_stamp(build, compiler, target));
104106
}
@@ -128,16 +130,18 @@ impl Step for Test {
128130
let target = self.target;
129131
let compiler = builder.compiler(0, build.build);
130132

131-
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
132-
println!("Checking test artifacts ({} -> {})", &compiler.host, target);
133133
let out_dir = build.stage_out(compiler, Mode::Libtest);
134134
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
135135
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
136136
test_cargo(build, &compiler, target, &mut cargo);
137+
138+
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
139+
println!("Checking test artifacts ({} -> {})", &compiler.host, target);
137140
run_cargo(build,
138141
&mut cargo,
139142
&libtest_stamp(build, compiler, target),
140143
true);
144+
141145
let libdir = builder.sysroot_libdir(compiler, target);
142146
add_to_sysroot(&libdir, &libtest_stamp(build, compiler, target));
143147
}

src/bootstrap/compile.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ impl Step for Std {
9393
return;
9494
}
9595

96-
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
97-
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
98-
&compiler.host, target);
99-
10096
if target.contains("musl") {
10197
let libdir = builder.sysroot_libdir(compiler, target);
10298
copy_musl_third_party_objects(build, target, &libdir);
@@ -106,6 +102,10 @@ impl Step for Std {
106102
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
107103
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
108104
std_cargo(builder, &compiler, target, &mut cargo);
105+
106+
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
107+
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
108+
&compiler.host, target);
109109
run_cargo(build,
110110
&mut cargo,
111111
&libstd_stamp(build, compiler, target),
@@ -360,13 +360,14 @@ impl Step for Test {
360360
return;
361361
}
362362

363-
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
364-
println!("Building stage{} test artifacts ({} -> {})", compiler.stage,
365-
&compiler.host, target);
366363
let out_dir = build.stage_out(compiler, Mode::Libtest);
367364
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
368365
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build");
369366
test_cargo(build, &compiler, target, &mut cargo);
367+
368+
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
369+
println!("Building stage{} test artifacts ({} -> {})", compiler.stage,
370+
&compiler.host, target);
370371
run_cargo(build,
371372
&mut cargo,
372373
&libtest_stamp(build, compiler, target),
@@ -482,16 +483,16 @@ impl Step for Rustc {
482483
target: build.build,
483484
});
484485

485-
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
486-
println!("Building stage{} compiler artifacts ({} -> {})",
487-
compiler.stage, &compiler.host, target);
488-
489486
let stage_out = builder.stage_out(compiler, Mode::Librustc);
490487
build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target));
491488
build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
492489

493490
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
494491
rustc_cargo(build, &mut cargo);
492+
493+
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
494+
println!("Building stage{} compiler artifacts ({} -> {})",
495+
compiler.stage, &compiler.host, target);
495496
run_cargo(build,
496497
&mut cargo,
497498
&librustc_stamp(build, compiler, target),
@@ -634,8 +635,6 @@ impl Step for CodegenBackend {
634635
.arg(build.src.join("src/librustc_trans/Cargo.toml"));
635636
rustc_cargo_env(build, &mut cargo);
636637

637-
let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage));
638-
639638
match &*self.backend {
640639
"llvm" | "emscripten" => {
641640
// Build LLVM for our target. This will implicitly build the
@@ -685,6 +684,8 @@ impl Step for CodegenBackend {
685684

686685
let tmp_stamp = build.cargo_out(compiler, Mode::Librustc, target)
687686
.join(".tmp.stamp");
687+
688+
let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage));
688689
let files = run_cargo(build,
689690
cargo.arg("--features").arg(features),
690691
&tmp_stamp,

src/bootstrap/test.rs

+28-27
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ impl Step for Tidy {
530530
fn run(self, builder: &Builder) {
531531
let build = builder.build;
532532

533-
let _folder = build.fold_output(|| "tidy");
534-
println!("tidy check");
535533
let mut cmd = builder.tool_cmd(Tool::Tidy);
536534
cmd.arg(build.src.join("src"));
537535
cmd.arg(&build.initial_cargo);
@@ -541,6 +539,9 @@ impl Step for Tidy {
541539
if build.config.quiet_tests {
542540
cmd.arg("--quiet");
543541
}
542+
543+
let _folder = build.fold_output(|| "tidy");
544+
println!("tidy check");
544545
try_run(build, &mut cmd);
545546
}
546547

@@ -836,9 +837,6 @@ impl Step for Compiletest {
836837
builder.ensure(native::TestHelpers { target });
837838
builder.ensure(RemoteCopyLibs { compiler, target });
838839

839-
let _folder = build.fold_output(|| format!("test_{}", suite));
840-
println!("Check compiletest suite={} mode={} ({} -> {})",
841-
suite, mode, &compiler.host, target);
842840
let mut cmd = builder.tool_cmd(Tool::Compiletest);
843841

844842
// compiletest currently has... a lot of arguments, so let's just pass all
@@ -998,6 +996,9 @@ impl Step for Compiletest {
998996

999997
build.ci_env.force_coloring_in_ci(&mut cmd);
1000998

999+
let _folder = build.fold_output(|| format!("test_{}", suite));
1000+
println!("Check compiletest suite={} mode={} ({} -> {})",
1001+
suite, mode, &compiler.host, target);
10011002
let _time = util::timeit();
10021003
try_run(build, &mut cmd);
10031004
}
@@ -1142,20 +1143,21 @@ impl Step for ErrorIndex {
11421143

11431144
builder.ensure(compile::Std { compiler, target: compiler.host });
11441145

1145-
let _folder = build.fold_output(|| "test_error_index");
1146-
println!("Testing error-index stage{}", compiler.stage);
1147-
11481146
let dir = testdir(build, compiler.host);
11491147
t!(fs::create_dir_all(&dir));
11501148
let output = dir.join("error-index.md");
11511149

1152-
let _time = util::timeit();
1153-
build.run(builder.tool_cmd(Tool::ErrorIndex)
1154-
.arg("markdown")
1155-
.arg(&output)
1156-
.env("CFG_BUILD", &build.build)
1157-
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));
1150+
let mut tool = builder.tool_cmd(Tool::ErrorIndex);
1151+
tool.arg("markdown")
1152+
.arg(&output)
1153+
.env("CFG_BUILD", &build.build)
1154+
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir());
1155+
11581156

1157+
let _folder = build.fold_output(|| "test_error_index");
1158+
println!("Testing error-index stage{}", compiler.stage);
1159+
let _time = util::timeit();
1160+
build.run(&mut tool);
11591161
markdown_test(builder, compiler, &output);
11601162
}
11611163
}
@@ -1400,11 +1402,6 @@ impl Step for Crate {
14001402
}
14011403
_ => panic!("can only test libraries"),
14021404
};
1403-
let _folder = build.fold_output(|| {
1404-
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
1405-
});
1406-
println!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
1407-
&compiler.host, target);
14081405

14091406
// Build up the base `cargo test` command.
14101407
//
@@ -1436,8 +1433,6 @@ impl Step for Crate {
14361433
cargo.arg("--quiet");
14371434
}
14381435

1439-
let _time = util::timeit();
1440-
14411436
if target.contains("emscripten") {
14421437
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
14431438
build.config.nodejs.as_ref().expect("nodejs not configured"));
@@ -1465,6 +1460,13 @@ impl Step for Crate {
14651460
format!("{} run",
14661461
builder.tool_exe(Tool::RemoteTestClient).display()));
14671462
}
1463+
1464+
let _folder = build.fold_output(|| {
1465+
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
1466+
});
1467+
println!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
1468+
&compiler.host, target);
1469+
let _time = util::timeit();
14681470
try_run(build, &mut cargo);
14691471
}
14701472
}
@@ -1513,12 +1515,6 @@ impl Step for CrateRustdoc {
15131515
target,
15141516
test_kind.subcommand(),
15151517
"src/tools/rustdoc");
1516-
let _folder = build.fold_output(|| {
1517-
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1518-
});
1519-
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1520-
&compiler.host, target);
1521-
15221518
if test_kind.subcommand() == "test" && !build.fail_fast {
15231519
cargo.arg("--no-fail-fast");
15241520
}
@@ -1532,6 +1528,11 @@ impl Step for CrateRustdoc {
15321528
cargo.arg("--quiet");
15331529
}
15341530

1531+
let _folder = build.fold_output(|| {
1532+
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1533+
});
1534+
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1535+
&compiler.host, target);
15351536
let _time = util::timeit();
15361537

15371538
try_run(build, &mut cargo);

src/bootstrap/tool.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ impl Step for ToolBuild {
112112
Mode::Tool => panic!("unexpected Mode::Tool for tool build")
113113
}
114114

115-
let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
116-
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
117-
118115
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
119116
cargo.arg("--features").arg(self.extra_features.join(" "));
117+
118+
let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
119+
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
120120
let is_expected = build.try_run(&mut cargo);
121121
build.save_toolstate(tool, if is_expected {
122122
ToolState::TestFail
@@ -339,9 +339,6 @@ impl Step for Rustdoc {
339339

340340
builder.ensure(compile::Rustc { compiler: build_compiler, target });
341341

342-
let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));
343-
println!("Building rustdoc for stage{} ({})", target_compiler.stage, target_compiler.host);
344-
345342
let mut cargo = prepare_tool_cargo(builder,
346343
build_compiler,
347344
target,
@@ -352,7 +349,10 @@ impl Step for Rustdoc {
352349
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
353350
.env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string());
354351

352+
let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));
353+
println!("Building rustdoc for stage{} ({})", target_compiler.stage, target_compiler.host);
355354
build.run(&mut cargo);
355+
356356
// Cargo adds a number of paths to the dylib search path on windows, which results in
357357
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
358358
// rustdoc a different name.

0 commit comments

Comments
 (0)