-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Per-configuration caching #10186
Comments
|
Sorry, I was (partially) wrong - I tested more carefully and it does seem that They all play badly with Also, if one specifies RUSTFLAGS to only one of the commands (e.g., only for So my point still stands, even if it less painful than I originally made it out to be; different tools (e.g. coverage) do compile with different options and Using the Another benefit of direct |
Ah, yea, changing RUSTFLAGS will cause everything to be recompiled. There are more details in #8716 as to why that happens. |
I guess this is a duplicate of #8716 then... |
Problem
cargo
needlessly rebuilds all dependencies whenever some tool uses a different build configuration. For example, if one doescargo check ; cargo test ; cargo clippy ; cargo doc
then all the dependencies (and the crate itself) would be rebuilt 4 times, while rebuilding them twice (once for check and clippy, and once for test and doc) would have sufficed.Proposed Solution
Ideally,
cargo
would use a global cache outside the package for the results of compiling each dependency with each specific configuration. This would also makesccache
mostly redundant. Since this would be so massively useful and still hasn't been done I can only assume there's a really good reason against it, so leave this one aside.More simply,
cargo
would cache the results of compiling the current crate's dependencies (and for that matter, the crate itself) in a separatetarget
sub-directory for each configuration (e.g., use a hash of all the configuration parameters, same one that is used today to decide whether the current target is a match for what is requested by each tool).Notes
As a workaround, I invoke all my
cargo
commands through aMakefile
, and prefix each one with./with_configuration.sh NAME cargo ...
whereNAME
identifies the configuration needed for that specific cargo command.The
with_configuration.sh
file is a blunt instrument - one has to be careful to wrap all the relevant commands with it (though the script offers some protection against this), and specify the correct configuration name for each one (which the script does not enforce).It is possible to make this script smarter (have it automatically pick the correct configuration name based on the name of the
cargo
command) but that would still be fragile (e.g., there are many tools, this will not consider the value of environment variables, etc.).In general the right thing would be for
cargo
itself to directly allow for caching multiple versions of the built products according to their specific configuration.The text was updated successfully, but these errors were encountered: