Skip to content

Commit d90084c

Browse files
authored
Rollup merge of #79970 - bjorn3:no_unnecessary_llvm_checkout, r=Mark-Simulacrum
Misc rustbuild improvements when the LLVM backend isn't used * Don't checkout llvm-project * Don't require cmake and ninja Fixes #78564
2 parents e4a663c + d79e19f commit d90084c

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

src/bootstrap/bootstrap.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -897,13 +897,17 @@ def update_submodules(self):
897897
filtered_submodules = []
898898
submodules_names = []
899899
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
900+
external_llvm_provided = self.get_toml('llvm-config') or self.downloading_llvm()
901+
llvm_needed = not self.get_toml('codegen-backends', 'rust') \
902+
or "llvm" in self.get_toml('codegen-backends', 'rust')
900903
for module in submodules:
901904
if module.endswith("llvm-project"):
902-
# Don't sync the llvm-project submodule either if an external LLVM
903-
# was provided, or if we are downloading LLVM. Also, if the
904-
# submodule has been initialized already, sync it anyways so that
905-
# it doesn't mess up contributor pull requests.
906-
if self.get_toml('llvm-config') or self.downloading_llvm():
905+
# Don't sync the llvm-project submodule if an external LLVM was
906+
# provided, if we are downloading LLVM or if the LLVM backend is
907+
# not being built. Also, if the submodule has been initialized
908+
# already, sync it anyways so that it doesn't mess up contributor
909+
# pull requests.
910+
if external_llvm_provided or not llvm_needed:
907911
if self.get_toml('lld') != 'true' and not llvm_checked_out:
908912
continue
909913
check = self.check_submodule(module, slow_submodules)

src/bootstrap/sanity.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::process::Command;
1717

1818
use build_helper::{output, t};
1919

20+
use crate::cache::INTERNER;
2021
use crate::config::Target;
2122
use crate::Build;
2223

@@ -79,18 +80,19 @@ pub fn check(build: &mut Build) {
7980
}
8081

8182
// We need cmake, but only if we're actually building LLVM or sanitizers.
82-
let building_llvm = build
83-
.hosts
84-
.iter()
85-
.map(|host| {
86-
build
87-
.config
88-
.target_config
89-
.get(host)
90-
.map(|config| config.llvm_config.is_none())
91-
.unwrap_or(true)
92-
})
93-
.any(|build_llvm_ourselves| build_llvm_ourselves);
83+
let building_llvm = build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
84+
&& build
85+
.hosts
86+
.iter()
87+
.map(|host| {
88+
build
89+
.config
90+
.target_config
91+
.get(host)
92+
.map(|config| config.llvm_config.is_none())
93+
.unwrap_or(true)
94+
})
95+
.any(|build_llvm_ourselves| build_llvm_ourselves);
9496
if building_llvm || build.config.any_sanitizers_enabled() {
9597
cmd_finder.must_have("cmake");
9698
}
@@ -147,10 +149,12 @@ pub fn check(build: &mut Build) {
147149
}
148150
}
149151

150-
// Externally configured LLVM requires FileCheck to exist
151-
let filecheck = build.llvm_filecheck(build.build);
152-
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
153-
panic!("FileCheck executable {:?} does not exist", filecheck);
152+
if build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
153+
// Externally configured LLVM requires FileCheck to exist
154+
let filecheck = build.llvm_filecheck(build.build);
155+
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
156+
panic!("FileCheck executable {:?} does not exist", filecheck);
157+
}
154158
}
155159

156160
for target in &build.targets {

0 commit comments

Comments
 (0)