Skip to content

Commit 705ab17

Browse files
committed
Fix tool cargo being off-by-one from rustc staging
Previously if you pass compiler stage 1 to `tool::Cargo`, it will build stage2 rustc and give you back a cargo built with stage2 rustc, which is not what we want. This commit adds a hack that chops off a stage from the compiler passed to `tool::Cargo`, meaning that we will get a cargo built with stage 1 compiler, avoiding unnecessary and incorrect build of stage2 rustc and the cargo built by that.
1 parent 6d132d9 commit 705ab17

File tree

1 file changed

+8
-0
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+8
-0
lines changed

src/bootstrap/src/core/build_steps/test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,14 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17351735
builder.initial_cargo.clone()
17361736
} else {
17371737
// We need to properly build cargo using the suitable stage compiler.
1738+
1739+
// HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if
1740+
// you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built
1741+
// and produce a cargo built with stage 2 rustc. To fix this, we need to chop off
1742+
// the compiler stage by 1 to align with expected `./x test run-make --stage N`
1743+
// behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri
1744+
// which does a similar hack.
1745+
let compiler = builder.compiler(builder.top_stage - 1, compiler.host);
17381746
builder.ensure(tool::Cargo { compiler, target: compiler.host })
17391747
};
17401748

0 commit comments

Comments
 (0)