Skip to content

Commit 3683b11

Browse files
committed
create Build::update_existing_submodule and use for llvm
Signed-off-by: onur-ozkan <[email protected]>
1 parent b75e6b4 commit 3683b11

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

+5
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,7 +97,9 @@ pub fn prebuilt_llvm_config(
9497
}
9598
}
9699

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

src/bootstrap/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,18 @@ impl Build {
625625
}
626626
}
627627

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

0 commit comments

Comments
 (0)