Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch submodule before checking llvm stamp #122632

Merged
merged 2 commits into from Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Expand Up @@ -76,6 +76,9 @@ pub fn prebuilt_llvm_config(
builder: &Builder<'_>,
target: TargetSelection,
) -> Result<LlvmResult, Meta> {
// If we have llvm submodule initialized already, sync it.
builder.update_existing_submodule(&Path::new("src").join("llvm-project"));

builder.config.maybe_download_ci_llvm();

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

// Initialize the llvm submodule if not initialized already.
builder.update_submodule(&Path::new("src").join("llvm-project"));

let root = "src/llvm-project/llvm";
let out_dir = builder.llvm_out(target);

Expand Down Expand Up @@ -279,7 +285,6 @@ impl Step for Llvm {
Err(m) => m,
};

builder.update_submodule(&Path::new("src").join("llvm-project"));
if builder.llvm_link_shared() && target.is_windows() {
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
}
Expand Down
12 changes: 12 additions & 0 deletions src/bootstrap/src/lib.rs
Expand Up @@ -625,6 +625,18 @@ impl Build {
}
}

/// Updates the given submodule only if it's initialized already; nothing happens otherwise.
pub fn update_existing_submodule(&self, submodule: &Path) {
// Avoid running git when there isn't a git checkout.
if !self.config.submodules(self.rust_info()) {
return;
}

if GitInfo::new(false, submodule).is_managed_git_subrepository() {
self.update_submodule(submodule);
}
}

/// Executes the entire build, as configured by the flags and configuration.
pub fn build(&mut self) {
unsafe {
Expand Down