Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#3887 - luser:rustc-wrapper, r=alexcrichton
Add support for wrapping cargo's rustc invocations by setting RUSTC_WRAPPER To use sccache for cargo builds we need a simple way to get sccache into the rustc commandline when cargo invokes rustc. Currently this is only possible by hard-linking or copying the `sccache` binary to be named `rustc` and then either setting `RUSTC` to its path or putting it first in `$PATH`, both of which are sort of clunky and require manual steps even if installing sccache via `cargo install`. This patch adds support for a `RUSTC_WRAPPER` environment variable which, if set, will simply be inserted as the actual binary for all rustc process execution, with rustc and all other rustc arguments following. I didn't add any tests for this, I couldn't figure out the right place to put them, and presumably we'd need to build a helper binary of some sort to use as the wrapper. If you've got suggestions for how to do that properly I'd be happy to write tests. This works well in my local testing: ``` luser@eye7:/build/read-process-memory$ /build/cargo/target/release/cargo clean; time RUSTC_WRAPPER=/build/sccache2/target/release/sccache RUSTC=/home/luser/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/rustc /build/cargo/target/release/cargo build Compiling getopts v0.2.14 Compiling log v0.3.6 Compiling libc v0.2.16 Compiling rand v0.3.14 Compiling pulldown-cmark v0.0.3 Compiling tempdir v0.3.5 Compiling skeptic v0.5.0 Compiling read-process-memory v0.1.2-pre (file:///build/read-process-memory) Finished dev [unoptimized + debuginfo] target(s) in 7.31 secs real 0m7.733s user 0m0.060s sys 0m0.036s luser@eye7:/build/read-process-memory$ /build/cargo/target/release/cargo clean; time RUSTC_WRAPPER=/build/sccache2/target/release/sccache RUSTC=/home/luser/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/rustc /build/cargo/target/release/cargo build Compiling getopts v0.2.14 Compiling libc v0.2.16 Compiling log v0.3.6 Compiling pulldown-cmark v0.0.3 Compiling rand v0.3.14 Compiling tempdir v0.3.5 Compiling skeptic v0.5.0 Compiling read-process-memory v0.1.2-pre (file:///build/read-process-memory) Finished dev [unoptimized + debuginfo] target(s) in 0.97 secs real 0m1.049s user 0m0.060s sys 0m0.036s ``` The use of beta rustc is just to pick up the fix for making `--emit=dep-info` faster (which should ship in 1.17). If this patch ships in cargo then in the future developers should simply be able to `cargo install sccache; export RUSTC_WRAPPER=sccache` and `cargo build` as normal, but benefit from local sccache caching.
- Loading branch information