Skip to content

Commit

Permalink
Rollup merge of rust-lang#68074 - matthew-healy:skip-llvm-rebuild-opt…
Browse files Browse the repository at this point in the history
…ion, r=Centril

Add `llvm-skip-rebuild` flag to `x.py`

This PR follows on from rust-lang#67437 to complete the feature request from rust-lang#65612.

Specifically it adds a new command-line flag, `--llvm-skip-rebuild`, which overrides both any value set in `config.toml` and the default value (`false`).

I'm not 100% confident that I've implemented the override in the "best" way, but I've checked it locally and it seems to work at least.

This option isn't currently mentioned in the Guide to Rustc Development. I'd be happy to write something on it if folk think that's worthwhile.
  • Loading branch information
Centril authored Jan 11, 2020
2 parents 8c0c5c7 + 7e50b59 commit ef3e360
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,13 @@ impl Config {
config.mandir = install.mandir.clone().map(PathBuf::from);
}

// We want the llvm-skip-rebuild flag to take precedence over the
// skip-rebuild config.toml option so we store it separately
// so that we can infer the right value
let mut llvm_skip_rebuild = flags.llvm_skip_rebuild;

// Store off these values as options because if they're not provided
// we'll infer default values for them later
let mut llvm_skip_rebuild = None;
let mut llvm_assertions = None;
let mut debug = None;
let mut debug_assertions = None;
Expand All @@ -517,7 +521,7 @@ impl Config {
}
set(&mut config.ninja, llvm.ninja);
llvm_assertions = llvm.assertions;
llvm_skip_rebuild = llvm.skip_rebuild;
llvm_skip_rebuild = llvm_skip_rebuild.or(llvm.skip_rebuild);
set(&mut config.llvm_optimize, llvm.optimize);
set(&mut config.llvm_thin_lto, llvm.thin_lto);
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
Expand Down
13 changes: 13 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub struct Flags {
//
// true => deny, false => warn
pub deny_warnings: Option<bool>,

pub llvm_skip_rebuild: Option<bool>,
}

pub enum Subcommand {
Expand Down Expand Up @@ -150,6 +152,14 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
"VALUE",
);
opts.optopt("", "error-format", "rustc error format", "FORMAT");
opts.optopt(
"",
"llvm-skip-rebuild",
"whether rebuilding llvm should be skipped \
a VALUE of TRUE indicates that llvm will not be rebuilt \
VALUE overrides the skip-rebuild option in config.toml.",
"VALUE",
);

// fn usage()
let usage =
Expand Down Expand Up @@ -487,6 +497,9 @@ Arguments:
.map(|p| p.into())
.collect::<Vec<_>>(),
deny_warnings: parse_deny_warnings(&matches),
llvm_skip_rebuild: matches.opt_str("llvm-skip-rebuild").map(|s| s.to_lowercase()).map(
|s| s.parse::<bool>().expect("`llvm-skip-rebuild` should be either true or false"),
),
}
}
}
Expand Down

0 comments on commit ef3e360

Please sign in to comment.