Skip to content

Commit

Permalink
Rollup merge of rust-lang#77120 - ecstatic-morse:keep-stage-std, r=Ma…
Browse files Browse the repository at this point in the history
…rk-Simulacrum

Add `--keep-stage-std` to `x.py` for keeping only standard library artifacts

Unlike `--keep-stage 0`, `--keep-stage-std 0` will allow the stage 0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if it has changed. This allows contributors to iterate on later stages of the compiler in tandem with the standard library without needing to to rebuild the entire compiler. I often run into this when working on const-checking, since I may need to add a feature gate or make a small tweak to the standard library.
  • Loading branch information
RalfJung authored Sep 25, 2020
2 parents 838cb36 + 16769eb commit 7ee5798
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/bootstrap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Make the default stage for x.py configurable [#76625](https://github.com/rust-lang/rust/pull/76625)
- Add a dedicated debug-logging option [#76588](https://github.com/rust-lang/rust/pull/76588)
- Add sample defaults for x.py [#76628](https://github.com/rust-lang/rust/pull/76628)
- Add `--keep-stage-std`, which behaves like `keep-stage` but allows the stage
0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if changed
[#77120](https://github.com/rust-lang/rust/pull/77120).


## [Version 0] - 2020-09-11

Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ impl Step for Std {
let target = self.target;
let compiler = self.compiler;

if builder.config.keep_stage.contains(&compiler.stage) {
if builder.config.keep_stage.contains(&compiler.stage)
|| builder.config.keep_stage_std.contains(&compiler.stage)
{
builder.info("Warning: Using a potentially old libstd. This may not behave well.");
builder.ensure(StdLink { compiler, target_compiler: compiler, target });
return;
Expand Down Expand Up @@ -472,6 +474,7 @@ impl Step for Rustc {

if builder.config.keep_stage.contains(&compiler.stage) {
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
builder.info("Warning: Use `--keep-stage-std` if you want to rebuild the compiler when it changes");
builder.ensure(RustcLink { compiler, target_compiler: compiler, target });
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct Config {
pub on_fail: Option<String>,
pub stage: u32,
pub keep_stage: Vec<u32>,
pub keep_stage_std: Vec<u32>,
pub src: PathBuf,
// defaults to `config.toml`
pub config: PathBuf,
Expand Down Expand Up @@ -542,6 +543,7 @@ impl Config {
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
config.bindir = "bin".into(); // default
if let Some(value) = flags.deny_warnings {
config.deny_warnings = value;
Expand Down
17 changes: 16 additions & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct Flags {
pub on_fail: Option<String>,
pub stage: Option<u32>,
pub keep_stage: Vec<u32>,
pub keep_stage_std: Vec<u32>,

pub host: Option<Vec<TargetSelection>>,
pub target: Option<Vec<TargetSelection>>,
Expand Down Expand Up @@ -148,6 +149,13 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
(pass multiple times to keep e.g., both stages 0 and 1)",
"N",
);
opts.optmulti(
"",
"keep-stage-std",
"stage(s) of the standard library to keep without recompiling \
(pass multiple times to keep e.g., both stages 0 and 1)",
"N",
);
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
let j_msg = format!(
"number of jobs to run in parallel; \
Expand Down Expand Up @@ -540,7 +548,9 @@ Arguments:
println!("--stage not supported for x.py check, always treated as stage 0");
process::exit(1);
}
if matches.opt_str("keep-stage").is_some() {
if matches.opt_str("keep-stage").is_some()
|| matches.opt_str("keep-stage-std").is_some()
{
println!("--keep-stage not supported for x.py check, only one stage available");
process::exit(1);
}
Expand All @@ -558,6 +568,11 @@ Arguments:
.into_iter()
.map(|j| j.parse().expect("`keep-stage` should be a number"))
.collect(),
keep_stage_std: matches
.opt_strs("keep-stage-std")
.into_iter()
.map(|j| j.parse().expect("`keep-stage-std` should be a number"))
.collect(),
host: if matches.opt_present("host") {
Some(
split(&matches.opt_strs("host"))
Expand Down

0 comments on commit 7ee5798

Please sign in to comment.