@@ -1630,6 +1630,13 @@ struct Compiletest {
1630
1630
compare_mode : Option < & ' static str > ,
1631
1631
}
1632
1632
1633
+ /// `compiletest` under `--stage 0` causes `compiletest` to be used with the beta compiler which can
1634
+ /// cause many tests to fail. This env var is needed to indicate that the user understands the risk
1635
+ /// and actually intends to use `compiletest` with `--stage 0`.
1636
+ fn compiletest_force_stage0 ( ) -> bool {
1637
+ env:: var ( "COMPILETEST_FORCE_STAGE0" ) . is_ok ( )
1638
+ }
1639
+
1633
1640
impl Step for Compiletest {
1634
1641
type Output = ( ) ;
1635
1642
@@ -1647,7 +1654,7 @@ impl Step for Compiletest {
1647
1654
return ;
1648
1655
}
1649
1656
1650
- if builder. top_stage == 0 && env :: var ( "COMPILETEST_FORCE_STAGE0" ) . is_err ( ) {
1657
+ if builder. top_stage == 0 && ! compiletest_force_stage0 ( ) {
1651
1658
eprintln ! ( "\
1652
1659
ERROR: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
1653
1660
HELP: to test the compiler, use `--stage 1` instead
@@ -1730,8 +1737,16 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1730
1737
let is_rustdoc = suite. ends_with ( "rustdoc-ui" ) || suite. ends_with ( "rustdoc-js" ) ;
1731
1738
1732
1739
if mode == "run-make" {
1733
- let cargo = builder. ensure ( tool:: Cargo { compiler, target : compiler. host } ) ;
1734
- cmd. arg ( "--cargo-path" ) . arg ( cargo) ;
1740
+ let cargo_path = if builder. top_stage == 0 && compiletest_force_stage0 ( ) {
1741
+ // If we're forcing `--stage 0`, we should provide the bootstrap cargo.
1742
+ builder. initial_cargo . clone ( )
1743
+ } else {
1744
+ // Unless we're forcing `--stage 0`, we need to properly build cargo using the
1745
+ // suitable stage compiler.
1746
+ builder. ensure ( tool:: Cargo { compiler, target : compiler. host } )
1747
+ } ;
1748
+
1749
+ cmd. arg ( "--cargo-path" ) . arg ( cargo_path) ;
1735
1750
}
1736
1751
1737
1752
// Avoid depending on rustdoc when we don't need it.
@@ -2088,8 +2103,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
2088
2103
cmd. arg ( "--rustfix-coverage" ) ;
2089
2104
}
2090
2105
2091
- cmd. env ( "BOOTSTRAP_CARGO" , & builder. initial_cargo ) ;
2092
-
2093
2106
cmd. arg ( "--channel" ) . arg ( & builder. config . channel ) ;
2094
2107
2095
2108
if !builder. config . omit_git_hash {
0 commit comments