Skip to content

Commit 2afa631

Browse files
authored
Rollup merge of #68074 - matthew-healy:skip-llvm-rebuild-option, r=Centril
Add `llvm-skip-rebuild` flag to `x.py` This PR follows on from #67437 to complete the feature request from #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.
2 parents c74ae96 + 7e50b59 commit 2afa631

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/bootstrap/config.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,13 @@ impl Config {
493493
config.mandir = install.mandir.clone().map(PathBuf::from);
494494
}
495495

496+
// We want the llvm-skip-rebuild flag to take precedence over the
497+
// skip-rebuild config.toml option so we store it separately
498+
// so that we can infer the right value
499+
let mut llvm_skip_rebuild = flags.llvm_skip_rebuild;
500+
496501
// Store off these values as options because if they're not provided
497502
// we'll infer default values for them later
498-
let mut llvm_skip_rebuild = None;
499503
let mut llvm_assertions = None;
500504
let mut debug = None;
501505
let mut debug_assertions = None;
@@ -517,7 +521,7 @@ impl Config {
517521
}
518522
set(&mut config.ninja, llvm.ninja);
519523
llvm_assertions = llvm.assertions;
520-
llvm_skip_rebuild = llvm.skip_rebuild;
524+
llvm_skip_rebuild = llvm_skip_rebuild.or(llvm.skip_rebuild);
521525
set(&mut config.llvm_optimize, llvm.optimize);
522526
set(&mut config.llvm_thin_lto, llvm.thin_lto);
523527
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);

src/bootstrap/flags.rs

+13
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct Flags {
3838
//
3939
// true => deny, false => warn
4040
pub deny_warnings: Option<bool>,
41+
42+
pub llvm_skip_rebuild: Option<bool>,
4143
}
4244

4345
pub enum Subcommand {
@@ -150,6 +152,14 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
150152
"VALUE",
151153
);
152154
opts.optopt("", "error-format", "rustc error format", "FORMAT");
155+
opts.optopt(
156+
"",
157+
"llvm-skip-rebuild",
158+
"whether rebuilding llvm should be skipped \
159+
a VALUE of TRUE indicates that llvm will not be rebuilt \
160+
VALUE overrides the skip-rebuild option in config.toml.",
161+
"VALUE",
162+
);
153163

154164
// fn usage()
155165
let usage =
@@ -487,6 +497,9 @@ Arguments:
487497
.map(|p| p.into())
488498
.collect::<Vec<_>>(),
489499
deny_warnings: parse_deny_warnings(&matches),
500+
llvm_skip_rebuild: matches.opt_str("llvm-skip-rebuild").map(|s| s.to_lowercase()).map(
501+
|s| s.parse::<bool>().expect("`llvm-skip-rebuild` should be either true or false"),
502+
),
490503
}
491504
}
492505
}

0 commit comments

Comments
 (0)