Bug 1576030 - Disable cargo incremental when using sccache. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 23 Aug 2019 04:50:55 +0000
changeset 553291 e21bc14e05be8c5f0ae2674fe50526bfbd4bae15
parent 553290 5df00af5913e90ba7c60411e1e6cb78c2f7c46e0
child 553292 cace4ffbecb254953949c51008d4ac1b9c5cab7d
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1576030
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1576030 - Disable cargo incremental when using sccache. r=nalexander For some reason, cargo incremental doesn't work as well as it should, and doesn't perform as well as sccache does. So when building with sccache, disable cargo incremental. This brought a no-change clobber build with 100% cache from 3:50 to 2:05 on a beefy AWS instance I was testing this with. Differential Revision: https://phabricator.services.mozilla.com/D43188
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1881,39 +1881,52 @@ def rust_compile_flags(opt_level, debug_
         flags.extend(['-C', opt])
 
     return flags
 
 
 # Rust incremental compilation
 # ==============================================================
 
+js_option(env='RUSTC_WRAPPER', nargs=1,
+          help='Wrap rust compilation with given tool')
+
 js_option('--disable-cargo-incremental',
           help='Disable incremental rust compilation.')
 
 @depends(rustc_opt_level, debug_rust, 'MOZ_AUTOMATION', code_coverage,
-         '--disable-cargo-incremental')
+         '--disable-cargo-incremental', using_sccache, 'RUSTC_WRAPPER')
+@imports('os')
 def cargo_incremental(opt_level, debug_rust, automation, code_coverage,
-                      enabled):
+                      enabled, using_sccache, rustc_wrapper):
     """Return a value for the CARGO_INCREMENTAL environment variable."""
 
     if not enabled:
         return '0'
 
     # We never want to use incremental compilation in automation.  sccache
     # handles our automation use case much better than incremental compilation
     # would.
     if automation:
         return '0'
 
     # Coverage instrumentation doesn't play well with incremental compilation
     # https://github.com/rust-lang/rust/issues/50203.
     if code_coverage:
         return '0'
 
+    # Incremental compilation doesn't work as well as it should, and if we're
+    # using sccache, it's better to use sccache than incremental compilation.
+    if not using_sccache and rustc_wrapper:
+        rustc_wrapper = os.path.basename(rustc_wrapper[0])
+        if os.path.splitext(rustc_wrapper)[0].lower() == 'sccache':
+            using_sccache = True
+    if using_sccache:
+        return '0'
+
     # Incremental compilation is automatically turned on for debug builds, so
     # we don't need to do anything special here.
     if debug_rust:
         return
 
     # --enable-release automatically sets -O2 for Rust code, and people can
     # set RUSTC_OPT_LEVEL to 2 or even 3 if they want to profile Rust code.
     # Let's assume that if Rust code is using -O2 or higher, we shouldn't