From 65fb7be72820f9be7ee7bb8e626e1d0fbb03968d Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 14 Jul 2016 17:13:13 +0200 Subject: [PATCH 1/3] mk: Move some definitions after their dependencies, to be visually less confusing --- mk/main.mk | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/mk/main.mk b/mk/main.mk index 4c72597f0c5c1..e446b64a6f5af 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -20,29 +20,6 @@ CFG_RELEASE_NUM=1.12.0 # versions (section 9) CFG_PRERELEASE_VERSION=.1 -# Append a version-dependent hash to each library, so we can install different -# versions in the same place -CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND)) - -# A magic value that allows the compiler to use unstable features during the -# bootstrap even when doing so would normally be an error because of feature -# staging or because the build turns on warnings-as-errors and unstable features -# default to warnings. The build has to match this key in an env var. -# -# This value is keyed off the release to ensure that all compilers for one -# particular release have the same bootstrap key. Note that this is -# 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) - -# The stage0 compiler needs to use the previous key recorded in src/stage0.txt, -# except for local-rebuild when it just uses the same current key. -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" CFG_RELEASE=$(CFG_RELEASE_NUM) @@ -72,6 +49,29 @@ CFG_RELEASE=$(CFG_RELEASE_NUM)-dev CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev endif +# Append a version-dependent hash to each library, so we can install different +# versions in the same place +CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND)) + +# A magic value that allows the compiler to use unstable features during the +# bootstrap even when doing so would normally be an error because of feature +# staging or because the build turns on warnings-as-errors and unstable features +# default to warnings. The build has to match this key in an env var. +# +# This value is keyed off the release to ensure that all compilers for one +# particular release have the same bootstrap key. Note that this is +# 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) + +# The stage0 compiler needs to use the previous key recorded in src/stage0.txt, +# except for local-rebuild when it just uses the same current key. +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 + # The name of the package to use for creating tarballs, installers etc. CFG_PACKAGE_NAME=rustc-$(CFG_PACKAGE_VERS) From c850470f73b21d55842801f69e83546d7dd727a7 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 14 Jul 2016 19:32:53 +0200 Subject: [PATCH 2/3] mk: If local-rust is the same as the current version, then force a local-rebuild --- configure | 2 +- mk/main.mk | 11 ++++++++++- mk/stage0.mk | 1 + src/etc/local_stage0.sh | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 16496eb89d4ca..fd009a757a4b7 100755 --- a/configure +++ b/configure @@ -600,7 +600,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 local-rebuild 0 "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version" 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" diff --git a/mk/main.mk b/mk/main.mk index e446b64a6f5af..fd12bf26dfc72 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -64,12 +64,21 @@ CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(C # from users enabling unstable features on the stable compiler. CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA) +# If local-rust is the same as the current version, then force a local-rebuild +ifdef CFG_ENABLE_LOCAL_RUST +ifeq ($(CFG_RELEASE),\ + $(shell $(S)src/etc/local_stage0.sh --print-rustc-release $(CFG_LOCAL_RUST_ROOT))) + CFG_INFO := $(info cfg: auto-detected local-rebuild $(CFG_RELEASE)) + CFG_ENABLE_LOCAL_REBUILD = 1 +endif +endif + # The stage0 compiler needs to use the previous key recorded in src/stage0.txt, # except for local-rebuild when it just uses the same current key. 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: '//) +CFG_BOOTSTRAP_KEY_STAGE0=$(shell sed -ne 's/^rustc_key: //p' $(S)src/stage0.txt) endif # The name of the package to use for creating tarballs, installers etc. diff --git a/mk/stage0.mk b/mk/stage0.mk index d0191874cb3d9..8a2bf2ebbde64 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -11,6 +11,7 @@ endif $(SNAPSHOT_RUSTC_POST_CLEANUP): \ $(S)src/stage0.txt \ + $(S)src/etc/local_stage0.sh \ $(S)src/etc/get-stage0.py $(MKFILE_DEPS) \ | $(HBIN0_H_$(CFG_BUILD))/ @$(call E, fetch: $@) diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh index fb455441910b8..354be34b6a295 100755 --- a/src/etc/local_stage0.sh +++ b/src/etc/local_stage0.sh @@ -49,6 +49,13 @@ if [ -z $TARG_DIR ]; then exit 1 fi +case "$TARG_DIR" in +--print-rustc-release) + # not actually copying to TARG_DIR, just print the local rustc version and exit + ${PREFIX}/bin/rustc${BIN_SUF} --version --verbose | sed -ne 's/^release: //p' +;; +*) + cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/ cp ${PREFIX}/${LIB_DIR}/${RUSTLIBDIR}/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/ @@ -66,3 +73,5 @@ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}term*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DI # do not fail if one of the above fails, as all we need is a working rustc! exit 0 + +esac From bbff3367fe0355dbdee466bd7d3e0ea241799a9f Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 14 Jul 2016 19:39:55 +0200 Subject: [PATCH 3/3] rustbuild: If local-rust is the same as the current version, then force a local-rebuild --- src/bootstrap/lib.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 943271fc8a641..caa6ea17ea054 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -118,6 +118,7 @@ pub struct Build { ver_date: Option, version: String, package_vers: String, + local_rebuild: bool, bootstrap_key: String, bootstrap_key_stage0: String, @@ -174,6 +175,7 @@ impl Build { Some(ref s) => PathBuf::from(s), None => stage0_root.join(exe("cargo", &config.build)), }; + let local_rebuild = config.local_rebuild; Build { flags: flags, @@ -189,6 +191,7 @@ impl Build { short_ver_hash: None, ver_date: None, version: String::new(), + local_rebuild: local_rebuild, bootstrap_key: String::new(), bootstrap_key_stage0: String::new(), package_vers: String::new(), @@ -219,6 +222,16 @@ impl Build { sanity::check(self); self.verbose("collecting channel variables"); channel::collect(self); + // If local-rust is the same as the current version, then force a local-rebuild + let local_version_verbose = output( + Command::new(&self.rustc).arg("--version").arg("--verbose")); + let local_release = local_version_verbose + .lines().filter(|x| x.starts_with("release:")) + .next().unwrap().trim_left_matches("release:").trim(); + if local_release == self.release { + self.verbose(&format!("auto-detected local-rebuild {}", self.release)); + self.local_rebuild = true; + } self.verbose("updating submodules"); self.update_submodules(); @@ -525,7 +538,7 @@ impl Build { .arg("--target").arg(target); let stage; - if compiler.stage == 0 && self.config.local_rebuild { + if compiler.stage == 0 && self.local_rebuild { // Assume the local-rebuild rustc already has stage1 features. stage = 1; } else { @@ -766,7 +779,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) && !self.config.local_rebuild { + let bootstrap_key = if compiler.is_snapshot(self) && !self.local_rebuild { &self.bootstrap_key_stage0 } else { &self.bootstrap_key