Skip to content

Commit 6bee514

Browse files
committed
mk: Simplify boostrap key strategy
Since PR #32731 we’re hardcoding the BOOTSTRAP_KEY to a well known value, so there’s no reason to have any key at all. Lets just use a regular environment variable instead. Hooray for simpler code.
1 parent 8694b4f commit 6bee514

File tree

5 files changed

+8
-32
lines changed

5 files changed

+8
-32
lines changed

mk/main.mk

+1-13
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ CFG_PRERELEASE_VERSION=.1
2424
# versions in the same place
2525
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
2626

27-
# A magic value that allows the compiler to use unstable features during the
28-
# bootstrap even when doing so would normally be an error because of feature
29-
# staging or because the build turns on warnings-as-errors and unstable features
30-
# default to warnings. The build has to match this key in an env var.
31-
#
32-
# This value is keyed off the release to ensure that all compilers for one
33-
# particular release have the same bootstrap key. Note that this is
34-
# intentionally not "secure" by any definition, this is largely just a deterrent
35-
# from users enabling unstable features on the stable compiler.
36-
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
37-
3827
ifeq ($(CFG_RELEASE_CHANNEL),stable)
3928
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
4029
CFG_RELEASE=$(CFG_RELEASE_NUM)
@@ -374,9 +363,8 @@ CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATUR
374363
# Turn on feature-staging
375364
export CFG_DISABLE_UNSTABLE_FEATURES
376365
# Subvert unstable feature lints to do the self-build
377-
export RUSTC_BOOTSTRAP_KEY:=$(CFG_BOOTSTRAP_KEY)
366+
export RUSTC_BOOTSTRAP
378367
endif
379-
export CFG_BOOTSTRAP_KEY
380368
ifdef CFG_MUSL_ROOT
381369
export CFG_MUSL_ROOT
382370
endif

src/bootstrap/build/channel.rs

-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
use std::fs::{self, File};
1212
use std::io::prelude::*;
13-
use std::path::Path;
1413
use std::process::Command;
1514

1615
use build_helper::output;
1716

1817
use build::Build;
19-
use build::util::mtime;
2018

2119
pub fn collect(build: &mut Build) {
2220
let mut main_mk = String::new();
@@ -79,8 +77,4 @@ pub fn collect(build: &mut Build) {
7977
build.ver_hash = Some(ver_hash);
8078
build.short_ver_hash = Some(short_ver_hash);
8179
}
82-
83-
build.bootstrap_key = mtime(Path::new("config.toml")).seconds()
84-
.to_string();
8580
}
86-

src/bootstrap/build/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
177177
cargo.env("CFG_RELEASE", &build.release)
178178
.env("CFG_RELEASE_CHANNEL", &build.config.channel)
179179
.env("CFG_VERSION", &build.version)
180-
.env("CFG_BOOTSTRAP_KEY", &build.bootstrap_key)
181180
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(String::new()))
182-
.env("RUSTC_BOOTSTRAP_KEY", &build.bootstrap_key)
181+
.env("RUSTC_BOOTSTRAP", "")
183182
.env("CFG_LIBDIR_RELATIVE", "lib");
184183

185184
if let Some(ref ver_date) = build.ver_date {

src/bootstrap/build/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub struct Build {
7878
ver_date: Option<String>,
7979
version: String,
8080
package_vers: String,
81-
bootstrap_key: String,
8281

8382
// Runtime state filled in later on
8483
cc: HashMap<String, (gcc::Tool, PathBuf)>,
@@ -123,7 +122,6 @@ impl Build {
123122
short_ver_hash: None,
124123
ver_date: None,
125124
version: String::new(),
126-
bootstrap_key: String::new(),
127125
package_vers: String::new(),
128126
cc: HashMap::new(),
129127
cxx: HashMap::new(),

src/librustc/session/config.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1256,15 +1256,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
12561256
pub fn get_unstable_features_setting() -> UnstableFeatures {
12571257
// Whether this is a feature-staged build, i.e. on the beta or stable channel
12581258
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
1259-
// The secret key needed to get through the rustc build itself by
1260-
// subverting the unstable features lints
1261-
let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
1262-
// The matching key to the above, only known by the build system
1263-
let bootstrap_provided_key = env::var("RUSTC_BOOTSTRAP_KEY").ok();
1264-
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
1265-
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
1266-
(true, _, _) => UnstableFeatures::Disallow,
1267-
(false, _, _) => UnstableFeatures::Allow
1259+
// Check whether we want to circumvent the unstable feature kill-switch for bootstrap
1260+
let bootstrap_circumvent = env::var_os("RUSTC_BOOTSTRAP").is_some();
1261+
match (disable_unstable_features, bootstrap_circumvent) {
1262+
(_, true) => UnstableFeatures::Cheat,
1263+
(true, _) => UnstableFeatures::Disallow,
1264+
(false, _) => UnstableFeatures::Allow
12681265
}
12691266
}
12701267

0 commit comments

Comments
 (0)