Cargo: Document how to use sccache with Cargo

Created on 20 Jul 2017  路  7Comments  路  Source: rust-lang/cargo

Looks like sccache can help quite a bit even with local development, when you are working on different projects, or when you are switching versions of the compiler (https://github.com/rust-lang/cargo/issues/4301 and https://github.com/rust-lang/cargo/issues/4306).

However, it seems to me that nobody knows how to use sccache with Cargo, and that it even exists. At least, I certainly don't know how to set it up :) I guess I'll try to figure this out and write some docs.

@luser are there any other existing docs besides https://users.rust-lang.org/t/sccache-for-caching-rust-compilation/10960 and readme at https://github.com/mozilla/sccache/?

A-documenting-cargo-itself

Most helpful comment

There's a separate Rust doc linked from the README. It's pretty easy to use, though!

All 7 comments

There's a separate Rust doc linked from the README. It's pretty easy to use, though!

The tl;dr; for Rust is:

$ cargo install sccache
$ export RUSTC_WRAPPER=sccache
# normal cargo commands here...

The cargo install step doesn't quite work yet but I suspect that'll get resolved soon.

So, export RUSTC_WRAPPER=sccache bit should go to bash_rc or the like? Perhaps this should be configurable via ~/.cargo/config?

Makes sense to me to add a configuration option for it!

I disagree about adding a configuration option for it, I think an environment variable is fine. However, when I do specify RUSTC_WRAPPER, cargo's rustc invocations are called via sccache as expected, however none of them result in hits as all the invocations come up as non-cacheable calls. I mean that at no point during a full day of rust development, crate installations, etc. etc. does Cache hits in sccache -s show anything other than zero.

@mqudsi Interesting! If you run with SCCACHE_ERROR_LOG=/tmp/sccache.log RUST_LOG=sccache=trace you can get a lot of information about what sccache is doing. grep'ing the log for CannotCache is generally useful in these situations. If you want to post that here or email me, [email protected] I'd be happy to take a look.

@luser thank you for your offer!

I've attached the sccache trace to this comment. This was from the 4th or 5th subsequent (though ultimately failed) compilation of sccache itself. There are a lot of unhandled compiles, though I don't think there are enough of them to explain why each time I recompile sccache, my hit count only rises by 3.

sccache.txt

Was this page helpful?
0 / 5 - 0 ratings