diff --git a/config.toml.example b/config.toml.example index 5054a8f44b9..8cc9c028391 100644 --- a/config.toml.example +++ b/config.toml.example @@ -356,6 +356,9 @@ # Print backtrace on internal compiler errors during bootstrap #backtrace-on-ice = false +# Whether to verify generated LLVM IR +#verify-llvm-ir = false + # ============================================================================= # Options for specific targets # diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 4607ca5cf9f..e81595a8c62 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -283,6 +283,10 @@ 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"); + } + let color = match env::var("RUSTC_COLOR") { Ok(s) => usize::from_str(&s).expect("RUSTC_COLOR should be an integer"), Err(_) => 0, diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index d482a0d5650..76387796d70 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -898,6 +898,10 @@ 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", format!("{}", self.verbosity)); // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful. diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 47feb8a8ab6..a0f6b786cbd 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -105,6 +105,7 @@ pub struct Config { pub rust_dist_src: bool, pub rust_codegen_backends: Vec>, pub rust_codegen_backends_dir: String, + pub rust_verify_llvm_ir: bool, pub build: Interned, pub hosts: Vec>, @@ -311,6 +312,7 @@ struct Rust { lld: Option, deny_warnings: Option, backtrace_on_ice: Option, + verify_llvm_ir: Option, } /// TOML representation of how each build target is configured. @@ -542,6 +544,7 @@ impl Config { config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from); set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings)); set(&mut config.backtrace_on_ice, rust.backtrace_on_ice); + set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir); if let Some(ref backends) = rust.codegen_backends { config.rust_codegen_backends = backends.iter()