diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index b89976eca26c4..b6764c1aaeab6 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -287,10 +287,6 @@ fn main() { cmd.arg("--cfg").arg("parallel_queries"); } - if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() { - cmd.arg("-Z").arg("verify-llvm-ir"); - } - if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none() { cmd.arg("-Dwarnings"); diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index b842bc43f5baa..aa4e44df2ef94 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1000,10 +1000,6 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_BACKTRACE_ON_ICE", "1"); } - if self.config.rust_verify_llvm_ir { - cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); - } - cargo.env("RUSTC_VERBOSE", self.verbosity.to_string()); // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful. diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7d235743c2c46..69d45acdedaf9 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -569,6 +569,9 @@ pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) { if builder.config.rustc_parallel_queries { cargo.env("RUSTC_PARALLEL_QUERIES", "1"); } + if builder.config.rust_verify_llvm_ir { + cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); + } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] diff --git a/src/ci/run.sh b/src/ci/run.sh index a9e506645f189..42561cf95d3ac 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -61,6 +61,7 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" elif [ "$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir" fi else # We almost always want debug assertions enabled, but sometimes this takes too @@ -74,6 +75,8 @@ else if [ "$NO_LLVM_ASSERTIONS" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" fi + + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir" fi if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then diff --git a/src/librustc/build.rs b/src/librustc/build.rs index 4df5f0e64050c..bde503d86de73 100644 --- a/src/librustc/build.rs +++ b/src/librustc/build.rs @@ -8,8 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::env; + fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=CFG_LIBDIR_RELATIVE"); println!("cargo:rerun-if-env-changed=CFG_COMPILER_HOST_TRIPLE"); + println!("cargo:rerun-if-env-changed=RUSTC_VERIFY_LLVM_IR"); + + if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() { + println!("cargo:rustc-cfg=always_verify_llvm_ir"); + } } diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3c209a4324675..fbe252fcfaf50 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -531,6 +531,7 @@ impl Session { } pub fn verify_llvm_ir(&self) -> bool { self.opts.debugging_opts.verify_llvm_ir + || cfg!(always_verify_llvm_ir) } pub fn borrowck_stats(&self) -> bool { self.opts.debugging_opts.borrowck_stats