about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-04 07:09:41 +0000
committerbors <bors@rust-lang.org>2018-03-04 07:09:41 +0000
commit4a316e7483f73ba20c0a0d2abd73d3b9da66bf2b (patch)
tree4314d2ae450448344bdea1905a5039063c808712 /src/bootstrap
parent4a7206323b70f6b146e54ae41652efbb61112024 (diff)
parentfdef6a881e784c505fc28ee85d54f72a77921410 (diff)
downloadrust-4a316e7483f73ba20c0a0d2abd73d3b9da66bf2b.tar.gz
rust-4a316e7483f73ba20c0a0d2abd73d3b9da66bf2b.zip
Auto merge of #48630 - alexcrichton:more-sccache, r=kennytm
rustbuild: Pass `ccache` to build scripts

This is a re-attempt at #48192 hopefully this time with 100% less randomly
[blocking builds for 20 minutes][block]. To work around #48192 the sccache
server is started in the `run.sh` script very early on in the compilation
process.

[block]: https://github.com/rust-lang/rust/issues/48192
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 8cbb1f3d0e9..22656e5a9da 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -688,9 +688,25 @@ impl<'a> Builder<'a> {
         //
         // FIXME: the guard against msvc shouldn't need to be here
         if !target.contains("msvc") {
-            let cc = self.cc(target);
-            cargo.env(format!("CC_{}", target), cc)
-                 .env("CC", cc);
+            let ccache = self.config.ccache.as_ref();
+            let ccacheify = |s: &Path| {
+                let ccache = match ccache {
+                    Some(ref s) => s,
+                    None => return s.display().to_string(),
+                };
+                // FIXME: the cc-rs crate only recognizes the literal strings
+                // `ccache` and `sccache` when doing caching compilations, so we
+                // mirror that here. It should probably be fixed upstream to
+                // accept a new env var or otherwise work with custom ccache
+                // vars.
+                match &ccache[..] {
+                    "ccache" | "sccache" => format!("{} {}", ccache, s.display()),
+                    _ => s.display().to_string(),
+                }
+            };
+            let cc = ccacheify(&self.cc(target));
+            cargo.env(format!("CC_{}", target), &cc)
+                 .env("CC", &cc);
 
             let cflags = self.cflags(target).join(" ");
             cargo.env(format!("CFLAGS_{}", target), cflags.clone())
@@ -705,8 +721,9 @@ impl<'a> Builder<'a> {
             }
 
             if let Ok(cxx) = self.cxx(target) {
-                cargo.env(format!("CXX_{}", target), cxx)
-                     .env("CXX", cxx)
+                let cxx = ccacheify(&cxx);
+                cargo.env(format!("CXX_{}", target), &cxx)
+                     .env("CXX", &cxx)
                      .env(format!("CXXFLAGS_{}", target), cflags.clone())
                      .env("CXXFLAGS", cflags);
             }