From 1db9fabdf7ba45fcb5ee184254cabd696faf6414 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 18 Apr 2018 00:50:41 +0100 Subject: [PATCH] Do not rebuild LLVM for x.py check --- src/bootstrap/builder.rs | 6 ++++++ src/bootstrap/check.rs | 5 ++--- src/librustc_llvm/build.rs | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index dcc4134b2f30..872271c453ec 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -552,6 +552,12 @@ impl<'a> Builder<'a> { .arg("--target") .arg(target); + // Set a flag for `check` so that certain build scripts can do less work + // (e.g. not building/requiring LLVM). + if cmd == "check" { + cargo.env("RUST_CHECK", "1"); + } + // If we were invoked from `make` then that's already got a jobserver // set up for us so no need to tell Cargo about jobs all over again. if env::var_os("MAKEFLAGS").is_none() && env::var_os("MFLAGS").is_none() { diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index d7b8fa36b7f6..61e02b25e583 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -11,7 +11,6 @@ //! Implementation of compiling the compiler and standard library, in "check" mode. use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot}; -use compile::build_codegen_backend; use builder::{RunConfig, Builder, ShouldRun, Step}; use {Compiler, Mode}; use cache::{INTERNER, Interned}; @@ -138,11 +137,11 @@ impl Step for CodegenBackend { let backend = self.backend; let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check"); - let mut features = build.rustc_features().to_string(); + let features = build.rustc_features().to_string(); cargo.arg("--manifest-path").arg(build.src.join("src/librustc_trans/Cargo.toml")); rustc_cargo_env(build, &mut cargo); - features += &build_codegen_backend(&builder, &mut cargo, &compiler, target, backend); + // We won't build LLVM if it's not available, as it shouldn't affect `check`. let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage)); run_cargo(build, diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 54e3f544acb6..d09a3e8b9dad 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -28,6 +28,11 @@ fn detect_llvm_link() -> (&'static str, &'static str) { } fn main() { + if env::var_os("RUST_CHECK").is_some() { + // If we're just running `check`, there's no need for LLVM to be built. + return; + } + let target = env::var("TARGET").expect("TARGET was not set"); let llvm_config = env::var_os("LLVM_CONFIG") .map(PathBuf::from)