Skip to content

Commit f70ad0a

Browse files
committed
Auto merge of #38331 - bluss:assume-stage, r=alexcrichton
rustbuild: Add cli option --keep-stage This option is intended to be used like: ./x.py build --stage 1 --keep-stage 0 Which skips all stage 0 steps, so that stage 1 can be recompiled directly (even if for example libcore has changes). This is useful when working on `cfg(not(stage0))` parts of the libraries or when re-running stage 1 tests in libraries in general. Fixes #38326
2 parents 833b03a + 0e01427 commit f70ad0a

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/bootstrap/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ The script accepts commands, flags, and arguments to determine what to do:
4242
./x.py build --stage 0 src/libtest
4343
```
4444

45+
If files are dirty that would normally be rebuilt from stage 0, that can be
46+
overidden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
47+
that belong to stage n or earlier:
48+
49+
```
50+
# keep old build products for stage 0 and build stage 1
51+
./x.py build --keep-stage 0 --stage 1
52+
```
53+
4554
* `test` - a command for executing unit tests. Like the `build` command this
4655
will execute the entire test suite by default, and otherwise it can be used to
4756
select which test suite is run:

src/bootstrap/flags.rs

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use step;
2929
pub struct Flags {
3030
pub verbose: bool,
3131
pub stage: Option<u32>,
32+
pub keep_stage: Option<u32>,
3233
pub build: String,
3334
pub host: Vec<String>,
3435
pub target: Vec<String>,
@@ -68,6 +69,7 @@ impl Flags {
6869
opts.optmulti("", "host", "host targets to build", "HOST");
6970
opts.optmulti("", "target", "target targets to build", "TARGET");
7071
opts.optopt("", "stage", "stage to build", "N");
72+
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
7173
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
7274
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
7375
opts.optflag("h", "help", "print this help message");
@@ -257,6 +259,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
257259
Flags {
258260
verbose: m.opt_present("v"),
259261
stage: m.opt_str("stage").map(|j| j.parse().unwrap()),
262+
keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()),
260263
build: m.opt_str("build").unwrap_or_else(|| {
261264
env::var("BUILD").unwrap()
262265
}),

src/bootstrap/step.rs

+4
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
871871

872872
// And finally, iterate over everything and execute it.
873873
for step in order.iter() {
874+
if self.build.flags.keep_stage.map_or(false, |s| step.stage <= s) {
875+
self.build.verbose(&format!("keeping step {:?}", step));
876+
continue;
877+
}
874878
self.build.verbose(&format!("executing step {:?}", step));
875879
(self.rules[step.name].run)(step);
876880
}

0 commit comments

Comments
 (0)