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

RUSTDOC_LOG does not invalidate output cache #8374

Open
jyn514 opened this issue Jun 17, 2020 · 8 comments
Open

RUSTDOC_LOG does not invalidate output cache #8374

jyn514 opened this issue Jun 17, 2020 · 8 comments
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting C-bug Category: bug

Comments

@jyn514
Copy link
Member

jyn514 commented Jun 17, 2020

Problem
When I set RUSTDOC_LOG=info after previously running cargo doc, any time I run cargo doc in the future will not have any output from rustdoc. The same problem is also present for RUSTC_LOG.

Steps

  1. cargo doc on any cargo project
  2. RUSTDOC_LOG=info cargo doc

The second run will have the same output as the first. For comparison, the expected output is something like this:

RUSTDOC_LOG example
$ RUSTDOC_LOG=rustdoc cargo doc 
 Documenting hexponent v0.3.0 (/home/joshua/src/rust/hexponent)
[INFO  rustdoc] starting to run rustc
[INFO  rustdoc::core] Executing passes
[INFO  rustdoc] finished with rustc
[INFO  rustdoc] going to format
[INFO  rustdoc::html::sources] emitting source files
[INFO  rustdoc::html::render] Recursing into /home/joshua/.local/lib/cargo/target/doc/hexponent
[INFO  rustdoc::html::render] Documenting hexponent
[INFO  rustdoc::html::render] Recursed; leaving /home/joshua/.local/lib/cargo/target/doc/hexponent
[INFO  rustdoc::html::render] Documenting FPFormat
[INFO  rustdoc::html::render] Documenting from_literal
[INFO  rustdoc::html::render] Recursing into /home/joshua/.local/lib/cargo/target/doc/hexponent/fpformat
[INFO  rustdoc::html::render] Recursed; leaving /home/joshua/.local/lib/cargo/target/doc/hexponent/fpformat
[INFO  rustdoc::html::render] Recursing into /home/joshua/.local/lib/cargo/target/doc/hexponent/parse_utils
[INFO  rustdoc::html::render] Recursed; leaving /home/joshua/.local/lib/cargo/target/doc/hexponent/parse_utils
[INFO  rustdoc::html::render] Documenting ParseErrorKind
[INFO  rustdoc::html::render] Documenting MissingPrefix
[INFO  rustdoc::html::render] Documenting MissingDigits
[INFO  rustdoc::html::render] Documenting MissingExponent
[INFO  rustdoc::html::render] Documenting ExponentOverflow
[INFO  rustdoc::html::render] Documenting MissingEnd
[INFO  rustdoc::html::render] Documenting ConversionResult
[INFO  rustdoc::html::render] Documenting Precise
[INFO  rustdoc::html::render] Documenting Imprecise
[INFO  rustdoc::html::render] Documenting FloatLiteral
[INFO  rustdoc::html::render] Documenting ParseError
[INFO  rustdoc::html::render] Documenting kind
[INFO  rustdoc::html::render] Documenting index
    Finished dev [unoptimized + debuginfo] target(s) in 0.63s

Possible Solution(s)

Invalidate cargo's output cache whenever RUSTDOC_LOG is changed.

Notes

Output of cargo version:

cargo 1.44.0 (05d080faa 2020-05-06) (but the problem was present on nightly last I checked a few days ago).

@jyn514
Copy link
Member Author

jyn514 commented Mar 3, 2021

@jyn514
Copy link
Member Author

jyn514 commented Mar 3, 2021

It turns out rustdoc can fix this on its end using env_depinfo: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/CLIPPY_ARGS.20is.20not.20tracked.20by.20Cargo

This still doesn't help because Cargo doesn't track dep-info from rustdoc - and in fact, it can't:

$ cargo +rustc2 rustdoc -q -- --emit=dep-info
error: Unrecognized option: 'emit'

Is it intentional that cargo doesn't do this? If I added support for --emit to rustdoc, would cargo use it?

@jyn514
Copy link
Member Author

jyn514 commented Mar 3, 2021

I guess another alternative is to change rustdoc to use RUSTC_LOG instead, which should inherit the depinfo from when rustc is run. But that seems not ideal.

@jyn514
Copy link
Member Author

jyn514 commented Mar 4, 2021

This still doesn't help because Cargo doesn't track dep-info from rustdoc - and in fact, it can't:

Actually it's even more than that - cargo only uses the dep-info from rustc for rustc itself, not for rustdoc 😕

$ cat span.d 
span.d: src/lib.rs src/span.rs

src/lib.rs:
src/span.rs:

# env-dep:RUSTC_LOG
# env-dep:RUSTC_LOG_COLOR
# env-dep:RUSTDOC_LOG
# env-dep:RUSTDOC_LOG_COLOR

$ cargo +rustc2 rustdoc
 Documenting span v0.1.0 (/home/joshua/test-rustdoc/span)
    Finished dev [unoptimized + debuginfo] target(s) in 0.58s
$ RUSTDOC_LOG=info cargo +rustc2 rustdoc
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s

jyn514 added a commit to jyn514/rust that referenced this issue Mar 4, 2021
Previously, changing the value of `RUSTC_LOG` would not rebuild, and,
because cargo caches output, show exactly the same logging as before.
This was confusing. Emit `RUSTC_LOG` with other `depinfo` dependencies
so cargo knows to rebuild when it's changed.

Note that this only adds RUSTC_LOG to depinfo.  Unfortunately, adding
RUSTDOC_LOG only when running as rustdoc doesn't help because rustdoc
doesn't emit depinfo at all. Unconditionally emitting RUSTDOC_LOG in the
depinfo doesn't help because cargo ignores it for everything except
rustc itself. I am not yet sure how to fix this; see
rust-lang/cargo#8374 for more info.
@jyn514
Copy link
Member Author

jyn514 commented Jun 8, 2021

@ehuss why did you assign me?

@ehuss ehuss unassigned jyn514 Jun 8, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 8, 2021

Oh, sorry. I was debugging why the rustbot claim above #8374 (comment) didn't work.

@jyn514
Copy link
Member Author

jyn514 commented Jun 9, 2021

Ah ok - I no longer want to tackle this, the pr fixing it was closed: rust-lang/rust#82763.

@jyn514 jyn514 closed this as completed Jun 9, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jun 7, 2023

hmm, I just had another idea for how to fix this: right now it looks like cargo unconditionally caches all rustc output — could we change it to only cache lints instead? I think lints were the original motivation for adding caching.

to avoid confusion we could say something like "note: 50 lines of non-lint output were not cached"?

@jyn514 jyn514 reopened this Jun 7, 2023
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 C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants