Skip to content

Commit 41501a6

Browse files
committed
Auto merge of #67437 - matthew-healy:skip-llvm-rebuild, r=Mark-Simulacrum
Add LLVM `skip-rebuild` option to `x.py` This PR reimplements parts of @Walther's work from #65848, and closes #65612. I decided not to implement the [arguments to override this setting](#65612 (comment)) in this PR. If there's strong feeling that this change shouldn't be merged without the overrides then I'm happy to close this until I've had a chance to add them in. Otherwise I'll aim to submit a second PR with those this weekend. I'd have liked to have tested the change in `native.rs`, but there didn't seem to be any existing test infrastructure. I ran this a few times manually and it _worked on my machine_ though... 😬
2 parents 8f5f8f9 + e44fc45 commit 41501a6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

config.toml.example

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
# =============================================================================
1515
[llvm]
1616

17+
# Indicates whether LLVM rebuild should be skipped when running bootstrap. If
18+
# this is `false` then the compiler's LLVM will be rebuilt whenever the built
19+
# version doesn't have the correct hash. If it is `true` then LLVM will never
20+
# be rebuilt. The default value is `false`.
21+
#skip-rebuild = false
22+
1723
# Indicates whether the LLVM build is a Release or Debug build
1824
#optimize = true
1925

src/bootstrap/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct Config {
6767
pub backtrace_on_ice: bool,
6868

6969
// llvm codegen options
70+
pub llvm_skip_rebuild: bool,
7071
pub llvm_assertions: bool,
7172
pub llvm_optimize: bool,
7273
pub llvm_thin_lto: bool,
@@ -244,6 +245,7 @@ struct Install {
244245
#[derive(Deserialize, Default)]
245246
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
246247
struct Llvm {
248+
skip_rebuild: Option<bool>,
247249
optimize: Option<bool>,
248250
thin_lto: Option<bool>,
249251
release_debuginfo: Option<bool>,
@@ -490,6 +492,7 @@ impl Config {
490492

491493
// Store off these values as options because if they're not provided
492494
// we'll infer default values for them later
495+
let mut llvm_skip_rebuild = None;
493496
let mut llvm_assertions = None;
494497
let mut debug = None;
495498
let mut debug_assertions = None;
@@ -511,6 +514,7 @@ impl Config {
511514
}
512515
set(&mut config.ninja, llvm.ninja);
513516
llvm_assertions = llvm.assertions;
517+
llvm_skip_rebuild = llvm.skip_rebuild;
514518
set(&mut config.llvm_optimize, llvm.optimize);
515519
set(&mut config.llvm_thin_lto, llvm.thin_lto);
516520
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
@@ -617,6 +621,8 @@ impl Config {
617621
set(&mut config.initial_rustc, build.rustc.map(PathBuf::from));
618622
set(&mut config.initial_cargo, build.cargo.map(PathBuf::from));
619623

624+
config.llvm_skip_rebuild = llvm_skip_rebuild.unwrap_or(false);
625+
620626
let default = false;
621627
config.llvm_assertions = llvm_assertions.unwrap_or(default);
622628

src/bootstrap/native.rs

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ impl Step for Llvm {
7070
let done_stamp = out_dir.join("llvm-finished-building");
7171

7272
if done_stamp.exists() {
73+
if builder.config.llvm_skip_rebuild {
74+
builder.info(
75+
"Warning: \
76+
Using a potentially stale build of LLVM; \
77+
This may not behave well.",
78+
);
79+
return build_llvm_config;
80+
}
81+
7382
if let Some(llvm_commit) = llvm_info.sha() {
7483
let done_contents = t!(fs::read(&done_stamp));
7584

0 commit comments

Comments
 (0)