Skip to content

Commit 98111bd

Browse files
committed
simplify LLVM submodule handling
Keep the LLVM submodule logic in single function to make it clear when it's called. Signed-off-by: onur-ozkan <[email protected]>
1 parent 76ed7a1 commit 98111bd

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

-7
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ impl LdFlags {
8888
/// This will return the llvm-config if it can get it (but it will not build it
8989
/// if not).
9090
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
91-
// If we have llvm submodule initialized already, sync it.
92-
builder.update_existing_submodule("src/llvm-project");
93-
9491
builder.config.maybe_download_ci_llvm();
9592

9693
// If we're using a custom LLVM bail out here, but we can only use a
@@ -109,10 +106,6 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
109106
}
110107
}
111108

112-
// Initialize the llvm submodule if not initialized already.
113-
// If submodules are disabled, this does nothing.
114-
builder.config.update_submodule("src/llvm-project");
115-
116109
let root = "src/llvm-project/llvm";
117110
let out_dir = builder.llvm_out(target);
118111

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

+15-7
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,12 @@ impl Config {
27372737
) -> bool {
27382738
let download_ci_llvm = download_ci_llvm.unwrap_or(StringOrBool::Bool(true));
27392739

2740+
let update_llvm_submodule = || {
2741+
// Fetching the LLVM submodule is unnecessary for self-tests.
2742+
#[cfg(not(feature = "bootstrap-self-test"))]
2743+
self.update_submodule("src/llvm-project");
2744+
};
2745+
27402746
let if_unchanged = || {
27412747
if self.rust_info.is_from_tarball() {
27422748
// Git is needed for running "if-unchanged" logic.
@@ -2746,9 +2752,7 @@ impl Config {
27462752
return false;
27472753
}
27482754

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

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

27622766
match download_ci_llvm {
27632767
StringOrBool::Bool(b) => {
2764-
if !b && self.download_rustc_commit.is_some() {
2765-
panic!(
2766-
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
2767-
);
2768+
if !b {
2769+
if self.download_rustc_commit.is_some() {
2770+
panic!(
2771+
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
2772+
);
2773+
}
2774+
2775+
update_llvm_submodule();
27682776
}
27692777

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

0 commit comments

Comments
 (0)