Skip to content

Commit

Permalink
Copy rustc-fake binary when building the rustc-perf tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jun 12, 2024
1 parent 9e0b762 commit fd44aca
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ impl Step for ToolBuild {
if tool == "tidy" {
tool = "rust-tidy";
}
let cargo_out = builder.cargo_out(compiler, self.mode, target).join(exe(tool, target));
let bin = builder.tools_dir(compiler).join(exe(tool, target));
builder.copy_link(&cargo_out, &bin);
bin
copy_tool_bin(builder, self.compiler, self.target, self.mode, tool)
}
}
}
Expand Down Expand Up @@ -217,6 +214,21 @@ pub fn prepare_tool_cargo(
cargo
}

/// Copies a built tool binary with the given `name` from the build directory to the
/// tools directory.
fn copy_tool_bin(
builder: &Builder<'_>,
compiler: Compiler,
target: TargetSelection,
mode: Mode,
name: &str,
) -> PathBuf {
let cargo_out = builder.cargo_out(compiler, mode, target).join(exe(name, target));
let bin = builder.tools_dir(compiler).join(exe(name, target));
builder.copy_link(&cargo_out, &bin);
bin
}

macro_rules! bootstrap_tool {
($(
$name:ident, $path:expr, $tool_name:expr
Expand Down Expand Up @@ -385,7 +397,7 @@ impl Step for RustcPerf {
// We need to ensure the rustc-perf submodule is initialized.
builder.update_submodule(Path::new("src/tools/rustc-perf"));

let target = builder.ensure(ToolBuild {
let tool = ToolBuild {
compiler: self.compiler,
target: self.target,
tool: "collector",
Expand All @@ -397,8 +409,13 @@ impl Step for RustcPerf {
// Only build the collector package, which is used for benchmarking through
// a CLI.
cargo_args: vec!["-p".to_string(), "collector".to_string()],
});
target
};
let collector_bin = builder.ensure(tool.clone());
// We also need to symlink the `rustc-fake` binary to the corresponding directory,
// because `collector` expects it in the same directory.
copy_tool_bin(builder, tool.compiler, tool.target, tool.mode, "rustc-fake");

collector_bin
}
}

Expand Down

0 comments on commit fd44aca

Please sign in to comment.