pub trait CompilerBuilder:
Send
+ Sync
+ Debug {
// Required methods
fn target(&mut self, target: Triple) -> Result<()>;
fn triple(&self) -> &Triple;
fn set(&mut self, name: &str, val: &str) -> Result<()>;
fn enable(&mut self, name: &str) -> Result<()>;
fn settings(&self) -> Vec<Setting>;
fn enable_incremental_compilation(
&mut self,
cache_store: Arc<dyn CacheStore>,
) -> Result<()>;
fn set_tunables(&mut self, tunables: Tunables) -> Result<()>;
fn build(&self) -> Result<Box<dyn Compiler>>;
// Provided methods
fn clif_dir(&mut self, _path: &Path) -> Result<()> { ... }
fn wmemcheck(&mut self, _enable: bool) { ... }
}
Expand description
Abstract trait representing the ability to create a Compiler
below.
This is used in Wasmtime to separate compiler implementations, currently mostly used to separate Cranelift from Wasmtime itself.
Required Methods§
sourcefn target(&mut self, target: Triple) -> Result<()>
fn target(&mut self, target: Triple) -> Result<()>
Sets the target of compilation to the target specified.
sourcefn triple(&self) -> &Triple
fn triple(&self) -> &Triple
Returns the currently configured target triple that compilation will produce artifacts for.
sourcefn set(&mut self, name: &str, val: &str) -> Result<()>
fn set(&mut self, name: &str, val: &str) -> Result<()>
Compiler-specific method to configure various settings in the compiler itself.
This is expected to be defined per-compiler. Compilers should return errors for unknown names/values.
sourcefn enable(&mut self, name: &str) -> Result<()>
fn enable(&mut self, name: &str) -> Result<()>
Compiler-specific method for configuring settings.
Same as CompilerBuilder::set
except for enabling boolean flags.
Currently cranelift uses this to sometimes enable a family of settings.
sourcefn settings(&self) -> Vec<Setting>
fn settings(&self) -> Vec<Setting>
Returns a list of all possible settings that can be configured with
CompilerBuilder::set
and CompilerBuilder::enable
.
sourcefn enable_incremental_compilation(
&mut self,
cache_store: Arc<dyn CacheStore>,
) -> Result<()>
fn enable_incremental_compilation( &mut self, cache_store: Arc<dyn CacheStore>, ) -> Result<()>
Enables Cranelift’s incremental compilation cache, using the given CacheStore
implementation.
This will return an error if the compiler does not support incremental compilation.
sourcefn set_tunables(&mut self, tunables: Tunables) -> Result<()>
fn set_tunables(&mut self, tunables: Tunables) -> Result<()>
Set the tunables for this compiler.