Add a method to share Config across machines (#2608)
With `Module::{serialize,deserialize}` it should be possible to share
wasmtime modules across machines or CPUs. Serialization, however, embeds
a hash of all configuration values, including cranelift compilation
settings. By default wasmtime's selection of the native ISA would enable
ISA flags according to CPU features available on the host, but the same
CPU features may not be available across two machines.
This commit adds a `Config::cranelift_clear_cpu_flags` method which
allows clearing the target-specific ISA flags that are automatically
inferred by default for the native CPU. Options can then be
incrementally built back up as-desired with teh `cranelift_other_flag`
method.
This commit is contained in:
@@ -385,6 +385,20 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
/// Clears native CPU flags inferred from the host.
|
||||
///
|
||||
/// By default Wasmtime will tune generated code for the host that Wasmtime
|
||||
/// itself is running on. If you're compiling on one host, however, and
|
||||
/// shipping artifacts to another host then this behavior may not be
|
||||
/// desired. This function will clear all inferred native CPU features.
|
||||
///
|
||||
/// To enable CPU features afterwards it's recommended to use the
|
||||
/// [`Config::cranelift_other_flag`] method.
|
||||
pub fn cranelift_clear_cpu_flags(&mut self) -> &mut Self {
|
||||
self.isa_flags = native::builder_without_flags();
|
||||
self
|
||||
}
|
||||
|
||||
/// Allows settings another Cranelift flag defined by a flag name and value. This allows
|
||||
/// fine-tuning of Cranelift settings.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user