Files
wasmtime/tests/all/debug/obj.rs
Yury Delendik 42127aac4e Refactor Cache logic to include debug information (#2065)
* move caching to the CompilationArtifacts

* mv cache_config from Compiler to CompiledModule

* hash isa flags

* no cache for wasm2obj

* mv caching to wasmtime crate

* account each Compiler field when hash
2020-07-23 12:10:13 -05:00

29 lines
652 B
Rust

use anyhow::{Context as _, Result};
use std::fs::File;
use std::io::Write;
use std::path::Path;
use target_lexicon::Triple;
use wasmtime::Strategy;
use wasmtime_cli::compile_to_obj;
pub fn compile_cranelift(
wasm: &[u8],
target: Option<Triple>,
output: impl AsRef<Path>,
) -> Result<()> {
let obj = compile_to_obj(
wasm,
target.as_ref(),
Strategy::Cranelift,
false,
wasmtime::OptLevel::None,
true,
)?;
let mut file = File::create(output).context("failed to create object file")?;
file.write_all(&obj.write()?)
.context("failed to write object file")?;
Ok(())
}