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

RUSTC, RUSTC_WRAPPER are not respected for doctests #12532

Open
RalfJung opened this issue Aug 20, 2023 · 8 comments
Open

RUSTC, RUSTC_WRAPPER are not respected for doctests #12532

RalfJung opened this issue Aug 20, 2023 · 8 comments
Labels
A-doctests Area: rustdoc --test C-bug Category: bug S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Comments

@RalfJung
Copy link
Member

RalfJung commented Aug 20, 2023

When setting RUSTC or RUSTC_WRAPPER, ideally that would affect all rustc invocations that happen during a build. However, right now, rustdoc running doctests will still directly call rustc and bypass those environment variables. IMO this is a bug, cargo should instruct rustdoc to invoke the right rustc. The same goes for the target.runner.

Due to this issue, cargo-miri currently has to do some abhorrent hacks where it intercepts cargo invoking rustdoc, and adjusts the --runtool and --test-builder flags so that they match RUSTC and target.runner. But ideally cargo would just do that by itself.

For RUSTC_WRAPPER, rustdoc needs to gain a new flag with "wrapper" semantics; that is being worked in in rust-lang/rust#114651.

@RalfJung RalfJung added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 20, 2023
@ehuss ehuss added A-doctests Area: rustdoc --test S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix and removed S-triage Status: This issue is waiting on initial triage. labels Sep 25, 2023
@Nemo157
Copy link
Member

Nemo157 commented Dec 21, 2023

target.runner is handled when using -Zdoctest-xcompile, even when not cross-compiling (#7040)

@ehuss
Copy link
Contributor

ehuss commented Dec 21, 2023

I believe that is the intended behavior. That is how the runner field works for cargo run, cargo test, and cargo bench. You don't have to pass --target to have it take effect.

@RalfJung
Copy link
Member Author

@ehuss what exactly is the intended behavior? That I set runner and then only some of the things that are being run use the runner and the rest does something different? What is the motivation for such a surprising and problematic inconsistency?

@Nemo157
Copy link
Member

Nemo157 commented Dec 21, 2023

I think once that flag's behavior is stabilized as the default behavior it will be consistent: target.runner will work for cargo test --doc always. The reason I mentioned that it applies even when not cross-compiling is that it appears to be somewhat of an incidental bugfix bundled into that flag; applying target.runner is commonly necessary for cross-compilation, but makes sense even without it.

@RalfJung
Copy link
Member Author

target.runner will work for cargo test --doc always

Is that the current behavior? At the time I wrote this bug report I think that was not the case.

@Nemo157
Copy link
Member

Nemo157 commented Dec 21, 2023

It's the behavior that -Zdoctest-xcompile enables.

@RalfJung
Copy link
Member Author

Oh I see, now I understand.

Does that also properly apply RUSTC/RUSTC_WRAPPER for doc test builds?

@Nemo157
Copy link
Member

Nemo157 commented Dec 21, 2023

No, those still need implementing separately, and RUSTC_WRAPPER still needs the linked PR or something like it to be able to support on the rustdoc side (I'm gonna bring that up to be merged at the next meeting, so that a feature for it on the cargo side could be added).

@ehuss ehuss changed the title RUSTC, RUSTC_WRAPPER, and target.runner are not respected for doctests RUSTC, RUSTC_WRAPPER, and target.runner and target.linker are not respected for doctests Jul 4, 2024
@ehuss ehuss changed the title RUSTC, RUSTC_WRAPPER, and target.runner and target.linker are not respected for doctests RUSTC, RUSTC_WRAPPER are not respected for doctests Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: rustdoc --test C-bug Category: bug S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Projects
Status: No status
Development

No branches or pull requests

3 participants