Skip to content

Commit 38708e5

Browse files
authored
Rollup merge of rust-lang#37265 - brson:bootstrap, r=alexcrichton
Allow bootstrapping without a key. Fixes rust-lang#36548 This will make it easier for packagers to bootstrap rustc when they happen to have a bootstrap compiler with a slightly different version number. It's not ok for anything other than the build system to set this environment variable. r? @alexcrichton
2 parents e1d2999 + d3c5905 commit 38708e5

File tree

7 files changed

+19
-66
lines changed

7 files changed

+19
-66
lines changed

mk/main.mk

+5-21
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ endif
5353
# versions in the same place
5454
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
5555

56-
# A magic value that allows the compiler to use unstable features during the
57-
# bootstrap even when doing so would normally be an error because of feature
58-
# staging or because the build turns on warnings-as-errors and unstable features
59-
# default to warnings. The build has to match this key in an env var.
60-
#
61-
# This value is keyed off the release to ensure that all compilers for one
62-
# particular release have the same bootstrap key. Note that this is
63-
# intentionally not "secure" by any definition, this is largely just a deterrent
64-
# from users enabling unstable features on the stable compiler.
65-
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
66-
6756
# If local-rust is the same as the current version, then force a local-rebuild
6857
ifdef CFG_ENABLE_LOCAL_RUST
6958
ifeq ($(CFG_RELEASE),\
@@ -73,14 +62,6 @@ ifeq ($(CFG_RELEASE),\
7362
endif
7463
endif
7564

76-
# The stage0 compiler needs to use the previous key recorded in src/stage0.txt,
77-
# except for local-rebuild when it just uses the same current key.
78-
ifdef CFG_ENABLE_LOCAL_REBUILD
79-
CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY)
80-
else
81-
CFG_BOOTSTRAP_KEY_STAGE0=$(shell sed -ne 's/^rustc_key: //p' $(S)src/stage0.txt)
82-
endif
83-
8465
# The name of the package to use for creating tarballs, installers etc.
8566
CFG_PACKAGE_NAME=rustc-$(CFG_PACKAGE_VERS)
8667

@@ -387,13 +368,16 @@ CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATUR
387368
# Turn on feature-staging
388369
export CFG_DISABLE_UNSTABLE_FEATURES
389370
# Subvert unstable feature lints to do the self-build
390-
export RUSTC_BOOTSTRAP_KEY:=$(CFG_BOOTSTRAP_KEY)
371+
export RUSTC_BOOTSTRAP
391372
endif
392-
export CFG_BOOTSTRAP_KEY
393373
ifdef CFG_MUSL_ROOT
394374
export CFG_MUSL_ROOT
395375
endif
396376

377+
# FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
378+
# Remove this once the bootstrap compiler uses the new login in Issue #36548.
379+
export RUSTC_BOOTSTRAP_KEY=62b3e239
380+
397381
######################################################################
398382
# Per-stage targets and runner
399383
######################################################################

mk/target.mk

-21
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@ $(foreach host,$(CFG_HOST), \
4242
$(foreach crate,$(CRATES), \
4343
$(eval $(call RUST_CRATE_FULLDEPS,$(stage),$(target),$(host),$(crate)))))))
4444

45-
# $(1) stage
46-
# $(2) target
47-
# $(3) host
48-
define DEFINE_BOOTSTRAP_KEY
49-
BOOTSTRAP_KEY$(1)_T_$(2)_H_$(3) := $$(CFG_BOOTSTRAP_KEY)
50-
ifeq ($(1),0)
51-
ifeq ($(3),$$(CFG_BUILD))
52-
BOOTSTRAP_KEY$(1)_T_$(2)_H_$(3) := $$(CFG_BOOTSTRAP_KEY_STAGE0)
53-
endif
54-
endif
55-
endef
56-
57-
$(foreach host,$(CFG_TARGET), \
58-
$(foreach target,$(CFG_TARGET), \
59-
$(foreach stage,$(STAGES), \
60-
$(eval $(call DEFINE_BOOTSTRAP_KEY,$(stage),$(target),$(host))))))
61-
6245
# RUST_TARGET_STAGE_N template: This defines how target artifacts are built
6346
# for all stage/target architecture combinations. This is one giant rule which
6447
# works as follows:
@@ -83,8 +66,6 @@ $(foreach host,$(CFG_TARGET), \
8366
define RUST_TARGET_STAGE_N
8467

8568
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): CFG_COMPILER_HOST_TRIPLE = $(2)
86-
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
87-
export RUSTC_BOOTSTRAP_KEY := $$(BOOTSTRAP_KEY$(1)_T_$(2)_H_$(3))
8869
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8970
$$(CRATEFILE_$(4)) \
9071
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
@@ -132,8 +113,6 @@ endef
132113
# $(4) - name of the tool being built
133114
define TARGET_TOOL
134115

