wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.44k stars 789 forks source link

wasmer::EngineBuilder::engine returns a wasmer_compiler::Engine instead of wasmer::Engine #3947

Open dsherret opened 1 year ago

dsherret commented 1 year ago

I've been trying to upgrade wasmer, but have been unable to because 3.x is very slow dropping instances of modules. In order to do this fast, I apparently need to share an engine across all the instances (https://github.com/wasmerio/wasmer/pull/3378#issuecomment-1327679422).

I just tried out wasmer 3.3 and was unable to upgrade because wasmer::EngineBuilder::engine returns a wasmer_compiler::Engine instead of wasmer::Engine and is therefore incompatible with EngineRef. For example, the following code does not work:

let compiler = Cranelift::default();
let engine = EngineBuilder::new(compiler).engine();
let engineref = EngineRef::new(&engine);
//                             ^^^^^^^ expected struct `Engine`, found struct `wasmer_compiler::engine::inner::Engine`
let module = Module::new(&engineref, &wasm_bytes)?;
dsherret commented 1 year ago

I've discovered a way to do this is to do:

let engine: wasmer::Engine = engine.into();
let engine_ref = EngineRef::new(&engine);

That said, this is not very discoverable. I feel like .engine() in EngineBuilder should still return a wasmer::Engine?

stale[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.