Remove the wasmtime wasm2obj command (#3301)
* Remove the `wasmtime wasm2obj` command This commit removes the `wasm2obj` subcommand of the `wasmtime` CLI. This subcommand has a very long history and dates back quite far. While it's existed, however, it's never been documented in terms of the output it's produced. AFAIK it's only ever been used for debugging to see the machine code output of Wasmtime on some modules. With recent changes to the module serialization output the output of `wasmtime compile`, the `*.cwasm` file, is now a native ELF file which can be fed to standard tools like `objdump`. Consequently I dont think there's any remaining need to keep `wasm2obj` around itself, so this commit removes the subcommand. * More code to delete * Try to fix debuginfo tests
This commit is contained in:
@@ -3,25 +3,24 @@ 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;
|
||||
use wasmtime::{Config, Engine, Module};
|
||||
|
||||
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 config = Config::new();
|
||||
config.debug_info(true);
|
||||
if let Some(target) = target {
|
||||
config.target(&target.to_string())?;
|
||||
}
|
||||
let engine = Engine::new(&config)?;
|
||||
let module = Module::new(&engine, wasm)?;
|
||||
let bytes = module.serialize()?;
|
||||
|
||||
let mut file = File::create(output).context("failed to create object file")?;
|
||||
file.write_all(&obj)
|
||||
file.write_all(&bytes)
|
||||
.context("failed to write object file")?;
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user