Skip to content

Document how to use sccache with Cargo #4307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matklad opened this issue Jul 20, 2017 · 7 comments · Fixed by #4464
Closed

Document how to use sccache with Cargo #4307

matklad opened this issue Jul 20, 2017 · 7 comments · Fixed by #4464
Assignees
Labels
A-documenting-cargo-itself Area: Cargo's documentation

Comments

@matklad
Copy link
Member

matklad commented Jul 20, 2017

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 (#4301 and #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/?

@matklad matklad self-assigned this Jul 20, 2017
@luser
Copy link
Contributor

luser commented Jul 20, 2017

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

@alexcrichton alexcrichton added the A-documenting-cargo-itself Area: Cargo's documentation label Jul 20, 2017
@alexcrichton
Copy link
Member

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.

@matklad
Copy link
Member Author

matklad commented Jul 20, 2017

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

@alexcrichton
Copy link
Member

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

@mqudsi
Copy link

mqudsi commented Aug 17, 2017

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.

@luser
Copy link
Contributor

luser commented Aug 17, 2017

@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.

@mqudsi
Copy link

mqudsi commented Sep 7, 2017

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants