diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index b5946b44e05ef6316ab5881d7250f1e923548b61..c88aa462a9548536861d29c761af4070780e8fdf 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -686,9 +686,25 @@ pub fn cargo(&self, // // 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()) @@ -703,8 +719,9 @@ pub fn cargo(&self, } 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); } diff --git a/src/ci/run.sh b/src/ci/run.sh index 02480c6937de16f419a8d2c764ef35c4681cc91d..3be1c255c164a61e54c1abdfbfd550523fc03c17 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -67,6 +67,12 @@ else fi fi +# We've had problems in the past of shell scripts leaking fds into the sccache +# server (#48192) which causes Cargo to erroneously think that a build script +# hasn't finished yet. Try to solve that problem by starting a very long-lived +# sccache server at the start of the build, but no need to worry if this fails. +SCCACHE_IDLE_TIMEOUT=10800 sccache --start-server || true + travis_fold start configure travis_time_start $SRC/configure $RUST_CONFIGURE_ARGS