Skip to content

Commit bbff336

Browse files
committed
rustbuild: If local-rust is the same as the current version, then force a local-rebuild
1 parent c850470 commit bbff336

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/bootstrap/lib.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub struct Build {
118118
ver_date: Option<String>,
119119
version: String,
120120
package_vers: String,
121+
local_rebuild: bool,
121122
bootstrap_key: String,
122123
bootstrap_key_stage0: String,
123124

@@ -174,6 +175,7 @@ impl Build {
174175
Some(ref s) => PathBuf::from(s),
175176
None => stage0_root.join(exe("cargo", &config.build)),
176177
};
178+
let local_rebuild = config.local_rebuild;
177179

178180
Build {
179181
flags: flags,
@@ -189,6 +191,7 @@ impl Build {
189191
short_ver_hash: None,
190192
ver_date: None,
191193
version: String::new(),
194+
local_rebuild: local_rebuild,
192195
bootstrap_key: String::new(),
193196
bootstrap_key_stage0: String::new(),
194197
package_vers: String::new(),
@@ -219,6 +222,16 @@ impl Build {
219222
sanity::check(self);
220223
self.verbose("collecting channel variables");
221224
channel::collect(self);
225+
// If local-rust is the same as the current version, then force a local-rebuild
226+
let local_version_verbose = output(
227+
Command::new(&self.rustc).arg("--version").arg("--verbose"));
228+
let local_release = local_version_verbose
229+
.lines().filter(|x| x.starts_with("release:"))
230+
.next().unwrap().trim_left_matches("release:").trim();
231+
if local_release == self.release {
232+
self.verbose(&format!("auto-detected local-rebuild {}", self.release));
233+
self.local_rebuild = true;
234+
}
222235
self.verbose("updating submodules");
223236
self.update_submodules();
224237

@@ -525,7 +538,7 @@ impl Build {
525538
.arg("--target").arg(target);
526539

527540
let stage;
528-
if compiler.stage == 0 && self.config.local_rebuild {
541+
if compiler.stage == 0 && self.local_rebuild {
529542
// Assume the local-rebuild rustc already has stage1 features.
530543
stage = 1;
531544
} else {
@@ -766,7 +779,7 @@ impl Build {
766779
// In stage0 we're using a previously released stable compiler, so we
767780
// use the stage0 bootstrap key. Otherwise we use our own build's
768781
// bootstrap key.
769-
let bootstrap_key = if compiler.is_snapshot(self) && !self.config.local_rebuild {
782+
let bootstrap_key = if compiler.is_snapshot(self) && !self.local_rebuild {
770783
&self.bootstrap_key_stage0
771784
} else {
772785
&self.bootstrap_key

0 commit comments

Comments
 (0)