Skip to content

Commit b4c17d4

Browse files
authored
Rollup merge of rust-lang#97277 - jyn514:no-unstable-for-bootstrap, r=Mark-Simulacrum
Avoid accidentally enabling unstable features in compilers (take 2) This allows rustbuild to control whether crates can use nightly features or not. It also prevents rustbuild from using nightly features itself. This is rust-lang#92261, but I fixed the CI error.
2 parents c370e30 + 751ad4a commit b4c17d4

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/bootstrap/bootstrap.py

-1
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,6 @@ def bootstrap(help_triggered):
11921192
env = os.environ.copy()
11931193
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
11941194
env["BOOTSTRAP_PYTHON"] = sys.executable
1195-
env["RUSTC_BOOTSTRAP"] = '1'
11961195
if build.rustc_commit is not None:
11971196
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
11981197
run(args, env=env, verbose=build.verbose, is_bootstrap=True)

src/bootstrap/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,14 @@ impl<'a> Builder<'a> {
12261226
// this), as well as #63012 which is the tracking issue for this
12271227
// feature on the rustc side.
12281228
cargo.arg("-Zbinary-dep-depinfo");
1229+
match mode {
1230+
Mode::ToolBootstrap => {
1231+
// Restrict the allowed features to those passed by rustbuild, so we don't depend on nightly accidentally.
1232+
// HACK: because anyhow does feature detection in build.rs, we need to allow the backtrace feature too.
1233+
rustflags.arg("-Zallow-features=binary-dep-depinfo,backtrace");
1234+
}
1235+
Mode::Std | Mode::Rustc | Mode::ToolStd | Mode::Codegen | Mode::ToolRustc => {}
1236+
}
12291237

12301238
cargo.arg("-j").arg(self.jobs().to_string());
12311239
// Remove make-related flags to ensure Cargo can correctly set things up

src/bootstrap/doc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,10 @@ impl Step for RustcBook {
881881
if self.validate {
882882
cmd.arg("--validate");
883883
}
884+
if !builder.unstable_features() {
885+
// We need to validate nightly features, even on the stable channel.
886+
cmd.env("RUSTC_BOOTSTRAP", "1");
887+
}
884888
// If the lib directories are in an unusual location (changed in
885889
// config.toml), then this needs to explicitly update the dylib search
886890
// path.

0 commit comments

Comments
 (0)