Skip to content

Commit

Permalink
Rollup merge of #79970 - bjorn3:no_unnecessary_llvm_checkout, r=Mark-…
Browse files Browse the repository at this point in the history
…Simulacrum

Misc rustbuild improvements when the LLVM backend isn't used

* Don't checkout llvm-project
* Don't require cmake and ninja

Fixes #78564
  • Loading branch information
JohnTitor committed Dec 13, 2020
2 parents e4a663c + d79e19f commit d90084c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
14 changes: 9 additions & 5 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,17 @@ def update_submodules(self):
filtered_submodules = []
submodules_names = []
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:
if module.endswith("llvm-project"):
# Don't sync the llvm-project submodule either if an external LLVM
# was provided, or if we are downloading LLVM. Also, if the
# submodule has been initialized already, sync it anyways so that
# it doesn't mess up contributor pull requests.
if self.get_toml('llvm-config') or self.downloading_llvm():
# Don't sync the llvm-project submodule if an external LLVM was
# provided, if we are downloading LLVM or if the LLVM backend is
# not being built. Also, if the submodule has been initialized
# already, sync it anyways so that it doesn't mess up contributor
# pull requests.
if external_llvm_provided or not llvm_needed:
if self.get_toml('lld') != 'true' and not llvm_checked_out:
continue
check = self.check_submodule(module, slow_submodules)
Expand Down
36 changes: 20 additions & 16 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::process::Command;

use build_helper::{output, t};

use crate::cache::INTERNER;
use crate::config::Target;
use crate::Build;

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

// We need cmake, but only if we're actually building LLVM or sanitizers.
let building_llvm = build
.hosts
.iter()
.map(|host| {
build
.config
.target_config
.get(host)
.map(|config| config.llvm_config.is_none())
.unwrap_or(true)
})
.any(|build_llvm_ourselves| build_llvm_ourselves);
let building_llvm = build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
&& build
.hosts
.iter()
.map(|host| {
build
.config
.target_config
.get(host)
.map(|config| config.llvm_config.is_none())
.unwrap_or(true)
})
.any(|build_llvm_ourselves| build_llvm_ourselves);
if building_llvm || build.config.any_sanitizers_enabled() {
cmd_finder.must_have("cmake");
}
Expand Down Expand Up @@ -147,10 +149,12 @@ pub fn check(build: &mut Build) {
}
}

// Externally configured LLVM requires FileCheck to exist
let filecheck = build.llvm_filecheck(build.build);
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
panic!("FileCheck executable {:?} does not exist", filecheck);
if build.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
// Externally configured LLVM requires FileCheck to exist
let filecheck = build.llvm_filecheck(build.build);
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
panic!("FileCheck executable {:?} does not exist", filecheck);
}
}

for target in &build.targets {
Expand Down

0 comments on commit d90084c

Please sign in to comment.