135-
$$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
136-
export RUSTC_BOOTSTRAP_KEY := $$(BOOTSTRAP_KEY$(1)_T_$(2)_H_$(3))
137116
$$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
138117
$$(TOOL_SOURCE_$(4)) \
139118
$$(TOOL_INPUTS_$(4)) \

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn compiletest(build: &Build,
214214
}
215215
}
216216
}
217-
build.add_bootstrap_key(compiler, &mut cmd);
217+
build.add_bootstrap_key(&mut cmd);
218218

219219
cmd.arg("--adb-path").arg("adb");
220220
cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);

src/bootstrap/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
119119
for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
120120
let file = t!(file);
121121
let mut cmd = Command::new(&compiler_path);
122-
build.add_bootstrap_key(&compiler, &mut cmd);
122+
build.add_bootstrap_key(&mut cmd);
123123
build.run(cmd.arg("--target").arg(target)
124124
.arg("--emit=obj")
125125
.arg("--out-dir").arg(into)
@@ -185,7 +185,6 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
185185
cargo.env("CFG_RELEASE", &build.release)
186186
.env("CFG_RELEASE_CHANNEL", &build.config.channel)
187187
.env("CFG_VERSION", &build.version)
188-
.env("CFG_BOOTSTRAP_KEY", &build.bootstrap_key)
189188
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(String::new()))
190189
.env("CFG_LIBDIR_RELATIVE", "lib");
191190

src/bootstrap/lib.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl Build {
662662
.env("RUSTDOC_REAL", self.rustdoc(compiler))
663663
.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
664664

665-
self.add_bootstrap_key(compiler, &mut cargo);
665+
self.add_bootstrap_key(&mut cargo);
666666

667667
// Specify some various options for build scripts used throughout
668668
// the build.
@@ -871,16 +871,11 @@ impl Build {
871871
}
872872

873873
/// Adds the compiler's bootstrap key to the environment of `cmd`.
874-
fn add_bootstrap_key(&self, compiler: &Compiler, cmd: &mut Command) {
875-
// In stage0 we're using a previously released stable compiler, so we
876-
// use the stage0 bootstrap key. Otherwise we use our own build's
877-
// bootstrap key.
878-
let bootstrap_key = if compiler.is_snapshot(self) && !self.local_rebuild {
879-
&self.bootstrap_key_stage0
880-
} else {
881-
&self.bootstrap_key
882-
};
883-
cmd.env("RUSTC_BOOTSTRAP_KEY", bootstrap_key);
874+
fn add_bootstrap_key(&self, cmd: &mut Command) {
875+
cmd.env("RUSTC_BOOTSTRAP", "");
876+
// FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
877+
// Remove this once the bootstrap compiler uses the new login in Issue #36548.
878+
cmd.env("RUSTC_BOOTSTRAP_KEY", "62b3e239");
884879
}
885880

886881
/// Returns the compiler's libdir where it stores the dynamic libraries that

src/libsyntax/feature_gate.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1330,15 +1330,12 @@ impl UnstableFeatures {
13301330
pub fn from_environment() -> UnstableFeatures {
13311331
// Whether this is a feature-staged build, i.e. on the beta or stable channel
13321332
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
1333-
// The secret key needed to get through the rustc build itself by
1334-
// subverting the unstable features lints
1335-
let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
1336-
// The matching key to the above, only known by the build system
1337-
let bootstrap_provided_key = env::var("RUSTC_BOOTSTRAP_KEY").ok();
1338-
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
1339-
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
1340-
(true, _, _) => UnstableFeatures::Disallow,
1341-
(false, _, _) => UnstableFeatures::Allow
1333+
// Whether we should enable unstable features for bootstrapping
1334+
let bootstrap = env::var("RUSTC_BOOTSTRAP").is_ok();
1335+
match (disable_unstable_features, bootstrap) {
1336+
(_, true) => UnstableFeatures::Cheat,
1337+
(true, _) => UnstableFeatures::Disallow,
1338+
(false, _) => UnstableFeatures::Allow
13421339
}
13431340
}
13441341

src/stage0.txt

-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
# released on `$date`
1414

1515
rustc: beta-2016-09-28
16-
rustc_key: 62b3e239
1716
cargo: nightly-2016-09-26

0 commit comments

Comments
 (0)