-
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
Default target conflicts with explicit targets causing full recompile #9239
Comments
Hm, I'm unable to reproduce with the given steps. If you're still able to reproduce, can you run the final command with the
This is normal. Host artifacts (such as build scripts and proc macros) go into
There are some subtle differences if you specify |
So I tested this out on another machine and couldn't replicate it, and after a bit of debugging I think it is occurring because I have the following in my cargo config: [build]
rustflags = ["-C", "link-arg=-fuse-ld=lld"] The extra log output (from one of the runs that requires a rebuild) is here: https://github.com/rust-lang/cargo/files/6093143/check.log |
The output always conatins the line:
If the last command run specified a target then
After that
Another |
Ah, yea, that's somewhat expected for now. Changes in RUSTFLAGS are not segregated in separate files/directories, so changing RUSTFLAGS will trigger a rebuild, and the way RUSTFLAGS interacts with build scripts can be a bit awkward (they are used for build scripts if There are several other issues tracking that behavior (#8716, #6375, #4423, #3739), so closing in favor of one of those. One workaround is to use different target directories, though I realize that is fairly cumbersome. |
For anyone who stumbles across this in the future and this hasn't been solved, I've solved this by adding my default target to the cargo config, e.g. [build]
target = "x86_64-unkown-linux-gnu" At a guess, that's making cargo behave as if it always runs with |
I can confirm that this issue still exists in
It appears cargo things these flags changed, even though they did not:
It only occurs when switching targets. It happens in reverse when specifying the target:
It even happens if both are the same target, but one is using the default and the other is specifying @ehuss Can this issue be re-opened or should I file a new issue? Edit: After further testing, it's directly related to the default target. Switching targets continues to cache correctly as long as |
@kjvalencik Unfortunately for now that is expected behavior. Due to #8716, RUSTFLAGS is not part of the filename hash. Due to #4423 RUSTFLAGS are not used for build scripts when |
Problem
Running
cargo
(incrementally) without an explicit target conflicts with runningcargo
with an explicit target in that it causes all dependencies to be recompiled. Compiling with multiple different explicit targets doesn't conflict however. I'd expect compiling without an explicit target to behave the same as compiling with the default target.One surprising thing that I noticed here is that
cargo check --target x86_64-unknown-linux-musl
creates thetarget/x86_64-unknown-linux-musl/debug
directory and thetarget/debug
directory.Steps
cargo new --bin blah
rand 0.8
)cargo check --target x86_64-unknown-linux-gnu
cargo check --target x86_64-unknown-linux-musl
cargo check --target x86_64-unknown-linux-gnu
(This should reuse cached builds)cargo check --target x86_64-unknown-linux-musl
(This should reuse cached builds)cargo check
(This will rebuild all dependencies)cargo check --target x86_64-unknown-linux-gnu
(This will suddenly rebuild all dependencies)Notes
Output of
cargo version
: cargo 1.50.0 (f04e7fa 2021-02-04)The text was updated successfully, but these errors were encountered: