diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index fb0d1811f2d..fe0c1dfb70b 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1650,7 +1650,7 @@ impl<'a> Builder<'a> { } }; cargo.env(profile_var("DEBUG"), debuginfo_level.to_string()); - if self.cc.borrow()[&target].args().iter().any(|arg| arg == "-gz") { + if !self.config.dry_run() && self.cc.borrow()[&target].args().iter().any(|arg| arg == "-gz") { rustflags.arg("-Clink-arg=-gz"); } cargo.env( diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 12ca6c79b34..8f2e7d75523 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1272,6 +1272,9 @@ pub fn compiler_file( c: CLang, file: &str, ) -> PathBuf { + if builder.config.dry_run() { + return PathBuf::new(); + } let mut cmd = Command::new(compiler); cmd.args(builder.cflags(target, GitRepo::Rustc, c)); cmd.arg(format!("-print-file-name={}", file)); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b0026aedca1..c9d256028d4 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1104,12 +1104,18 @@ impl Build { /// Returns the path to the C compiler for the target specified. fn cc(&self, target: TargetSelection) -> PathBuf { + if self.config.dry_run() { + return PathBuf::new(); + } self.cc.borrow()[&target].path().into() } /// Returns a list of flags to pass to the C compiler for the target /// specified. fn cflags(&self, target: TargetSelection, which: GitRepo, c: CLang) -> Vec { + if self.config.dry_run() { + return Vec::new(); + } let base = match c { CLang::C => self.cc.borrow()[&target].clone(), CLang::Cxx => self.cxx.borrow()[&target].clone(), @@ -1154,16 +1160,25 @@ impl Build { /// Returns the path to the `ar` archive utility for the target specified. fn ar(&self, target: TargetSelection) -> Option { + if self.config.dry_run() { + return None; + } self.ar.borrow().get(&target).cloned() } /// Returns the path to the `ranlib` utility for the target specified. fn ranlib(&self, target: TargetSelection) -> Option { + if self.config.dry_run() { + return None; + } self.ranlib.borrow().get(&target).cloned() } /// Returns the path to the C++ compiler for the target specified. fn cxx(&self, target: TargetSelection) -> Result { + if self.config.dry_run() { + return Ok(PathBuf::new()); + } match self.cxx.borrow().get(&target) { Some(p) => Ok(p.path().into()), None => { @@ -1174,6 +1189,9 @@ impl Build { /// Returns the path to the linker for the given target if it needs to be overridden. fn linker(&self, target: TargetSelection) -> Option { + if self.config.dry_run() { + return Some(PathBuf::new()); + } if let Some(linker) = self.config.target_config.get(&target).and_then(|c| c.linker.clone()) { Some(linker)