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

Log the name of the dependency that changed #13883

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/cargo/core/compiler/fingerprint/dirty_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ pub enum DirtyReason {
new: InternedString,
},
UnitDependencyInfoChanged {
old_name: InternedString,
name: InternedString,
old_fingerprint: u64,

new_name: InternedString,
new_fingerprint: u64,
},
FsStatusOutdated(FsStatus),
Expand Down Expand Up @@ -209,8 +207,8 @@ impl DirtyReason {
unit,
format_args!("name of dependency changed ({old} => {new})"),
),
DirtyReason::UnitDependencyInfoChanged { .. } => {
s.dirty_because(unit, "dependency info changed")
DirtyReason::UnitDependencyInfoChanged { name, .. } => {
s.dirty_because(unit, format_args!("dependency info changed ({name})"))
}
DirtyReason::FsStatusOutdated(status) => match status {
FsStatus::Stale => s.dirty_because(unit, "stale, unknown reason"),
Expand Down
3 changes: 1 addition & 2 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,9 +1046,8 @@ impl Fingerprint {

if a.fingerprint.hash_u64() != b.fingerprint.hash_u64() {
return DirtyReason::UnitDependencyInfoChanged {
new_name: a.name,
name: a.name,
new_fingerprint: a.fingerprint.hash_u64(),
old_name: b.name,
old_fingerprint: b.fingerprint.hash_u64(),
};
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ fn dylib() {
[COMPILING] registry-shared v0.0.1
[FRESH] registry v0.0.1
[RUNNING] `rustc --crate-name registry_shared [..]-C embed-bitcode=no[..]
[DIRTY] bar v0.0.0 ([..]): dependency info changed
[DIRTY] bar v0.0.0 ([..]): dependency info changed (registry_shared)
[COMPILING] bar [..]
[RUNNING] `rustc --crate-name bar [..]--crate-type dylib [..]-C embed-bitcode=no[..]
[FINISHED] [..]
Expand All @@ -622,7 +622,7 @@ fn dylib() {
[FRESH] registry-shared v0.0.1
[COMPILING] registry v0.0.1
[RUNNING] `rustc --crate-name registry [..]
[DIRTY] bar v0.0.0 ([..]): dependency info changed
[DIRTY] bar v0.0.0 ([..]): dependency info changed (registry_shared)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message looks strange to me. Should it not output registry rather than registry_shared here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the problem is we only report the first dependency, rather than all.

I suspect what is happening here is we are reusing registry_shared with a version from a couple builds back. This is a different hash than the immediately prior build, so it requires rebuilding bar but this isn't quite clear without more context.

I wonder if this change will cause more confusion than good and we should defer to #2904 which would add a cargo report subcommand for reporting why the last command rebuilt and we can include a lot more context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #13859 (comment), yet it might need some design discussions before proceed.

[COMPILING] bar [..]
[RUNNING] `rustc --crate-name bar [..]--crate-type dylib [..]-C embed-bitcode=no[..]
[RUNNING] `rustc --crate-name bar [..]-C lto [..]--test[..]
Expand Down