Skip to content

Conversation

@weihanglo
Copy link
Member

@weihanglo weihanglo commented Nov 4, 2025

What does this PR try to resolve?

This implements a basic emission for rebuild reasons.

It reuses the DirtyReason enum in the log messages.
Hence the serialization change.

Part of #15844

How to test and review this PR?

The schema is not final, subject to change,
but at least this PR unblocks us the exploration of cargo report commands.

See tests in dirty_reason.rs for the shape of the JSON message.

Schema decisions

We may need to review this before stabilization:

  • FileTime: serialize as f64 milliseconds
    Millisecond precision should be sufficient for mtime comparison,
    if not we can change to nanosecond
  • Checksum: serializing to Display format
    (e.g., "sha256=abc123...")
  • StaleItem: with internally tagged format, for example
    {"stale-item":"missing-file","path":"src/lib.rs"}
    {"stale-item":"changed-file","reference_mtime":"...", ...}
    
  • FsStatus: with internally tagged format, for example
    {"fs-status":"stale-item","type":"missing-file","path":"..."}
    
    The UpToDate variant is skipped
    since it's not relevant for rebuild reason logging.

Converts tuple variants to struct variants with named 'path' field.

This prepares for cleaner JSON serialization
where we can have `{"type":"missing-file","path":"..."}`
instead of needing a generic "data" wrapper.
@rustbot rustbot added A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 4, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@epage
Copy link
Contributor

epage commented Nov 4, 2025

Can you note interesting schema decisions (like milliseconds) in the PR with the intent to move it to the tracking issue on merge? Would like to make sure we don't overlook these when discussing stabilization.

To implement Serialize for DirtyReason,
we need to also impl Serialize for underly types as well:

* `FileTime`: serialize as f64 milliseconds
  Millisecond precision should be sufficient for mtime comparison,
  if not we can change to nanosecond
* `Checksum`: serializing to Display format
  (e.g., "sha256=abc123...")
* `StaleItem`: with internally tagged format, for example
  ```
  {"stale-item":"missing-file","path":"src/lib.rs"}
  {"stale-item":"changed-file","reference_mtimer":"...", ...}
  ```
* `FsStatus`: with internally tagged format, for example
  ```
  {"fs-status":"stale-item","type":"missing-file","path":"..."}
  ```
  The `UpToDate` variant is skipped
  since it's not relevant for rebuild reason logging.

_Part of `-Zbuild-analysis` rebuild reason logging feature_
_Part of `-Zbuild-analysis` rebuild reason logging_
@epage epage added this pull request to the merge queue Nov 4, 2025
Merged via the queue into rust-lang:master with commit 8d3e73f Nov 4, 2025
25 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 4, 2025
@weihanglo weihanglo deleted the logging branch November 4, 2025 17:13
bors added a commit to rust-lang/rust that referenced this pull request Nov 8, 2025
Update cargo submodule

22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f
2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000
- fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223)
- refactor: Remove lazycell (rust-lang/cargo#16224)
- refactor: extract ConfigValue to its own module (rust-lang/cargo#16222)
- fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220)
- fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213)
- fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125)
- fix: non-mergeable list from config cli merge the same way  (rust-lang/cargo#16219)
- docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216)
- fix: Remove build-plan (rust-lang/cargo#16212)
- Add native completions for `--package` on various commands (rust-lang/cargo#16210)
- fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215)
- refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177)
- docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211)
- docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205)
- feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203)
- chore: Update dependencies (rust-lang/cargo#16200)
- chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190)
- chore(deps): update msrv (rust-lang/cargo#16178)
- refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194)
- refactor(gctx): extract config schema to a module (rust-lang/cargo#16195)
- chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191)
- chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186)

r? ghost
@rustbot rustbot added this to the 1.93.0 milestone Nov 8, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 10, 2025
Update cargo submodule

22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f
2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000
- fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223)
- refactor: Remove lazycell (rust-lang/cargo#16224)
- refactor: extract ConfigValue to its own module (rust-lang/cargo#16222)
- fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220)
- fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213)
- fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125)
- fix: non-mergeable list from config cli merge the same way  (rust-lang/cargo#16219)
- docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216)
- fix: Remove build-plan (rust-lang/cargo#16212)
- Add native completions for `--package` on various commands (rust-lang/cargo#16210)
- fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215)
- refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177)
- docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211)
- docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205)
- feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203)
- chore: Update dependencies (rust-lang/cargo#16200)
- chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190)
- chore(deps): update msrv (rust-lang/cargo#16178)
- refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194)
- refactor(gctx): extract config schema to a module (rust-lang/cargo#16195)
- chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191)
- chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rebuild-detection Area: rebuild detection and fingerprinting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants