1
Fork 0

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
This commit is contained in:
Yuki Okushi 2020-12-13 11:05:43 +09:00 committed by GitHub
commit d90084c226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 21 deletions

View file

@ -897,13 +897,17 @@ class RustBuild(object):
filtered_submodules = [] filtered_submodules = []
submodules_names = [] submodules_names = []
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git")) llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
external_llvm_provided = self.get_toml('llvm-config') or self.downloading_llvm()
llvm_needed = not self.get_toml('codegen-backends', 'rust') \
or "llvm" in self.get_toml('codegen-backends', 'rust')
for module in submodules: for module in submodules:
if module.endswith("llvm-project"): if module.endswith("llvm-project"):
# Don't sync the llvm-project submodule either if an external LLVM # Don't sync the llvm-project submodule if an external LLVM was
# was provided, or if we are downloading LLVM. Also, if the # provided, if we are downloading LLVM or if the LLVM backend is
# submodule has been initialized already, sync it anyways so that # not being built. Also, if the submodule has been initialized
# it doesn't mess up contributor pull requests. # already, sync it anyways so that it doesn't mess up contributor
if self.get_toml('llvm-config') or self.downloading_llvm(): # pull requests.
if external_llvm_provided or not llvm_needed:
if self.get_toml('lld') != 'true' and not llvm_checked_out: if self.get_toml('lld') != 'true' and not llvm_checked_out:
continue continue
check = self.check_submodule(module, slow_submodules) check = self.check_submodule(module, slow_submodules)

View file

@ -17,6 +17,7 @@ use std::process::Command;
use build_helper::{output, t}; use build_helper::{output, t};
use crate::cache::INTERNER;
use crate::config::Target; use crate::config::Target;
use crate::Build; use crate::Build;
@ -79,18 +80,19 @@ pub fn check(build: &mut Build) {
} }
// We need cmake, but only if we're actually building LLVM or sanitizers. // We need cmake, but only if we're actually building LLVM or sanitizers.
let building_llvm = build let building_llvm = build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
.hosts && build
.iter() .hosts
.map(|host| { .iter()
build .map(|host| {
.config build
.target_config .config
.get(host) .target_config
.map(|config| config.llvm_config.is_none()) .get(host)
.unwrap_or(true) .map(|config| config.llvm_config.is_none())
}) .unwrap_or(true)
.any(|build_llvm_ourselves| build_llvm_ourselves); })
.any(|build_llvm_ourselves| build_llvm_ourselves);
if building_llvm || build.config.any_sanitizers_enabled() { if building_llvm || build.config.any_sanitizers_enabled() {
cmd_finder.must_have("cmake"); cmd_finder.must_have("cmake");
} }
@ -147,10 +149,12 @@ pub fn check(build: &mut Build) {
} }
} }
// Externally configured LLVM requires FileCheck to exist if build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
let filecheck = build.llvm_filecheck(build.build); // Externally configured LLVM requires FileCheck to exist
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests { let filecheck = build.llvm_filecheck(build.build);
panic!("FileCheck executable {:?} does not exist", filecheck); if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
panic!("FileCheck executable {:?} does not exist", filecheck);
}
} }
for target in &build.targets { for target in &build.targets {