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

Cargo always builds cargo check #5236

Closed
Mark-Simulacrum opened this issue Mar 23, 2018 · 4 comments
Closed

Cargo always builds cargo check #5236

Mark-Simulacrum opened this issue Mar 23, 2018 · 4 comments

Comments

@Mark-Simulacrum
Copy link
Member

I'm seeing the following locally in a new project (created via cargo new):

$ RUST_LOG=cargo::ops::cargo_rustc::fingerprint=debug cargo check
DEBUG 2018-03-23T23:02:00Z: cargo::ops::cargo_rustc::fingerprint: fingerprint at: /home/mark/Build/testing/fffff/target/debug/.fingerprint/fffff-d3ba5f321a9eb8a2/bin-fffff-d3ba5f321a9eb8a2
   Compiling fffff v0.1.0 (file:///home/mark/Build/testing/fffff)
DEBUG 2018-03-23T23:02:00Z: cargo::ops::cargo_rustc::fingerprint: write fingerprint: /home/mark/Build/testing/fffff/target/debug/.fingerprint/fffff-d3ba5f321a9eb8a2/bin-fffff-d3ba5f321a9eb8a2
    Finished dev [unoptimized + debuginfo] target(s) in 0.10 secs
$ RUST_LOG=cargo::ops::cargo_rustc::fingerprint=trace cargo check
DEBUG 2018-03-23T23:02:16Z: cargo::ops::cargo_rustc::fingerprint: fingerprint at: /home/mark/Build/testing/fffff/target/debug/.fingerprint/fffff-d3ba5f321a9eb8a2/bin-fffff-d3ba5f321a9eb8a2
   Compiling fffff v0.1.0 (file:///home/mark/Build/testing/fffff)
DEBUG 2018-03-23T23:02:16Z: cargo::ops::cargo_rustc::fingerprint: write fingerprint: /home/mark/Build/testing/fffff/target/debug/.fingerprint/fffff-d3ba5f321a9eb8a2/bin-fffff-d3ba5f321a9eb8a2
    Finished dev [unoptimized + debuginfo] target(s) in 0.11 secs

This isn't really too big of an issue, but it feels wrong that Cargo does work (and spawns rustc) despite nothing changing in the project to my knowledge. It's also somewhat concerning that I don't see anything with =info on the RUST_LOG which leads me to believe that this is perhaps unintentional?

@alexcrichton
Copy link
Member

Hm this doesn't reproduce with a "hello world" instance, do you have a way to reproduce this locally though?

@Mark-Simulacrum
Copy link
Member Author

Yeah, I see the following. I'm not sure what else I could provide; seems odd that you can't reproduce, and yet I've reproduce on two different machines now...

macbook: ~
$ cargo new always-build
     Created binary (application) `always-build` project

mark: ~
$ cd always-build/

mark: ~/always-build
$ cargo check
   Compiling always-build v0.1.0 (file:///Users/mark/always-build)
    Finished dev [unoptimized + debuginfo] target(s) in 0.15 secs

mark: ~/always-build
$ cargo check
   Compiling always-build v0.1.0 (file:///Users/mark/always-build)
    Finished dev [unoptimized + debuginfo] target(s) in 0.12 secs

$ cargo -vV
cargo 1.26.0-nightly (d10ec661b 2018-03-20)
release: 1.26.0
commit-hash: d10ec661b06420654bbc4ed0ccd32295698aa1dc
commit-date: 2018-03-20

@ehuss
Copy link
Contributor

ehuss commented Mar 30, 2018

This was discussed a bit in #3624 and #4318. bin targets will always be re-checked because they do not generate .rmeta files, and this code always assumes it is checking a library:

if unit.profile.check {
let filename = out_dir.join(format!("lib{}.rmeta", stem));
let link_dst = link_stem
.clone()
.map(|(ld, ls)| ld.join(format!("lib{}.rmeta", ls)));
ret.push((filename, link_dst, TargetFileType::Linkable));
} else {

The bigger question is should check be re-run each time, even if there are no changes. matklad indicated that cargo should instead cache the output from the compiler so that warnings can be redisplayed when the cache is fresh (for build or check). I feel like that would be somewhat tricky. It may need to somehow extend the fingerprint to include things like --message-format, --color, terminal settings (for "auto" color), etc.

@Mark-Simulacrum
Copy link
Member Author

I'm personally okay with that; if we can't check bin targets then that's fine, though that's somewhat surprising -- I'd expect us to be able to produce metadata anyway. But that's largely unimportant; I'm going to close this as not a bug.

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

No branches or pull requests

3 participants