From 9b8b3b2b0339bbae4aad139c5dad4b46410cd784 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 7 Mar 2017 23:20:39 +0300 Subject: [PATCH 1/3] rustbuild: Add option for enabling partial LLVM rebuilds --- appveyor.yml | 8 +++---- src/bootstrap/config.rs | 4 ++++ src/bootstrap/config.toml.example | 7 ++++++ src/bootstrap/native.rs | 23 ++++++++----------- ...uto-clean-trigger => llvm-rebuild-trigger} | 2 +- 5 files changed, 26 insertions(+), 18 deletions(-) rename src/rustllvm/{llvm-auto-clean-trigger => llvm-rebuild-trigger} (66%) diff --git a/appveyor.yml b/appveyor.yml index 46ff9a252a0f6..744ef2b2b24e4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -144,10 +144,10 @@ on_failure: - cat %CD%/sccache.log cache: - - "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger" - - "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger" - - "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger" - - "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger" + - "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger" + - "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger" + - "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger" + - "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger" branches: only: diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 431d4a333d337..4b79e4beb4b8c 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -60,6 +60,7 @@ pub struct Config { pub llvm_link_shared: bool, pub llvm_targets: Option, pub llvm_link_jobs: Option, + pub llvm_clean_rebuild: bool, // rust codegen options pub rust_optimize: bool, @@ -181,6 +182,7 @@ struct Llvm { static_libstdcpp: Option, targets: Option, link_jobs: Option, + clean_rebuild: Option, } #[derive(RustcDecodable, Default, Clone)] @@ -241,6 +243,7 @@ impl Config { pub fn parse(build: &str, file: Option) -> Config { let mut config = Config::default(); config.llvm_optimize = true; + config.llvm_clean_rebuild = true; config.use_jemalloc = true; config.backtrace = true; config.rust_optimize = true; @@ -334,6 +337,7 @@ impl Config { set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo); set(&mut config.llvm_version_check, llvm.version_check); set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp); + set(&mut config.llvm_clean_rebuild, llvm.clean_rebuild); config.llvm_targets = llvm.targets.clone(); config.llvm_link_jobs = llvm.link_jobs; } diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 776bd729119e2..4e4b11fdc11a8 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -61,6 +61,13 @@ # controlled by rustbuild's -j parameter. #link-jobs = 0 +# Delete LLVM build directory on LLVM rebuild. +# This option's default (`true`) is optimized for CI needs, and CI wants to +# perform clean full builds only (possibly accelerated by (s)ccache). +# You may want to override this option for local builds to enable partial LLVM +# rebuilds. +#clean-rebuild = true + # ============================================================================= # General build configuration options # ============================================================================= diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index c13235b9c7680..a7754f2669ef0 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -41,9 +41,9 @@ pub fn llvm(build: &Build, target: &str) { } } - let clean_trigger = build.src.join("src/rustllvm/llvm-auto-clean-trigger"); - let mut clean_trigger_contents = String::new(); - t!(t!(File::open(&clean_trigger)).read_to_string(&mut clean_trigger_contents)); + let rebuild_trigger = build.src.join("src/rustllvm/llvm-rebuild-trigger"); + let mut rebuild_trigger_contents = String::new(); + t!(t!(File::open(&rebuild_trigger)).read_to_string(&mut rebuild_trigger_contents)); let out_dir = build.llvm_out(target); let done_stamp = out_dir.join("llvm-finished-building"); @@ -51,18 +51,15 @@ pub fn llvm(build: &Build, target: &str) { let mut done_contents = String::new(); t!(t!(File::open(&done_stamp)).read_to_string(&mut done_contents)); - // LLVM was already built previously. - // We don't track changes in LLVM sources, so we need to choose between reusing - // what was built previously, or cleaning the directory and doing a fresh build. - // The choice depends on contents of the clean-trigger file. - // If the contents are the same as during the previous build, then no action is required. - // If the contents differ from the previous build, then cleaning is triggered. - if done_contents == clean_trigger_contents { + // If LLVM was already built previously and contents of the rebuild-trigger file + // didn't change from the previous build, then no action is required. + if done_contents == rebuild_trigger_contents { return - } else { - t!(fs::remove_dir_all(&out_dir)); } } + if build.config.llvm_clean_rebuild { + t!(fs::remove_dir_all(&out_dir)); + } println!("Building LLVM for {}", target); let _time = util::timeit(); @@ -154,7 +151,7 @@ pub fn llvm(build: &Build, target: &str) { // tools and libs on all platforms. cfg.build(); - t!(t!(File::create(&done_stamp)).write_all(clean_trigger_contents.as_bytes())); + t!(t!(File::create(&done_stamp)).write_all(rebuild_trigger_contents.as_bytes())); } fn check_llvm_version(build: &Build, llvm_config: &Path) { diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-rebuild-trigger similarity index 66% rename from src/rustllvm/llvm-auto-clean-trigger rename to src/rustllvm/llvm-rebuild-trigger index e30ad63d52f87..aeabf4a1dd376 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-rebuild-trigger @@ -1,4 +1,4 @@ -# If this file is modified, then llvm will be forcibly cleaned and then rebuilt. +# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. 2017-03-04 From 362aa9a317127014a81c8f414ef8b26aee6acfc0 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 8 Mar 2017 16:22:08 +0300 Subject: [PATCH 2/3] Default llvm.clean-rebuild to false --- configure | 1 + src/bootstrap/config.rs | 2 +- src/bootstrap/config.toml.example | 8 +++----- src/ci/run.sh | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 9b34e214214a5..35b376d5f27b8 100755 --- a/configure +++ b/configure @@ -437,6 +437,7 @@ opt local-rust 0 "use an installed rustc rather than downloading a snapshot" 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 llvm-link-shared 0 "prefer shared linking to LLVM (llvm-config --link-shared)" +opt llvm-clean-rebuild 0 "delete LLVM build directory on rebuild" opt rpath 1 "build rpaths into rustc itself" opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0" # This is used by the automation to produce single-target nightlies diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 4b79e4beb4b8c..dcd49c51e3a99 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -243,7 +243,6 @@ impl Config { pub fn parse(build: &str, file: Option) -> Config { let mut config = Config::default(); config.llvm_optimize = true; - config.llvm_clean_rebuild = true; config.use_jemalloc = true; config.backtrace = true; config.rust_optimize = true; @@ -443,6 +442,7 @@ impl Config { ("LLVM_VERSION_CHECK", self.llvm_version_check), ("LLVM_STATIC_STDCPP", self.llvm_static_stdcpp), ("LLVM_LINK_SHARED", self.llvm_link_shared), + ("LLVM_CLEAN_REBUILD", self.llvm_clean_rebuild), ("OPTIMIZE", self.rust_optimize), ("DEBUG_ASSERTIONS", self.rust_debug_assertions), ("DEBUGINFO", self.rust_debuginfo), diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 4e4b11fdc11a8..5a00e90f370b5 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -62,11 +62,9 @@ #link-jobs = 0 # Delete LLVM build directory on LLVM rebuild. -# This option's default (`true`) is optimized for CI needs, and CI wants to -# perform clean full builds only (possibly accelerated by (s)ccache). -# You may want to override this option for local builds to enable partial LLVM -# rebuilds. -#clean-rebuild = true +# This option defaults to `false` for local development, but CI may want to +# always perform clean full builds (possibly accelerated by (s)ccache). +#clean-rebuild = false # ============================================================================= # General build configuration options diff --git a/src/ci/run.sh b/src/ci/run.sh index 4c4836d7ca230..19bea9ced0642 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -28,6 +28,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-openssl-static" +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-clean-rebuild" if [ "$DIST_SRC" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src" From 4cda4d67f169109bb0c09a2bd2abf5dfd2f41b0d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 10 Mar 2017 13:02:30 -0800 Subject: [PATCH 3/3] Allow cleaning llvm build dir to fail It may not exist, so we don't want to spuriously generate an error. --- src/bootstrap/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index a7754f2669ef0..6cc1ca8d02ed0 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -58,7 +58,7 @@ pub fn llvm(build: &Build, target: &str) { } } if build.config.llvm_clean_rebuild { - t!(fs::remove_dir_all(&out_dir)); + drop(fs::remove_dir_all(&out_dir)); } println!("Building LLVM for {}", target);