Skip to content

Commit

Permalink
[WIP] Don't require building a stage1 compiler before running cargotest
Browse files Browse the repository at this point in the history
- Always use a bootstrap compiler for cargo and cargo-credential helpers

  This seems wrong; I think cargo is intentionally built with stage 2
  because it's distributed with other parts of the release. However, I
  don't know how to avoid it - just changing CargoTest to build it with
  stage 0 unconditionally still builds rustc because it uses a `ToolRustc`
  mode.

- Don't call `builder.ensure(Rustc)`. It's unnecessary.
- Don't use the same compiler for building cargo as for testing.
  • Loading branch information
jyn514 committed May 1, 2021
1 parent d95a6cf commit 2266746
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ impl Step for Cargotest {
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
/// test` to ensure that we don't regress the test suites there.
fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(self.stage, self.host);
builder.ensure(compile::Rustc { compiler, target: compiler.host });
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
let bootstrap_compiler = builder.compiler(0, self.host);
let cargo = builder
.ensure(tool::Cargo { compiler: bootstrap_compiler, target: bootstrap_compiler.host });

// Note that this is a short, cryptic, and not scoped directory name. This
// is currently to minimize the length of path on Windows where we otherwise
Expand All @@ -179,13 +179,14 @@ impl Step for Cargotest {

let _time = util::timeit(&builder);
let mut cmd = builder.tool_cmd(Tool::CargoTest);
let test_compiler = builder.compiler(self.stage, self.host);
try_run(
builder,
cmd.arg(&cargo)
.arg(&out_dir)
.args(builder.config.cmd.test_args())
.env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler)),
.env("RUSTC", builder.rustc(test_compiler))
.env("RUSTDOC", builder.rustdoc(test_compiler)),
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ impl Step for Cargo {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Cargo {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler(0, run.builder.config.build),
target: run.target,
});
}
Expand All @@ -606,7 +606,7 @@ impl Step for Cargo {
compiler: self.compiler,
target: self.target,
tool: "cargo",
mode: Mode::ToolRustc,
mode: Mode::ToolBootstrap,
path: "src/tools/cargo",
is_optional_tool: false,
source_type: SourceType::Submodule,
Expand All @@ -621,7 +621,7 @@ impl Step for Cargo {
compiler: self.compiler,
target: self.target,
tool: name,
mode: Mode::ToolRustc,
mode: Mode::ToolBootstrap,
path,
is_optional_tool: true,
source_type: SourceType::Submodule,
Expand Down

0 comments on commit 2266746

Please sign in to comment.