diff --git a/src/codegen/sys/tests.rs b/src/codegen/sys/tests.rs index e82e376d3..3a8648f8b 100644 --- a/src/codegen/sys/tests.rs +++ b/src/codegen/sys/tests.rs @@ -317,7 +317,7 @@ fn generate_abi_rs( writeln!(w, "use std::error::Error;")?; writeln!(w, "use std::ffi::OsString;")?; writeln!(w, "use std::path::Path;")?; - writeln!(w, "use std::process::Command;")?; + writeln!(w, "use std::process::{{Command, Stdio}};")?; writeln!(w, "use std::str;")?; writeln!(w, "use tempfile::Builder;")?; writeln!(w)?; @@ -381,9 +381,11 @@ fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { let mut cmd = Command::new(pkg_config); cmd.arg("--cflags"); cmd.args(packages); + cmd.stderr(Stdio::inherit()); let out = cmd.output()?; if !out.status.success() { - return Err(format!("command {cmd:?} returned {}", out.status).into()); + let (status, stdout) = (out.status, str::from_utf8(&out.stdout)?); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); } let stdout = str::from_utf8(&out.stdout)?; Ok(shell_words::split(stdout.trim())?) @@ -502,13 +504,15 @@ fn get_c_output(name: &str) -> Result> { let cc = Compiler::new().expect("configured compiler"); cc.compile(&c_file, &exe)?; - let mut abi_cmd = Command::new(exe); - let output = abi_cmd.output()?; - if !output.status.success() { - return Err(format!("command {abi_cmd:?} failed, {output:?}").into()); + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, str::from_utf8(&out.stdout)?); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); } - Ok(String::from_utf8(output.stdout)?) + Ok(String::from_utf8(out.stdout)?) } const RUST_LAYOUTS: &[(&str, Layout)] = &["####