diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2024-09-24 19:02:06 +0800 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2024-09-24 19:04:51 +0800 |
| commit | 705ab171a4cc872f79753cf2b83a967baa67b7a4 (patch) | |
| tree | 71273852022f96e74bf14a986286ea963b5f6c8b | |
| parent | 6d132d9a5d526ca74db4ca4396e7e5f8c88573ae (diff) | |
| download | rust-705ab171a4cc872f79753cf2b83a967baa67b7a4.tar.gz rust-705ab171a4cc872f79753cf2b83a967baa67b7a4.zip | |
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.
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index dcbaf20796f..870fe6a9f16 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1735,6 +1735,14 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the builder.initial_cargo.clone() } else { // We need to properly build cargo using the suitable stage compiler. + + // HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if + // you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built + // and produce a cargo built with stage 2 rustc. To fix this, we need to chop off + // the compiler stage by 1 to align with expected `./x test run-make --stage N` + // behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri + // which does a similar hack. + let compiler = builder.compiler(builder.top_stage - 1, compiler.host); builder.ensure(tool::Cargo { compiler, target: compiler.host }) }; |
