Update debug output to debug why create-exe on Windows doesn't output anything

This commit is contained in:
Felix Schütt
2022-11-16 12:29:07 +01:00
parent f73cf54ce8
commit 493f393abc
2 changed files with 26 additions and 9 deletions

View File

@@ -550,6 +550,8 @@ impl CreateExe {
header_code_path = std::env::current_dir()?; header_code_path = std::env::current_dir()?;
} }
println!("Output result to: {}", output_path.display());
/* Compile main function */ /* Compile main function */
let compilation = { let compilation = {
let mut include_dir = libwasmer_path.clone(); let mut include_dir = libwasmer_path.clone();
@@ -565,6 +567,10 @@ impl CreateExe {
cmd.arg("--library"); cmd.arg("--library");
cmd.arg("c"); cmd.arg("c");
cmd.arg("-OReleaseSafe"); cmd.arg("-OReleaseSafe");
cmd.arg("-fstrip");
cmd.arg("-dead_strip");
cmd.arg("-dead_strip_dylibs");
cmd.arg("--verbose-cc");
cmd.arg(&format!("-femit-bin={}", output_path.display())); cmd.arg(&format!("-femit-bin={}", output_path.display()));
if !zig_triple.contains("windows") { if !zig_triple.contains("windows") {
@@ -579,6 +585,7 @@ impl CreateExe {
cmd.arg(volume_obj.clone()); cmd.arg(volume_obj.clone());
} }
println!("{:?}", cmd);
cmd.output().context("Could not execute `zig`")? cmd.output().context("Could not execute `zig`")?
}; };
if !compilation.status.success() { if !compilation.status.success() {

View File

@@ -25,7 +25,6 @@ fn test_no_start_wat_path() -> String {
#[test] #[test]
fn test_cross_compile_python_windows() -> anyhow::Result<()> { fn test_cross_compile_python_windows() -> anyhow::Result<()> {
let temp_dir = tempfile::TempDir::new()?; let temp_dir = tempfile::TempDir::new()?;
let python_wasmer_path = temp_dir.path().join("python.exe");
let targets = &[ let targets = &[
"aarch64-darwin", "aarch64-darwin",
@@ -36,6 +35,8 @@ fn test_cross_compile_python_windows() -> anyhow::Result<()> {
]; ];
for t in targets { for t in targets {
let python_wasmer_path = temp_dir.path().join(format!("{t}-python"));
let output = Command::new(get_wasmer_path()) let output = Command::new(get_wasmer_path())
.arg("create-exe") .arg("create-exe")
.arg(wasi_test_python_path()) .arg(wasi_test_python_path())
@@ -45,17 +46,26 @@ fn test_cross_compile_python_windows() -> anyhow::Result<()> {
.arg(python_wasmer_path.clone()) .arg(python_wasmer_path.clone())
.output()?; .output()?;
let stdout = std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes");
let stderr = std::str::from_utf8(&output.stderr)
.expect("stderr is not utf8! need to handle arbitrary bytes");
if !output.status.success() { if !output.status.success() {
bail!( bail!("linking failed with: stdout: {stdout}\n\nstderr: {stderr}");
"linking failed with: stdout: {}\n\nstderr: {}",
std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes"),
std::str::from_utf8(&output.stderr)
.expect("stderr is not utf8! need to handle arbitrary bytes")
);
} }
assert!(python_wasmer_path.exists()); println!("stdout: {stdout}");
println!("stderr: {stderr}");
if !python_wasmer_path.exists() {
let p = std::fs::read_dir(temp_dir.path())
.unwrap()
.filter_map(|e| Some(e.ok()?.path()))
.collect::<Vec<_>>();
println!("p: {:#?}", p);
}
} }
Ok(()) Ok(())