Skip to content

Commit 17f03b3

Browse files
Rollup merge of rust-lang#158380 - folkertdev:revert-rebuild-llvm-on-bootstrap-change, r=folkertdev
Revert "rebuild LLVM when `bootstrap.toml` config changes" This reverts commit 48e7c28. Turns out that currently this change makes perf a lot worse, see rust-lang#157836 (comment). cc @panstromek @Kobzol r? @ghost
2 parents 26daeac + 0083485 commit 17f03b3

4 files changed

Lines changed: 6 additions & 109 deletions

File tree

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub fn prebuilt_llvm_config(
169169
generate_smart_stamp_hash(
170170
builder,
171171
&builder.config.src.join("src/llvm-project"),
172-
&builder.llvm_cache_key(),
172+
builder.in_tree_llvm_info.sha().unwrap_or_default(),
173173
)
174174
});
175175

@@ -999,7 +999,7 @@ impl Step for OmpOffload {
999999
generate_smart_stamp_hash(
10001000
builder,
10011001
&builder.config.src.join("src/llvm-project/offload"),
1002-
&builder.llvm_cache_key(),
1002+
builder.in_tree_llvm_info.sha().unwrap_or_default(),
10031003
)
10041004
});
10051005
let stamp = BuildStamp::new(&out_dir).with_prefix("offload").add_stamp(smart_stamp_hash);
@@ -1166,8 +1166,8 @@ impl Step for Enzyme {
11661166
// Enzyme links against LLVM. If we update the LLVM submodule libLLVM might get a new
11671167
// version number, in which case Enzyme will now fail to find LLVM. By including the LLVM
11681168
// hash into the Enzyme hash we force a rebuild of Enzyme when updating LLVM.
1169-
let enzyme_hash_input =
1170-
builder.llvm_cache_key() + builder.enzyme_info.sha().unwrap_or_default();
1169+
let enzyme_hash_input = builder.in_tree_llvm_info.sha().unwrap_or_default().to_owned()
1170+
+ builder.enzyme_info.sha().unwrap_or_default();
11711171

11721172
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
11731173
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
@@ -1430,7 +1430,7 @@ impl Step for Sanitizers {
14301430
generate_smart_stamp_hash(
14311431
builder,
14321432
&builder.config.src.join("src/llvm-project/compiler-rt"),
1433-
&builder.llvm_cache_key(),
1433+
builder.in_tree_llvm_info.sha().unwrap_or_default(),
14341434
)
14351435
});
14361436

src/bootstrap/src/core/builder/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,16 +1687,6 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
16871687
pub fn exec_ctx(&self) -> &ExecutionContext {
16881688
&self.config.exec_ctx
16891689
}
1690-
1691-
/// When to rebuild LLVM. Currently includes the LLVM commit hash and the configuration from
1692-
/// bootstrap.toml.
1693-
pub(crate) fn llvm_cache_key(&self) -> String {
1694-
format!(
1695-
"sha={sha}\nkey={key}",
1696-
sha = self.in_tree_llvm_info.sha().unwrap_or_default(),
1697-
key = self.config.llvm_cache_key,
1698-
)
1699-
}
17001690
}
17011691

17021692
/// Return qualified step name, e.g. `compile::Rustc`.

src/bootstrap/src/core/config/config.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ pub struct Config {
156156
pub backtrace_on_ice: bool,
157157

158158
// llvm codegen options
159-
/// Key used to decide when to rebuild LLVM.
160-
pub llvm_cache_key: String,
161-
162159
pub llvm_assertions: bool,
163160
pub llvm_tests: bool,
164161
pub llvm_enzyme: bool,
@@ -598,8 +595,6 @@ impl Config {
598595
rustflags: rust_rustflags,
599596
} = toml.rust.unwrap_or_default();
600597

601-
let llvm = toml.llvm.unwrap_or_default();
602-
let llvm_cache_key = llvm.cache_key();
603598
let Llvm {
604599
optimize: llvm_optimize,
605600
thin_lto: llvm_thin_lto,
@@ -630,7 +625,7 @@ impl Config {
630625
enable_warnings: llvm_enable_warnings,
631626
download_ci_llvm: llvm_download_ci_llvm,
632627
build_config: llvm_build_config,
633-
} = llvm;
628+
} = toml.llvm.unwrap_or_default();
634629

635630
let Dist {
636631
sign_folder: dist_sign_folder,
@@ -1406,7 +1401,6 @@ impl Config {
14061401
llvm_assertions,
14071402
llvm_bitcode_linker_enabled: rust_llvm_bitcode_linker.unwrap_or(false),
14081403
llvm_build_config: llvm_build_config.clone().unwrap_or(Default::default()),
1409-
llvm_cache_key,
14101404
llvm_cflags,
14111405
llvm_clang: llvm_clang.unwrap_or(false),
14121406
llvm_clang_cl,

src/bootstrap/src/core/config/toml/llvm.rs

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -43,93 +43,6 @@ define_config! {
4343
}
4444
}
4545

46-
impl Llvm {
47-
/// A key that is used to determine whether LLVM should be rebuilt.
48-
pub(crate) fn cache_key(&self) -> String {
49-
let helper = || {
50-
let mut key = String::with_capacity(512);
51-
52-
let Self {
53-
optimize,
54-
thin_lto,
55-
release_debuginfo,
56-
assertions,
57-
tests,
58-
enzyme,
59-
plugins,
60-
static_libstdcpp,
61-
libzstd,
62-
ninja,
63-
targets,
64-
experimental_targets,
65-
link_jobs: _,
66-
link_shared,
67-
version_suffix,
68-
clang_cl,
69-
cflags,
70-
cxxflags,
71-
ldflags,
72-
use_libcxx,
73-
use_linker,
74-
allow_old_toolchain,
75-
offload,
76-
polly,
77-
offload_clang_dir,
78-
clang,
79-
enable_warnings: _,
80-
build_config,
81-
download_ci_llvm: _,
82-
} = self;
83-
84-
use std::fmt::Write;
85-
write!(key, "{:?}", optimize)?;
86-
write!(key, "{:?}", thin_lto)?;
87-
write!(key, "{:?}", release_debuginfo)?;
88-
write!(key, "{:?}", assertions)?;
89-
write!(key, "{:?}", tests)?;
90-
write!(key, "{:?}", enzyme)?;
91-
write!(key, "{:?}", plugins)?;
92-
write!(key, "{:?}", static_libstdcpp)?;
93-
write!(key, "{:?}", libzstd)?;
94-
write!(key, "{:?}", ninja)?;
95-
write!(key, "{:?}", targets)?;
96-
write!(key, "{:?}", experimental_targets)?;
97-
write!(key, "{:?}", link_shared)?;
98-
write!(key, "{:?}", version_suffix)?;
99-
write!(key, "{:?}", clang_cl)?;
100-
write!(key, "{:?}", cflags)?;
101-
write!(key, "{:?}", cxxflags)?;
102-
write!(key, "{:?}", ldflags)?;
103-
write!(key, "{:?}", use_libcxx)?;
104-
write!(key, "{:?}", use_linker)?;
105-
write!(key, "{:?}", allow_old_toolchain)?;
106-
write!(key, "{:?}", offload)?;
107-
write!(key, "{:?}", polly)?;
108-
write!(key, "{:?}", offload_clang_dir)?;
109-
write!(key, "{:?}", clang)?;
110-
111-
match build_config {
112-
None => {
113-
write!(key, "None")?;
114-
}
115-
Some(c) => {
116-
let mut build_config = c.iter().collect::<Vec<_>>();
117-
build_config.sort();
118-
119-
for (k, v) in build_config {
120-
write!(key, "{}: {}", k, v)?;
121-
}
122-
}
123-
}
124-
125-
Ok::<_, std::fmt::Error>(key)
126-
};
127-
128-
// write! to a String always succeeds unless OOM.
129-
helper().unwrap()
130-
}
131-
}
132-
13346
/// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options.
13447
/// It does this by destructuring the `Llvm` instance to make sure every `Llvm` field is covered and not missing.
13548
#[cfg(not(test))]

0 commit comments

Comments
 (0)