Migrating code to object (from faerie) (#1848)
* Using the "object" library everywhere in wasmtime. * scroll_derive
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::{init_file_per_thread_logger, pick_compilation_strategy, CommonOption
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
@@ -75,13 +76,13 @@ impl WasmToObjCommand {
|
||||
self.common.enable_simd,
|
||||
self.common.opt_level(),
|
||||
self.common.debug_info,
|
||||
self.output.clone(),
|
||||
&cache_config,
|
||||
)?;
|
||||
|
||||
// FIXME: Make the format a parameter.
|
||||
let file = File::create(Path::new(&self.output)).context("failed to create object file")?;
|
||||
obj.write(file).context("failed to write object file")?;
|
||||
let mut file =
|
||||
File::create(Path::new(&self.output)).context("failed to create object file")?;
|
||||
file.write_all(&obj.write()?)
|
||||
.context("failed to write object file")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use anyhow::{anyhow, bail, Context as _, Result};
|
||||
use faerie::Artifact;
|
||||
use object::write::Object;
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime::Strategy;
|
||||
use wasmtime_debug::{emit_dwarf, read_debuginfo, write_debugsections};
|
||||
@@ -21,9 +21,8 @@ pub fn compile_to_obj(
|
||||
enable_simd: bool,
|
||||
opt_level: wasmtime::OptLevel,
|
||||
debug_info: bool,
|
||||
artifact_name: String,
|
||||
cache_config: &CacheConfig,
|
||||
) -> Result<Artifact> {
|
||||
) -> Result<Object> {
|
||||
let isa_builder = match target {
|
||||
Some(target) => native::lookup(target.clone())?,
|
||||
None => native::builder(),
|
||||
@@ -51,7 +50,7 @@ pub fn compile_to_obj(
|
||||
|
||||
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
|
||||
|
||||
let mut obj = Artifact::new(isa.triple().clone(), artifact_name);
|
||||
let mut obj = Object::new(isa.triple().binary_format, isa.triple().architecture);
|
||||
|
||||
// TODO: Expose the tunables as command-line flags.
|
||||
let mut tunables = Tunables::default();
|
||||
|
||||
Reference in New Issue
Block a user