Skip to content
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

Detect and use sccache by introspecting RUSTC_WRAPPER #475

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

mqudsi
Copy link
Contributor

@mqudsi mqudsi commented Jan 31, 2020

If no other C/C++ caching tool is found by inspecting CC and CXX,
RUSTC_WRAPPER is tested to see if an output-caching wrapper for
rustc is in use. If that is the case and it is a wrapper known to also
support C/C++ caching, use it.

If no other C/C++ caching tool is found by inspecting `CC` and `CXX`,
`RUSTC_WRAPPER` is tested to see if an output-caching wrapper for
`rustc` is in use. If that is the case and it is a wrapper known to also
support C/C++ caching, use it.

(Also correct/clarify a misnamed variable that caused me some confusion
looking over the code.)
When checking for possible `RUSTC_WRAPPER`s that we can use to cache
C/C++ output, allow for filename extensions (e.g. `sccache.exe`) and
absolute paths (e.g. `/usr/local/bin/sccache`).

Closes rust-lang#473
@mqudsi mqudsi force-pushed the sccache_detection branch from 13ce46d to 8e53398 Compare January 31, 2020 03:11
@alexcrichton alexcrichton merged commit 4b72474 into rust-lang:master Feb 4, 2020
@alexcrichton
Copy link
Member

Thanks!

@kyren
Copy link

kyren commented Apr 23, 2020

Just an FYI in case anybody else comes across this bug, this PR can actually break your build if you're already setting RUSTC_WRAPPER and also happen to also have sccache -> gcc symlinks in your PATH with an error similar to the following:

running: "sccache" "gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/nix/store/kpc7x7mvb38di1711n6n2s1pgp9zwl7k-openssl-1.1.1d-dev/include" "-Wall" "-Wextra" "-E" "build/expando.c"
cargo:warning=error: failed to execute compile
cargo:warning=caused by: Compiler not supported: ""
exit code: 2

--- stderr
thread 'main' panicked at '
Header expansion error:
Error { kind: ToolExecError, message: "Command \"sccache\" \"gcc\" \"-O3\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-g\" \"-fno-omit-frame-pointer\" \"-m64\" \"-I\" \"/nix/store/kpc7x7mvb38di1711n6n2s1pgp9zwl7k-openssl-1.1.1d-dev/include\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"gcc\" did not execute successfully (status code exit code: 2)." }

Since pretty much everything in rust land that builds C code uses the cc crate, simply not having those symlinks in the PATH when invoking builds via cargo seems like a reasonable fix (since it'll be now be added by the cc crate automatically).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants