Skip to content

Commit b19896a

Browse files
authored
Unrolled build for rust-lang#122632
Rollup merge of rust-lang#122632 - onur-ozkan:fix-llvm-caching-bug, r=albertlarsan68 fetch submodule before checking llvm stamp Previously, we were checking the LLVM stamp before fetching the submodule which leads to not being able to compile llvm on submodule updates. Fixes rust-lang#122612 Fixes rust-lang#122787
2 parents 1dea922 + 3683b11 commit b19896a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ pub fn prebuilt_llvm_config(
7676
builder: &Builder<'_>,
7777
target: TargetSelection,
7878
) -> Result<LlvmResult, Meta> {
79+
// If we have llvm submodule initialized already, sync it.
80+
builder.update_existing_submodule(&Path::new("src").join("llvm-project"));
81+
7982
builder.config.maybe_download_ci_llvm();
8083

8184
// If we're using a custom LLVM bail out here, but we can only use a
@@ -94,6 +97,9 @@ pub fn prebuilt_llvm_config(
9497
}
9598
}
9699

100+
// Initialize the llvm submodule if not initialized already.
101+
builder.update_submodule(&Path::new("src").join("llvm-project"));
102+
97103
let root = "src/llvm-project/llvm";
98104
let out_dir = builder.llvm_out(target);
99105

@@ -280,7 +286,6 @@ impl Step for Llvm {
280286
Err(m) => m,
281287
};
282288

283-
builder.update_submodule(&Path::new("src").join("llvm-project"));
284289
if builder.llvm_link_shared() && target.is_windows() {
285290
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
286291
}

src/bootstrap/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ impl Build {
630630
}
631631
}
632632

633+
/// Updates the given submodule only if it's initialized already; nothing happens otherwise.
634+
pub fn update_existing_submodule(&self, submodule: &Path) {
635+
// Avoid running git when there isn't a git checkout.
636+
if !self.config.submodules(self.rust_info()) {
637+
return;
638+
}
639+
640+
if GitInfo::new(false, submodule).is_managed_git_subrepository() {
641+
self.update_submodule(submodule);
642+
}
643+
}
644+
633645
/// Executes the entire build, as configured by the flags and configuration.
634646
pub fn build(&mut self) {
635647
unsafe {

0 commit comments

Comments
 (0)