Function wasmer_c_api::wasm_c_api::engine::wasm_config_set_compiler
source · #[no_mangle]
pub extern "C" fn wasm_config_set_compiler(
config: &mut wasm_config_t,
compiler: wasmer_compiler_t,
)
Expand description
Updates the configuration to specify a particular compiler to use.
This is a Wasmer-specific function.
§Example
int main() {
// Create the configuration.
wasm_config_t* config = wasm_config_new();
// Use the Cranelift compiler, if available.
if (wasmer_is_compiler_available(CRANELIFT)) {
wasm_config_set_compiler(config, CRANELIFT);
}
// Or maybe LLVM?
else if (wasmer_is_compiler_available(LLVM)) {
wasm_config_set_compiler(config, LLVM);
}
// Or maybe Singlepass?
else if (wasmer_is_compiler_available(SINGLEPASS)) {
wasm_config_set_compiler(config, SINGLEPASS);
}
// OK, let's run with no particular compiler.
// Create the engine.
wasm_engine_t* engine = wasm_engine_new_with_config(config);
// Check we have an engine!
assert(engine);
// Free everything.
wasm_engine_delete(engine);
return 0;
}