Skip to content

Commit

Permalink
Don't skip building LLVM if already built
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed May 2, 2020
1 parent 131e120 commit 7f645ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,17 @@ impl<'a> Builder<'a> {
}

// Set a flag for `check`/`clippy`/`fix`, so that certain build
// scripts can do less work (e.g. not building/requiring LLVM).
// scripts can do less work (i.e. not building/requiring LLVM).
if cmd == "check" || cmd == "clippy" || cmd == "fix" {
cargo.env("RUST_CHECK", "1");
// If we've not yet built LLVM, or it's stale, then bust
// the librustc_llvm cache. That will always work, even though it
// may mean that on the next non-check build we'll need to rebuild
// librustc_llvm. But if LLVM is stale, that'll be a tiny amount
// of work comparitively, and we'd likely need to rebuild it anyway,
// so that's okay.
if crate::native::prebuilt_llvm_config(self, target).is_err() {
cargo.env("RUST_CHECK", "1");
}
}

let stage = if compiler.stage == 0 && self.local_rebuild {
Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,13 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne
// librustc_llvm and librustc_codegen_llvm.
//
// Note that this is disabled if LLVM itself is disabled or we're in a check
// build, where if we're in a check build there's no need to build all of
// LLVM and such.
if builder.config.llvm_enabled() && builder.kind != Kind::Check {
// build. If we are in a check build we still go ahead here presuming we've
// detected that LLVM is alreay built and good to go which helps prevent
// busting caches (e.g. like #71152).
if builder.config.llvm_enabled()
&& (builder.kind != Kind::Check
|| crate::native::prebuilt_llvm_config(builder, target).is_ok())
{
if builder.is_rust_llvm(target) {
cargo.env("LLVM_RUSTLLVM", "1");
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
}

fn main() {
println!("cargo:rerun-if-env-changed=RUST_CHECK");
if env::var_os("RUST_CHECK").is_some() {
// If we're just running `check`, there's no need for LLVM to be built.
println!("cargo:rerun-if-env-changed=RUST_CHECK");
return;
}

Expand Down

0 comments on commit 7f645ab

Please sign in to comment.