Created
May 15, 2016 21:23
-
-
Save cuviper/5e35ff74c41f575d24c9940a03eb9d32 to your computer and use it in GitHub Desktop.
WIP Rust #29556
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure b/configure | |
index 38f3e3b00c6d..bcb0b0fded8a 100755 | |
--- a/configure | |
+++ b/configure | |
@@ -599,6 +599,7 @@ opt debug-assertions 0 "build with debugging assertions" | |
opt fast-make 0 "use .gitmodules as timestamp for submodule deps" | |
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds" | |
opt local-rust 0 "use an installed rustc rather than downloading a snapshot" | |
+opt local-rebuild 0 "use an installed rustc matching the current version, for rebuilds" | |
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM" | |
opt rpath 1 "build rpaths into rustc itself" | |
opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0" | |
@@ -847,6 +848,15 @@ then | |
BIN_SUF=.exe | |
fi | |
+if [ -n "$CFG_ENABLE_LOCAL_REBUILD" ] | |
+then | |
+ if [ -z "$CFG_ENABLE_LOCAL_RUST" ] | |
+ then | |
+ CFG_ENABLE_LOCAL_RUST=1 | |
+ putvar CFG_ENABLE_LOCAL_RUST | |
+ fi | |
+fi | |
+ | |
if [ -n "$CFG_ENABLE_LOCAL_RUST" ] | |
then | |
system_rustc=$(which rustc) | |
diff --git a/mk/main.mk b/mk/main.mk | |
index 493b61051331..15092925b15d 100644 | |
--- a/mk/main.mk | |
+++ b/mk/main.mk | |
@@ -34,7 +34,11 @@ CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(C | |
# intentionally not "secure" by any definition, this is largely just a deterrent | |
# from users enabling unstable features on the stable compiler. | |
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA) | |
+ifdef CFG_ENABLE_LOCAL_REBUILD | |
+CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY) | |
+else | |
CFG_BOOTSTRAP_KEY_STAGE0=$(shell grep 'rustc_key' $(S)src/stage0.txt | sed 's/rustc_key: '//) | |
+endif | |
ifeq ($(CFG_RELEASE_CHANNEL),stable) | |
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly" | |
@@ -526,6 +530,11 @@ ifneq ($(strip $(CFG_BUILD)),$(strip $(3))) | |
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1 | |
RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR1_T_$(2)_H_$$(CFG_BUILD)) | |
+else | |
+ifdef CFG_ENABLE_LOCAL_REBUILD | |
+# Use the local compiler as if it were effectively stage1 too. | |
+CFGFLAG$(1)_T_$(2)_H_$(3) = stage1 | |
+endif | |
endif | |
endif | |
diff --git a/src/bootstrap/build/config.rs b/src/bootstrap/build/config.rs | |
index 533c1c93d5bc..dd5e6e8e3939 100644 | |
--- a/src/bootstrap/build/config.rs | |
+++ b/src/bootstrap/build/config.rs | |
@@ -65,6 +65,7 @@ pub struct Config { | |
pub target: Vec<String>, | |
pub rustc: Option<String>, | |
pub cargo: Option<String>, | |
+ pub rebuild: bool, | |
// libstd features | |
pub debug_jemalloc: bool, | |
@@ -306,6 +307,7 @@ impl Config { | |
("JEMALLOC", self.use_jemalloc), | |
("DEBUG_JEMALLOC", self.debug_jemalloc), | |
("RPATH", self.rust_rpath), | |
+ ("LOCAL_REBUILD", self.rebuild), | |
} | |
match key { | |
diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs | |
index 44f161fb487f..05b74dd1095f 100644 | |
--- a/src/bootstrap/build/mod.rs | |
+++ b/src/bootstrap/build/mod.rs | |
@@ -478,6 +478,11 @@ impl Build { | |
.arg("-j").arg(self.jobs().to_string()) | |
.arg("--target").arg(target); | |
+ let mut stage = compiler.stage; | |
+ if stage == 0 && self.config.rebuild { | |
+ stage = 1; | |
+ } | |
+ | |
// Customize the compiler we're running. Specify the compiler to cargo | |
// as our shim and then pass it some various options used to configure | |
// how the actual compiler itself is called. | |
@@ -486,7 +491,7 @@ impl Build { | |
// src/bootstrap/{rustc,rustdoc.rs} | |
cargo.env("RUSTC", self.out.join("bootstrap/debug/rustc")) | |
.env("RUSTC_REAL", self.compiler_path(compiler)) | |
- .env("RUSTC_STAGE", compiler.stage.to_string()) | |
+ .env("RUSTC_STAGE", stage.to_string()) | |
.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()) | |
.env("RUSTC_CODEGEN_UNITS", | |
self.config.rust_codegen_units.to_string()) | |
@@ -712,7 +717,7 @@ impl Build { | |
// In stage0 we're using a previously released stable compiler, so we | |
// use the stage0 bootstrap key. Otherwise we use our own build's | |
// bootstrap key. | |
- let bootstrap_key = if compiler.is_snapshot(self) { | |
+ let bootstrap_key = if compiler.is_snapshot(self) && !self.config.rebuild { | |
&self.bootstrap_key_stage0 | |
} else { | |
&self.bootstrap_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment