Skip to content

fix(compiler): forward verbose flag to rustc for local crates#17006

Merged
epage merged 2 commits into
rust-lang:masterfrom
raushan728:FIX-16531
May 26, 2026
Merged

fix(compiler): forward verbose flag to rustc for local crates#17006
epage merged 2 commits into
rust-lang:masterfrom
raushan728:FIX-16531

Conversation

@raushan728

@raushan728 raushan728 commented May 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #16531

This PR forwards the --verbose flag to rustc when compiling local packages. This ensures users can see full, untruncated diagnostics (such as detailed linker errors) when running cargo build --verbose.

Note on caching: We intentionally do not track this verbosity state in the fingerprint/cache. Since compiler/linker errors are not cached by Cargo anyway, simply forwarding the flag is sufficient to reveal the full error output without unnecessarily thrashing the cache for successful builds.

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting Command-report labels May 17, 2026
@rustbot

rustbot commented May 17, 2026

Copy link
Copy Markdown
Collaborator

r? @weihanglo

rustbot has assigned @weihanglo.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 17, 2026
@raushan728

raushan728 commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

CI is failing on ~50 tests because the snapshots need to be updated with the new [DIRTY] state and --verbose flag.

Since SNAPSHOTS=overwrite removes the [..] wildcards and hardcodes local hashes, I held off on pushing the test updates. Let me know if this looks good, and should I manually fix the wildcards in the failing tests?

@epage

epage commented May 18, 2026

Copy link
Copy Markdown
Contributor

tracks this verbosity state in the unit Fingerprint hash

From #16531 (comment)

So to summarize, the proposal is:

...

  • When forwarded, include cargo's verbosity mode in either the Unit Hash (new cache entry) or the Fingerprint (overwrite existing cache entry)

There was a choice here and you went one route. Please when doing these types of things document your reasoning.

Note that the statement wasn't a commitment to do this but a re-iteration of the request to confirm understanding which brings us to #16531 (comment)

One of the concerns was around the output caching behavior. For some use cases, like the linker error described above, it should be fine since errors aren't cached. But for other cases, it can cause confusing behavior (like #8830 and #9003). My understanding is that rustc rarely emits verbose output, so in most cases it shouldn't be a problem. It's a small risk, and maybe it can be mitigated with documentation?

I think this is saying that we decided to punt on tracking this is in the hash or fingerprint. Looking at the notes doesn't provide any more insight.

@ehuss do you remember which way we landed on this?

@raushan728

Copy link
Copy Markdown
Contributor Author

I went with fingerprint instead of unit hash because running with --verbose is usually a temporary one-off check. Using unit hash would duplicate artifacts and unnecessarily bloat the target/ directory. Fingerprint just forces a rebuild to show the full error without wasting space.

Regarding tracking it at all: if we don't dirty the cache, Cargo just replays the previously cached truncated message. So just forwarding the flag wouldn't actually show the full output.

To drop the fingerprint tracking entirely if @ehuss confirms we should punt on it.

@ehuss

ehuss commented May 18, 2026

Copy link
Copy Markdown
Contributor

I don't recall if we landed one way or the other on caching.

Right now I don't have a good answer to that myself. The downsides seem clear to me:

  • Not tracked: You won't get the verbose output (enabling -v when already cached), or the verbose output will be stuck "on" (removing -v after building). You have to know to run cargo clean if you really want to see the difference.
  • Fingerprint-tracked: Just changing the -v flag will thrash your cache (and the majority of the time, the output will be identical).
  • Unit-tracked: Switching -v can explode the build cache (and the majority of the time, the output will be identical).

These differences are not applicable to the linker error mentioned in the issue, since that wouldn't be cached. If we truly only care about that one message (or any messages with errors), then I would go with not-tracked (since an error isn't cached). That would be the least disruptive, and address the concern in the issue (not seeing the full linker output). The downside is that it wouldn't help with any rustc messages in the future that are not errors but change based on --verbose.

We could always change this in the future, too.

@raushan728

Copy link
Copy Markdown
Contributor Author

Since errors (like the linker error) aren't cached anyway, going with the "Not tracked" solves the primary issue without thrashing the cache for successful builds.

I'll drop the fingerprint tracking, keep just the --verbose forwarding in prepare_rustc . I'll push the update shortly.

@raushan728 raushan728 force-pushed the FIX-16531 branch 5 times, most recently from be4fe3f to af8858c Compare May 22, 2026 15:58
@rustbot

This comment has been minimized.

Forwards the verbose flag to rustc when compiling local packages.
Ensures users can see full untruncated diagnostics when running cargo build with the verbose flag.

Fixes rust-lang#16531
@rustbot

rustbot commented May 24, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@epage epage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

There was a question on whether the local check was right but that is most likely where people will see linker warnings, reduces the impact of the caching issue, and we can always change this later

View changes since this review

@epage epage added this pull request to the merge queue May 26, 2026
Merged via the queue into rust-lang:master with commit fbb61be May 26, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2026
@rustbot rustbot mentioned this pull request May 26, 2026
3 tasks
@raushan728 raushan728 deleted the FIX-16531 branch May 27, 2026 04:38
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request May 27, 2026
Update cargo submodule

13 commits in 4d1f984518c77fad6eeef4f40153b002a659e662..fbb61be30e5f9ac3a6ad58e56a5c0f5db2d2b3ef
2026-05-15 17:12:01 +0000 to 2026-05-26 15:08:03 +0000
- fix(compiler): forward verbose flag to rustc for local crates (rust-lang/cargo#17006)
- Fix CVE-2026-5222 and CVE-2026-5223 (rust-lang/cargo#17031)
- Don't use the network for a publish dry-run test  (rust-lang/cargo#17027)
- feat: Break out `RegistryConfig` and `crate_url` for interpreting `RegistryConfig::dl` (rust-lang/cargo#17011)
- refactor(diag): Sort the PARSE_PASS_RULES (rust-lang/cargo#17019)
- fix(artifact)!: Remove compat mode from artifacts (rust-lang/cargo#17016)
- refactor(diag): Simplify adding of new diagnostics (rust-lang/cargo#17015)
- test(package): Mark a network test that timed out on me (rust-lang/cargo#17017)
- refactor(diag): Pull in the parse pass (rust-lang/cargo#17008)
- test(lints): Avoid compiling where possible (rust-lang/cargo#17007)
- fix(diag): Report deferred diagnostics like other diagnostics (rust-lang/cargo#16994)
- refactor: drop `-Zunstable-options` for `rustdoc --emit` (rust-lang/cargo#17002)
- chore(deps): update msrv (1 version) to v1.95 (rust-lang/cargo#17001)
@rustbot rustbot added this to the 1.98.0 milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting Command-report

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo build --verbose should imply rustc --verbose

5 participants