diff --git a/build.rs b/build.rs index cd79927..c470ba1 100644 --- a/build.rs +++ b/build.rs @@ -71,7 +71,7 @@ fn compile_probe() -> Option { fs::write(&probefile, PROBE).ok()?; // Make sure to pick up Cargo rustc configuration. - let mut cmd = if let Some(wrapper) = env::var_os("CARGO_RUSTC_WRAPPER") { + let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") { let mut cmd = Command::new(wrapper); // The wrapper's first argument is supposed to be the path to rustc. cmd.arg(rustc); @@ -89,6 +89,10 @@ fn compile_probe() -> Option { .arg(out_dir) .arg(probefile); + if let Some(target) = env::var_os("TARGET") { + cmd.arg("--target").arg(target); + } + // If Cargo wants to set RUSTFLAGS, use that. if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") { if !rustflags.is_empty() {