create-exe: Prefer libwasmer-headless when cross-compiling

This commit is contained in:
Manos Pitsidianakis
2022-08-12 17:32:54 +03:00
parent 331f42362f
commit 70f30e4458

View File

@@ -220,9 +220,21 @@ impl CreateExe {
} else {
"lib/libwasmer.a"
};
let libwasmer_headless_path = if self
.target_triple
.clone()
.unwrap_or(Triple::host())
.operating_system
== wasmer_types::OperatingSystem::Windows
{
"lib/wasmer.lib"
} else {
"lib/libwasmer-headless.a"
};
let filename = if let Some(local_tarball) = cross_subc.tarball {
let files = untar(local_tarball)?;
files.into_iter().find(|f| f.contains(libwasmer_path)).ok_or_else(|| {
files.clone().into_iter().find(|f| f.contains(libwasmer_headless_path)).or_else(||
files.into_iter().find(|f| f.contains(libwasmer_path))).ok_or_else(|| {
anyhow!("Could not find libwasmer for {} target in the provided tarball path.", target)})?
} else {
#[cfg(feature = "http")]
@@ -230,7 +242,8 @@ impl CreateExe {
let release = http_fetch::get_latest_release()?;
let tarball = http_fetch::download_release(release, target.clone())?;
let files = untar(tarball)?;
files.into_iter().find(|f| f.contains(libwasmer_path)).ok_or_else(|| {
files.clone().into_iter().find(|f| f.contains(libwasmer_headless_path)).or_else(||
files.into_iter().find(|f| f.contains(libwasmer_path))).ok_or_else(|| {
anyhow!("Could not find libwasmer for {} target in the fetched release from Github: you can download it manually and specify its path with the --cross-compilation-library-path LIBRARY_PATH flag.", target)})?
}
#[cfg(not(feature = "http"))]
@@ -456,6 +469,10 @@ impl CreateExe {
let mut cmd = Command::new(zig_binary_path);
let mut cmd_mut: &mut Command = cmd
.arg("cc")
.arg("-w")
.arg("-fgnu-inline-asm")
.arg("-fsanitize=undefined")
.arg("-fsanitize-trap=undefined")
.arg("-target")
.arg(&zig_triple)
.arg(&format!("-L{}", libwasmer_path.display()))