Skip to content

Commit

Permalink
simplify LLVM submodule handling
Browse files Browse the repository at this point in the history
Keep the LLVM submodule logic in single function to make it clear when it's called.

Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Sep 27, 2024
1 parent 76ed7a1 commit 98111bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ impl LdFlags {
/// This will return the llvm-config if it can get it (but it will not build it
/// if not).
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
// If we have llvm submodule initialized already, sync it.
builder.update_existing_submodule("src/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 @@ -109,10 +106,6 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
}
}

// Initialize the llvm submodule if not initialized already.
// If submodules are disabled, this does nothing.
builder.config.update_submodule("src/llvm-project");

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

Expand Down
22 changes: 15 additions & 7 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,12 @@ impl Config {
) -> bool {
let download_ci_llvm = download_ci_llvm.unwrap_or(StringOrBool::Bool(true));

let update_llvm_submodule = || {
// Fetching the LLVM submodule is unnecessary for self-tests.
#[cfg(not(feature = "bootstrap-self-test"))]
self.update_submodule("src/llvm-project");
};

let if_unchanged = || {
if self.rust_info.is_from_tarball() {
// Git is needed for running "if-unchanged" logic.
Expand All @@ -2746,9 +2752,7 @@ impl Config {
return false;
}

// Fetching the LLVM submodule is unnecessary for self-tests.
#[cfg(not(feature = "bootstrap-self-test"))]
self.update_submodule("src/llvm-project");
update_llvm_submodule();

// Check for untracked changes in `src/llvm-project`.
let has_changes = self
Expand All @@ -2761,10 +2765,14 @@ impl Config {

match download_ci_llvm {
StringOrBool::Bool(b) => {
if !b && self.download_rustc_commit.is_some() {
panic!(
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
);
if !b {
if self.download_rustc_commit.is_some() {
panic!(
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
);
}

update_llvm_submodule();
}

// If download-ci-llvm=true we also want to check that CI llvm is available
Expand Down

0 comments on commit 98111bd

Please sign in to comment.