Skip to content

Commit

Permalink
Windows: disable more tests due to -lunwind issue, fix include paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Jan 3, 2023
1 parent 731a0e0 commit d166bf8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
16 changes: 12 additions & 4 deletions lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ fn run_c_compile(
output_name: &Path,
target: &Triple,
debug: bool,
include_dirs: &[PathBuf],
) -> anyhow::Result<()> {
#[cfg(not(windows))]
let c_compiler = "cc";
Expand All @@ -815,6 +816,11 @@ fn run_c_compile(
.arg("-I")
.arg(utils::get_wasmer_include_directory()?);

for i in include_dirs {
command.arg("-I");
command.arg(normalize_path(&i.display().to_string()));
}

// On some compiler -target isn't implemented
if *target != Triple::host() {
command = command.arg("-target").arg(format!("{}", target));
Expand Down Expand Up @@ -1128,6 +1134,10 @@ fn link_exe_from_dir(
})
.collect::<Vec<_>>();

let mut include_dirs = include_dirs;
include_dirs.sort();
include_dirs.dedup();

// On Windows, cross-compilation to Windows itself with zig does not work due
// to libunwind and libstdc++ not compiling, so we fake this special case of cross-compilation
// by falling back to the system compilation + system linker
Expand All @@ -1140,10 +1150,11 @@ fn link_exe_from_dir(
&directory.join("wasmer_main.o"),
&cross_compilation.target,
debug,
&include_dirs,
)
.map_err(|e| {
anyhow::anyhow!(
"could not write wasmer_main.c in dir {}: {e}",
"could not run c compile of wasmer_main.c in dir {}: {e}",
directory.display()
)
})?;
Expand Down Expand Up @@ -1209,9 +1220,6 @@ fn link_exe_from_dir(
#[cfg(target_os = "windows")]
cmd.arg("-lc");

let mut include_dirs = include_dirs;
include_dirs.sort();
include_dirs.dedup();
for include_dir in include_dirs {
cmd.arg("-I");
cmd.arg(normalize_path(&format!("{}", include_dir.display())));
Expand Down
11 changes: 7 additions & 4 deletions lib/cli/src/commands/create_obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ impl CreateObj {
));
}

eprintln!(
"✔ Object compiled successfully to `{}`",
self.output.canonicalize().unwrap().display()
);
let output_file = self.output.canonicalize().unwrap().display().to_string();
let output_file = output_file
.strip_prefix(r"\\?\")
.unwrap_or(&output_file)
.to_string();

eprintln!("✔ Object compiled successfully to `{output_file}`");

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/cli/tests/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ fn create_exe_works_with_file() -> anyhow::Result<()> {
Ok(())
}

#[cfg(not(target_os = "windows"))]
#[test]
fn create_exe_serialized_works() -> anyhow::Result<()> {
let temp_dir = tempfile::tempdir()?;
Expand Down

0 comments on commit d166bf8

Please sign in to comment.