Skip to content

Commit

Permalink
Rollup merge of rust-lang#97277 - jyn514:no-unstable-for-bootstrap, r…
Browse files Browse the repository at this point in the history
…=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.
  • Loading branch information
jackh726 authored May 22, 2022
2 parents c370e30 + 751ad4a commit b4c17d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ def bootstrap(help_triggered):
env = os.environ.copy()
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
env["BOOTSTRAP_PYTHON"] = sys.executable
env["RUSTC_BOOTSTRAP"] = '1'
if build.rustc_commit is not None:
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
run(args, env=env, verbose=build.verbose, is_bootstrap=True)
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,14 @@ impl<'a> Builder<'a> {
// this), as well as #63012 which is the tracking issue for this
// feature on the rustc side.
cargo.arg("-Zbinary-dep-depinfo");
match mode {
Mode::ToolBootstrap => {
// Restrict the allowed features to those passed by rustbuild, so we don't depend on nightly accidentally.
// HACK: because anyhow does feature detection in build.rs, we need to allow the backtrace feature too.
rustflags.arg("-Zallow-features=binary-dep-depinfo,backtrace");
}
Mode::Std | Mode::Rustc | Mode::ToolStd | Mode::Codegen | Mode::ToolRustc => {}
}

cargo.arg("-j").arg(self.jobs().to_string());
// Remove make-related flags to ensure Cargo can correctly set things up
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ impl Step for RustcBook {
if self.validate {
cmd.arg("--validate");
}
if !builder.unstable_features() {
// We need to validate nightly features, even on the stable channel.
cmd.env("RUSTC_BOOTSTRAP", "1");
}
// If the lib directories are in an unusual location (changed in
// config.toml), then this needs to explicitly update the dylib search
// path.
Expand Down

0 comments on commit b4c17d4

Please sign in to comment.