Skip to content

Add --compile-time-deps argument for x check #143785

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Jul 11, 2025

Together with skipping building C++ code in rustc_llvm for check, this reduces the amount of time it takes to do the x check for rust-analyzer analysis from 12m16s to 3m06s when the bootstrap compiler is already downloaded.

@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

r? @clubby789

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

@rustbot rustbot added 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) labels Jul 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This reduces the amount of time it takes to do the x check for
rust-analyzer analysis from 12m16s to 3m34s when the bootstrap compiler
is already downloaded.
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jul 11, 2025
@Kobzol
Copy link
Member

Kobzol commented Jul 11, 2025

r? @Kobzol

I don't use RA much, so could you please walk me through what exactly this does? I know that RA/RustRover wanted this flag to only compile proc macros and compile + run build scripts to speed up the initial analysis of the crate. In RustRover it's not that critical, because it caches stuff heavily. If I understand it correctly, RA doesn't cache stuff between executions, so if you reopen the rustc project, it has to do x check from scratch to prime its analysis engine? And this will cause bootstrap to only do the minimum amount of work necessary to achieve that? So it only helps for the initial startup, but then if you make changes to rustc and RA runs x check in the background, it won't be applied?

@rustbot rustbot assigned Kobzol and unassigned clubby789 Jul 11, 2025
@ShoyuVanilla
Copy link
Member

r? @Kobzol

I don't use RA much, so could you please walk me through what exactly this does? I know that RA/RustRover wanted this flag to only compile proc macros and compile + run build scripts to speed up the initial analysis of the crate. In RustRover it's not that critical, because it caches stuff heavily. If I understand it correctly, RA doesn't cache stuff between executions, so if you reopen the rustc project, it has to do x check from scratch to prime its analysis engine? And this will cause bootstrap to only do the minimum amount of work necessary to achieve that? So it only helps for the initial startup, but then if you make changes to rustc and RA runs x check in the background, it won't be applied?

Basically you're correct but there are two things to clarify:

  • RA doesn't have persistent cache (yet) but it runs cargo check (--compile-time-deps) to build the necessary artifacts to the filesystem. So this is not directly related to cache priming and RA and RR can equally benefit from this.
  • And it only helps the very first run wrt build scripts and proc macro dependency changes. As mentioned above, all artifacts needed are built into filesystem and as you said, further interactions inside RA trigger cargo check without --compile-time-deps option and also leave artifacts to filesystem. Since then, any new runs won't benefit from this as there isn't anything to build when starting RA (though it might help slightly by reducing fingerprint checks)

@Kobzol
Copy link
Member

Kobzol commented Jul 11, 2025

I see. So it only helps if you open RA after clearing the build directory or changing the checked out rustc SHA a lot? 12 minutes sounds quite brutal, I wonder if the RA build script command should be changed to x check compiler instead of x check or something.

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 11, 2025

So it only helps if you open RA after clearing the build directory or changing the checked out rustc SHA a lot?

Yes

I wonder if the RA build script command should be changed to x check compiler instead of x check or something.

That would hurt working on things other than rustc, like clippy, miri or rustfmt.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Could you please add a change_tracker.rs entry with Info level about this?

@@ -2542,6 +2542,11 @@ pub fn stream_cargo(
}
cmd.arg("--message-format").arg(message_format);

if builder.config.compile_time_deps {
cmd.arg("-Zunstable-options");
cmd.arg("--compile-time-deps");
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a brief comment here, explaining what the flag does. Also I would move this into Builder::cargo, in stream_cargo we shouldn't be doing large modifications to the Cargo command anymore, we only configure output diagnostics and message format (which are actually related to streaming).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

6 participants