Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions src/bootstrap/src/core/build_steps/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ pub fn perf(builder: &Builder<'_>, args: &PerfArgs) {
target: builder.config.host_target,
});

let rustc_perf_dir = builder.build.tempdir().join("rustc-perf");
let results_dir = rustc_perf_dir.join("results");
builder.create_dir(&results_dir);

let mut cmd = command(collector.tool_path);

// We need to set the working directory to `src/tools/rustc-perf`, so that it can find the directory
// with compile-time benchmarks.
cmd.current_dir(builder.src.join("src/tools/rustc-perf"));

let db_path = results_dir.join("results.db");

let is_profiling = match &args.cmd {
PerfCommand::Eprintln { .. }
| PerfCommand::Samply { .. }
Expand All @@ -151,32 +163,23 @@ pub fn perf(builder: &Builder<'_>, args: &PerfArgs) {
Consider setting `rust.debuginfo-level = 1` in `bootstrap.toml`."#);
}

let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
builder.std(compiler, builder.config.host_target);

if let Some(opts) = args.cmd.shared_opts()
&& opts.profiles.contains(&Profile::Doc)
{
builder.ensure(Rustdoc { target_compiler: compiler });
}
let prepare_rustc = || {
let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
builder.std(compiler, builder.config.host_target);

let sysroot = builder.ensure(Sysroot::new(compiler));
let mut rustc = sysroot.clone();
rustc.push("bin");
rustc.push("rustc");
rustc.set_extension(EXE_EXTENSION);

let rustc_perf_dir = builder.build.tempdir().join("rustc-perf");
let results_dir = rustc_perf_dir.join("results");
builder.create_dir(&results_dir);

let mut cmd = command(collector.tool_path);

// We need to set the working directory to `src/tools/rustc-perf`, so that it can find the directory
// with compile-time benchmarks.
cmd.current_dir(builder.src.join("src/tools/rustc-perf"));
if let Some(opts) = args.cmd.shared_opts()
&& opts.profiles.contains(&Profile::Doc)
{
builder.ensure(Rustdoc { target_compiler: compiler });
}

let db_path = results_dir.join("results.db");
let sysroot = builder.ensure(Sysroot::new(compiler));
let mut rustc = sysroot.clone();
rustc.push("bin");
rustc.push("rustc");
rustc.set_extension(EXE_EXTENSION);
rustc
};

match &args.cmd {
PerfCommand::Eprintln { opts }
Expand All @@ -191,7 +194,7 @@ Consider setting `rust.debuginfo-level = 1` in `bootstrap.toml`."#);
});

cmd.arg("--out-dir").arg(&results_dir);
cmd.arg(rustc);
cmd.arg(prepare_rustc());

apply_shared_opts(&mut cmd, opts);
cmd.run(builder);
Expand All @@ -202,7 +205,7 @@ Consider setting `rust.debuginfo-level = 1` in `bootstrap.toml`."#);
cmd.arg("bench_local");
cmd.arg("--db").arg(&db_path);
cmd.arg("--id").arg(id);
cmd.arg(rustc);
cmd.arg(prepare_rustc());

apply_shared_opts(&mut cmd, opts);
cmd.run(builder);
Expand Down
Loading