diff --git a/build.rs b/build.rs index 5945799d2423d..0f65e2eaa59cb 100644 --- a/build.rs +++ b/build.rs @@ -196,8 +196,17 @@ fn rustc_minor_nightly() -> (u32, bool) { }; } - let rustc = otry!(env::var_os("RUSTC")); - let output = Command::new(rustc) + let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); + let mut cmd = match env::var_os("RUSTC_WRAPPER") { + Some(wrapper) if !wrapper.is_empty() => { + let mut cmd = Command::new(wrapper); + cmd.arg(rustc); + cmd + } + _ => Command::new(rustc), + }; + + let output = cmd .arg("--version") .output() .ok()