Skip to content

Commit cfe78d9

Browse files
authored
Rollup merge of rust-lang#141970 - onur-ozkan:skip-stage1-std, r=Kobzol
implement new `x` flag: `--skip-std-check-if-no-download-rustc` One of our developers (``@RalfJung)`` [reported](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606)[#t-infra/bootstrap > Surprising stages for check build after stage reorg](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606) that working on both the compiler and the library simultaneously with RA enabled is extremely difficult because checking library creates a heavy load on machines (by building stage1 compiler) on each modification. `--skip-std-check-if-no-download-rustc` flag is intended to reduce this heavy load on their IDE integration as much as possible. Fixes: rust-lang#141955
2 parents 0ea49dc + c843bec commit cfe78d9

File tree

13 files changed

+217
-48
lines changed

13 files changed

+217
-48
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ impl Step for Std {
7777
}
7878

7979
fn run(self, builder: &Builder<'_>) {
80+
if !builder.download_rustc() && builder.config.skip_std_check_if_no_download_rustc {
81+
eprintln!(
82+
"WARNING: `--skip-std-check-if-no-download-rustc` flag was passed and `rust.download-rustc` is not available. Skipping."
83+
);
84+
return;
85+
}
86+
8087
builder.require_submodule("library/stdarch", None);
8188

8289
let stage = self.custom_stage.unwrap_or(builder.top_stage);

src/bootstrap/src/core/config/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ pub struct Config {
423423

424424
/// Cache for determining path modifications
425425
pub path_modification_cache: Arc<Mutex<HashMap<Vec<&'static str>, PathFreshness>>>,
426+
427+
/// Skip checking the standard library if `rust.download-rustc` isn't available.
428+
/// This is mostly for RA as building the stage1 compiler to check the library tree
429+
/// on each code change might be too much for some computers.
430+
pub skip_std_check_if_no_download_rustc: bool,
426431
}
427432

428433
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
@@ -1507,6 +1512,7 @@ impl Config {
15071512
config.enable_bolt_settings = flags.enable_bolt_settings;
15081513
config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock;
15091514
config.is_running_on_ci = flags.ci.unwrap_or(CiEnv::is_ci());
1515+
config.skip_std_check_if_no_download_rustc = flags.skip_std_check_if_no_download_rustc;
15101516

15111517
// Infer the rest of the configuration.
15121518

src/bootstrap/src/core/config/flags.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ pub struct Flags {
182182
/// Make bootstrap to behave as it's running on the CI environment or not.
183183
#[arg(global = true, long, value_name = "bool")]
184184
pub ci: Option<bool>,
185+
/// Skip checking the standard library if `rust.download-rustc` isn't available.
186+
/// This is mostly for RA as building the stage1 compiler to check the library tree
187+
/// on each code change might be too much for some computers.
188+
#[arg(global = true, long)]
189+
pub skip_std_check_if_no_download_rustc: bool,
185190
}
186191

187192
impl Flags {

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
416416
severity: ChangeSeverity::Warning,
417417
summary: "Stage0 library no longer matches the in-tree library, which means stage1 compiler now uses the beta library.",
418418
},
419+
ChangeInfo {
420+
change_id: 141970,
421+
severity: ChangeSeverity::Info,
422+
summary: "Added new bootstrap flag `--skip-std-check-if-no-download-rustc` that skips std checks when download-rustc is unavailable. Mainly intended for developers to reduce RA overhead.",
423+
},
419424
];

src/doc/rustc-dev-guide/src/building/suggested.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ always overrides the inner ones.
5959

6060
## Configuring `rust-analyzer` for `rustc`
6161

62+
### Checking the "library" tree
63+
64+
Checking the "library" tree requires a stage1 compiler, which can be a heavy process on some computers.
65+
For this reason, bootstrap has a flag called `--skip-std-check-if-no-download-rustc` that skips checking the
66+
"library" tree if `rust.download-rustc` isn't available. If you want to avoid putting a heavy load on your computer
67+
with `rust-analyzer`, you can add the `--skip-std-check-if-no-download-rustc` flag to your `./x check` command in
68+
the `rust-analyzer` configuration.
69+
6270
### Project-local rust-analyzer setup
6371

6472
`rust-analyzer` can help you check and format your code whenever you save a

src/etc/completions/x.fish

Lines changed: 24 additions & 1 deletion
Large diffs are not rendered by default.

src/etc/completions/x.ps1

Lines changed: 23 additions & 0 deletions
Large diffs are not rendered by default.

src/etc/completions/x.py.fish

Lines changed: 24 additions & 1 deletion
Large diffs are not rendered by default.

src/etc/completions/x.py.ps1

Lines changed: 23 additions & 0 deletions
Large diffs are not rendered by default.

src/etc/completions/x.py.sh

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)