Skip to content

Commit 56b8bc9

Browse files
authored
Don't use RUSTC_WRAPPER if it's empty. (#305)
Port bytecodealliance/rustix#565 to cap-std.
1 parent ef3493b commit 56b8bc9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ fn can_compile<T: AsRef<str>>(test: T) -> bool {
5050
let rustc = var("RUSTC").unwrap();
5151
let target = var("TARGET").unwrap();
5252

53-
let mut cmd = if let Ok(wrapper) = var("RUSTC_WRAPPER") {
53+
// Use `RUSTC_WRAPPER` if it's set, unless it's set to an empty string,
54+
// as documented [here].
55+
// [here]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads
56+
let wrapper = var("RUSTC_WRAPPER")
57+
.ok()
58+
.and_then(|w| if w.is_empty() { None } else { Some(w) });
59+
60+
let mut cmd = if let Some(wrapper) = wrapper {
5461
let mut cmd = std::process::Command::new(wrapper);
5562
// The wrapper's first argument is supposed to be the path to rustc.
5663
cmd.arg(rustc);

0 commit comments

Comments
 (0)