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

Add RUSTC_STAGE env var to ./x.py clippy invocation #100492

Closed
wants to merge 1 commit into from

Conversation

khyperia
Copy link
Contributor

I have absolutely no idea if ./x.py clippy is supposed to be supported or work these days, but it didn't for me, so I figured I'd fix it.

Important: #97443 by @asquared31415 deletes this bit of code. I'm not sure if that PR is still alive or not, or if this PR should be discarded in favor of that one, idk, I'm just blindly whacking at infra until it seems to work.

Before this change, when I ran ./x.py clippy, it told me to rustup component add clippy. This was entirely unhelpful, as I already had clippy installed! So I expanded the error reporting to report the actual error, and it spit this out:

rustc exited with code 101
stderr: thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', bin/rustc.rs:49:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So, I added in a .env("RUSTC_STAGE", stage.to_string()), and it seems to mostly work now!

... until it reaches Checking stage0 clippy artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc), at which point it errors out with error: internal compiler error: compiler\rustc_monomorphize\src\collector.rs:1031:9: no MIR available for DefId(1:6900 ~ std[81ca]::process::{impl#22}::new) (oh the irony, clippy ICE'ing when it tries to check clippy).

In any case, the situation seems better than before, so I figured I'd submit this anyway.

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 13, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2022
@Mark-Simulacrum
Copy link
Member

Unfortunately, this is not the right fix. RUSTC_STAGE is read ~only by the bootstrap rustc shim we use to thread down certain arguments that can't be passed via RUSTFLAGS (and some legacy flags). I'm not quite sure why your PATH is setup such that that rustc is what is running here, that seems odd.

This code has always been pretty iffy; it's trying to avoid a proper integration into bootstrap (e.g., like we do for rustfmt), and that makes it pay the cost of being often broken in individual user's configurations. Since we don't officially support running Clippy on the standard library or compiler codebase, it's not something that we've invested time into fixing.

@khyperia
Copy link
Contributor Author

Since we don't officially support running Clippy on the standard library or compiler codebase, it's not something that we've invested time into fixing.

Good to know! A bit confusing to have an official-looking ./x.py clippy command, then, but good to know that's a missing stair to be avoided.

I'm not quite sure why your PATH is setup such that that rustc is what is running here, that seems odd.

Same! Printing PATH just before that command is executed shows nothing out of the ordinary, and even running a println!("{:?}", Command::new("where").arg("rustc").output()) prints out C:\Users\khype\.cargo\bin\rustc.exe. I'm very confused how this is working for everyone else!

I'll just close this then if it's just an issue on my machine.

@khyperia khyperia closed this Aug 13, 2022
@khyperia khyperia deleted the xpy-clippy-fix branch August 13, 2022 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants