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

Cache is completely invalidated when RUSTFLAGS is passed on the clippy command line instead #9280

Closed
jbaublitz opened this issue Mar 17, 2021 · 2 comments
Labels
C-bug Category: bug

Comments

@jbaublitz
Copy link

Problem

Here is the full Makefile:

https://github.com/stratis-storage/stratisd/blob/develop-2.3.0/Makefile

This diff is the two different invocations in question:

stratis-storage/stratisd@b014c72

I expected the build in the minus part of the diff to not invalidate the cache. However, unless our ${DENY} Rust flags are passed in via the RUSTFLAGS environment variable as they are in make build as opposed to on the clippy command line, the cache is completely invalidated and cargo rebuilds all of the dependencies every time make build is run after make clippy and vice versa.

Steps

  1. Run RUSTFLAGS="-D warning" cargo build
  2. Run cargo clippy -- -D warning
  3. This should completely invalidate the cache and cause a full rebuild of all dependencies

Possible Solution(s)
Is there a way to detect something like -D warning whether it's passed into the clippy command line or through RUSTFLAGS?

Output of cargo version:
cargo 1.50.0

This is happening on Fedora 32 with the packaged Rust version.

@jbaublitz jbaublitz added the C-bug Category: bug label Mar 17, 2021
@ehuss
Copy link
Contributor

ehuss commented Mar 17, 2021

Unfortunately this is somewhat expected behavior. Artifacts are not segregated by different RUSTFLAGS (see #8716). In this case, build scripts are shared between build and check/clippy, and are being rebuilt since they are using different flags.

There are a few different options:

  • Use the same RUSTFLAGS for both commands. I'm not sure if there is a reason to pass clippy -- -D warnings instead of using RUSTFLAGS. That is, RUSTFLAGS="-D warnings" cargo clippy should work.
  • Use different target directories for different commands.
  • Use the --target flag. This will prevent build scripts from using RUSTFLAGS.

@jbaublitz
Copy link
Author

Okay, the solution we came up with was option number 1, so if that's the expected behavior, I'll close this out. It works for us!

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

No branches or pull requests

2 participants