From a1f5001998ad43ee6ce5a933be737ed63317916f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Dec 2016 09:12:39 -0800 Subject: [PATCH 1/3] rustc: Use `create_dir_racy` in save analysis The OSX bots failed last night due a race condition in save analysis where concurrent calls to `fs::create_dir_all` conflicted with one another. This replaces the relevant function call with `fs::create_dir_racy` which is defined internally to the compiler. --- src/librustc_save_analysis/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 0c910240b60..862345fd46e 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -48,7 +48,7 @@ use rustc::session::config::CrateType::CrateTypeExecutable; use rustc::ty::{self, TyCtxt}; use std::env; -use std::fs::{self, File}; +use std::fs::File; use std::path::{Path, PathBuf}; use syntax::ast::{self, NodeId, PatKind, Attribute, CRATE_NODE_ID}; @@ -832,7 +832,7 @@ pub fn process_crate<'l, 'tcx>(tcx: TyCtxt<'l, 'tcx, 'tcx>, }, }; - if let Err(e) = fs::create_dir_all(&root_path) { + if let Err(e) = rustc::util::fs::create_dir_racy(&root_path) { tcx.sess.err(&format!("Could not create directory {}: {}", root_path.display(), e)); From bbf2b708932288bb720acf66fdae2711b5940937 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Dec 2016 09:17:33 -0800 Subject: [PATCH 2/3] rustbuild: Skip some more non-relevant dist steps This commit skips a few more dist tragets during compilation which shouldn't be necessary. * First, when packaging std we only take action when the host target is the build target. Otherwise we package the same artifacts a number of times, which shouldn't be necessary. * Next, we apply the same logic to the save-analysis build. This is actually required for correctness as the build compiler is the only one which actually has save analysis information. This should fix an error seen on nightlies. --- src/bootstrap/dist.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index a015f485205..245859b78d0 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -260,6 +260,14 @@ pub fn debugger_scripts(build: &Build, pub fn std(build: &Build, compiler: &Compiler, target: &str) { println!("Dist std stage{} ({} -> {})", compiler.stage, compiler.host, target); + + // The only true set of target libraries came from the build triple, so + // let's reduce redundant work by only producing archives from that host. + if compiler.host != build.config.build { + println!("\tskipping, not a build host"); + return + } + let name = format!("rust-std-{}", package_vers(build)); let image = tmpdir(build).join(format!("{}-{}-image", name, target)); let _ = fs::remove_dir_all(&image); @@ -294,10 +302,15 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) { println!("Dist analysis"); if build.config.channel != "nightly" { - println!("Skipping dist-analysis - not on nightly channel"); + println!("\tskipping - not on nightly channel"); return; } + if compiler.host != build.config.build { + println!("\tskipping - not a build host"); + return + } if compiler.stage != 2 { + println!("\tskipping - not stage2"); return } From 194c3fb1544e8bf6300989dd20f7254bad237c76 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Dec 2016 09:21:42 -0800 Subject: [PATCH 3/3] rustbuild: Don't dist docs if disabled This commit skips the `docs` dist step if the `--disable-docs` flag is passed, fixing a compile error seen on nightly. --- src/bootstrap/dist.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 245859b78d0..60352cc894e 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -48,6 +48,11 @@ pub fn tmpdir(build: &Build) -> PathBuf { /// Slurps up documentation from the `stage`'s `host`. pub fn docs(build: &Build, stage: u32, host: &str) { println!("Dist docs stage{} ({})", stage, host); + if !build.config.docs { + println!("\tskipping - docs disabled"); + return + } + let name = format!("rust-docs-{}", package_vers(build)); let image = tmpdir(build).join(format!("{}-{}-image", name, name)); let _ = fs::remove_dir_all(&image);