Remove usage of CompilationStrategy from Config (#764)
* Remove usage of `CompilationStrategy` from `Config` This commit removes the public API usage of the internal `CompilationStrategy` enumeration from the `Config` type in the `wasmtime` crate. To do this the `enum` was copied locally into the crate and renamed `Strategy`. The high-level description of this change is: * The `Config::strategy` method now takes a locally-defined `Strategy` enumeration instead of an internal type. * The contents of `Strategy` are always the same, not relying on Cargo features to indicate which variants are present. This avoids unnecessary downstream `#[cfg]`. * A `lightbeam` feature was added to the `wasmtime` crate itself to lightbeam compilation support. * The `Config::strategy` method is now fallible. It returns a runtime error if support for the selected strategy wasn't compiled in. * The `Strategy` enum is listed as `#[non_exhaustive]` so we can safely add variants over time to it. This reduces the public crate dependencies of the `wasmtime` crate itself, removing the need to reach into internal crates even more! cc #708 * Fix fuzz targets * Update nightly used to build releases * Run rustfmt
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::context::layout_vmcontext;
|
||||
use crate::data_segment::{declare_data_segment, emit_data_segment};
|
||||
use crate::function::{declare_functions, emit_functions};
|
||||
use crate::table::{declare_table, emit_table};
|
||||
use anyhow::Result;
|
||||
use faerie::{Artifact, Decl, Link};
|
||||
use wasmtime_environ::isa::TargetFrontendConfig;
|
||||
use wasmtime_environ::{Compilation, DataInitializer, Module, Relocations};
|
||||
@@ -10,18 +11,16 @@ fn emit_vmcontext_init(
|
||||
obj: &mut Artifact,
|
||||
module: &Module,
|
||||
target_config: &TargetFrontendConfig,
|
||||
) -> Result<(), String> {
|
||||
) -> Result<()> {
|
||||
let (data, table_relocs) = layout_vmcontext(module, target_config);
|
||||
obj.declare_with("_vmcontext_init", Decl::data().global(), data.to_vec())
|
||||
.map_err(|err| format!("{}", err))?;
|
||||
obj.declare_with("_vmcontext_init", Decl::data().global(), data.to_vec())?;
|
||||
for reloc in table_relocs.iter() {
|
||||
let target_name = format!("_table_{}", reloc.index);
|
||||
obj.link(Link {
|
||||
from: "_vmcontext_init",
|
||||
to: &target_name,
|
||||
at: reloc.offset as u64,
|
||||
})
|
||||
.map_err(|err| format!("{}", err))?;
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -35,7 +34,7 @@ pub fn emit_module(
|
||||
relocations: &Relocations,
|
||||
data_initializers: &[DataInitializer],
|
||||
target_config: &TargetFrontendConfig,
|
||||
) -> Result<(), String> {
|
||||
) -> Result<()> {
|
||||
declare_functions(obj, module, relocations)?;
|
||||
|
||||
for (i, initializer) in data_initializers.iter().enumerate() {
|
||||
|
||||
Reference in New Issue
Block a user