Skip to content

Commit 23b4bf9

Browse files
authored
Rollup merge of rust-lang#49089 - alexcrichton:fix-timings, r=Mark-Simulacrum
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!
2 parents 17d39ed + 6fd4d67 commit 23b4bf9

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

@@ -841,9 +842,6 @@ impl Step for Compiletest {
841842
builder.ensure(native::TestHelpers { target });
842843
builder.ensure(RemoteCopyLibs { compiler, target });
843844

844-
let _folder = build.fold_output(|| format!("test_{}", suite));
845-
println!("Check compiletest suite={} mode={} ({} -> {})",
846-
suite, mode, &compiler.host, target);
847845
let mut cmd = builder.tool_cmd(Tool::Compiletest);
848846

849847
// compiletest currently has... a lot of arguments, so let's just pass all
@@ -1003,6 +1001,9 @@ impl Step for Compiletest {
10031001

10041002
build.ci_env.force_coloring_in_ci(&mut cmd);
10051003

1004+
let _folder = build.fold_output(|| format!("test_{}", suite));
1005+
println!("Check compiletest suite={} mode={} ({} -> {})",
1006+
suite, mode, &compiler.host, target);
10061007
let _time = util::timeit();
10071008
try_run(build, &mut cmd);
10081009
}
@@ -1147,20 +1148,21 @@ impl Step for ErrorIndex {
11471148

11481149
builder.ensure(compile::Std { compiler, target: compiler.host });
11491150

1150-
let _folder = build.fold_output(|| "test_error_index");
1151-
println!("Testing error-index stage{}", compiler.stage);
1152-
11531151
let dir = testdir(build, compiler.host);
11541152
t!(fs::create_dir_all(&dir));
11551153
let output = dir.join("error-index.md");
11561154

1157-
let _time = util::timeit();
1158-
build.run(builder.tool_cmd(Tool::ErrorIndex)
1159-
.arg("markdown")
1160-
.arg(&output)
1161-
.env("CFG_BUILD", &build.build)
1162-
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));
1155+
let mut tool = builder.tool_cmd(Tool::ErrorIndex);
1156+
tool.arg("markdown")
1157+
.arg(&output)
1158+
.env("CFG_BUILD", &build.build)
1159+
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir());
1160+
11631161

1162+
let _folder = build.fold_output(|| "test_error_index");
1163+
println!("Testing error-index stage{}", compiler.stage);
1164+
let _time = util::timeit();
1165+
build.run(&mut tool);
11641166
markdown_test(builder, compiler, &output);
11651167
}
11661168
}
@@ -1405,11 +1407,6 @@ impl Step for Crate {
14051407
}
14061408
_ => panic!("can only test libraries"),
14071409
};
1408-
let _folder = build.fold_output(|| {
1409-
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
1410-
});
1411-
println!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
1412-
&compiler.host, target);
14131410

14141411
// Build up the base `cargo test` command.
14151412
//
@@ -1441,8 +1438,6 @@ impl Step for Crate {
14411438
cargo.arg("--quiet");
14421439
}
14431440

1444-
let _time = util::timeit();
1445-
14461441
if target.contains("emscripten") {
14471442
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
14481443
build.config.nodejs.as_ref().expect("nodejs not configured"));
@@ -1470,6 +1465,13 @@ impl Step for Crate {
14701465
format!("{} run",
14711466
builder.tool_exe(Tool::RemoteTestClient).display()));
14721467
}
1468+
1469+
let _folder = build.fold_output(|| {
1470+
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
1471+
});
1472+
println!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
1473+
&compiler.host, target);
1474+
let _time = util::timeit();
14731475
try_run(build, &mut cargo);
14741476
}
14751477
}
@@ -1518,12 +1520,6 @@ impl Step for CrateRustdoc {
15181520
target,
15191521
test_kind.subcommand(),
15201522
"src/tools/rustdoc");
1521-
let _folder = build.fold_output(|| {
1522-
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1523-
});
1524-
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1525-
&compiler.host, target);
1526-
15271523
if test_kind.subcommand() == "test" && !build.fail_fast {
15281524
cargo.arg("--no-fail-fast");
15291525
}
@@ -1537,6 +1533,11 @@ impl Step for CrateRustdoc {
15371533
cargo.arg("--quiet");
15381534
}
15391535

1536+
let _folder = build.fold_output(|| {
1537+
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1538+
});
1539+
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1540+
&compiler.host, target);
15401541
let _time = util::timeit();
15411542

15421543
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)