Skip to content

Commit b57366a

Browse files
committed
Improve verify_llvm_ir config option
* Make it influence the behavior of the compiled rustc, rather than just the rustc build system. That is, if verify_llvm_ir=true, even manual invocations of the built rustc will verify LLVM IR. * Enable verification of LLVM IR in CI, for non-deploy and deploy-alt builds. This is similar to how LLVM assertions are handled.
1 parent e1643a8 commit b57366a

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

src/bootstrap/bin/rustc.rs

-4
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,6 @@ fn main() {
287287
cmd.arg("--cfg").arg("parallel_queries");
288288
}
289289

290-
if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() {
291-
cmd.arg("-Z").arg("verify-llvm-ir");
292-
}
293-
294290
if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
295291
{
296292
cmd.arg("-Dwarnings");

src/bootstrap/builder.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,6 @@ impl<'a> Builder<'a> {
10001000
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
10011001
}
10021002

1003-
if self.config.rust_verify_llvm_ir {
1004-
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
1005-
}
1006-
10071003
cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
10081004

10091005
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.

src/bootstrap/compile.rs

+3
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) {
569569
if builder.config.rustc_parallel_queries {
570570
cargo.env("RUSTC_PARALLEL_QUERIES", "1");
571571
}
572+
if builder.config.rust_verify_llvm_ir {
573+
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
574+
}
572575
}
573576

574577
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/ci/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
6161
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
6262
elif [ "$DEPLOY_ALT" != "" ]; then
6363
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
64+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
6465
fi
6566
else
6667
# We almost always want debug assertions enabled, but sometimes this takes too
@@ -74,6 +75,8 @@ else
7475
if [ "$NO_LLVM_ASSERTIONS" = "" ]; then
7576
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
7677
fi
78+
79+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
7780
fi
7881

7982
if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then

src/librustc/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::env;
12+
1113
fn main() {
1214
println!("cargo:rerun-if-changed=build.rs");
1315
println!("cargo:rerun-if-env-changed=CFG_LIBDIR_RELATIVE");
1416
println!("cargo:rerun-if-env-changed=CFG_COMPILER_HOST_TRIPLE");
17+
println!("cargo:rerun-if-env-changed=RUSTC_VERIFY_LLVM_IR");
18+
19+
if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() {
20+
println!("cargo:rustc-cfg=always_verify_llvm_ir");
21+
}
1522
}

src/librustc/session/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ impl Session {
531531
}
532532
pub fn verify_llvm_ir(&self) -> bool {
533533
self.opts.debugging_opts.verify_llvm_ir
534+
|| cfg!(always_verify_llvm_ir)
534535
}
535536
pub fn borrowck_stats(&self) -> bool {
536537
self.opts.debugging_opts.borrowck_stats

0 commit comments

Comments
 (0)