Open
Description
I've tried to run RustPython in wasm via wasmer
and wasmtime
.
Both give me an error when trying to use this code built with --target=wasm32-wasi
, rustc 1.55.0
:
This seems to be a WASM validation error, so maybe this is a rustc
codegen issue?
Error: failed to run main module `target/wasm32-wasi/debug/semantic_plugin_python.wasm`
Caused by:
0: WebAssembly failed to compile
1: WebAssembly translation error
2: Invalid input WebAssembly code at offset 24846689: locals exceed maximum
use rustpython_vm as vm;
use rustpython_vm::{InitParameter, Interpreter, PySettings, VirtualMachine};
pub fn main() {
let mut scope = None;
let interp = vm::Interpreter::new_with_init(PySettings::default(), |vm| {
// VM_INIT_FUNCS.with(|cell| {
// for f in cell.borrow().iter() {
// f(vm)
// }
// });
// vm.add_frozen(rustpython_derive::py_freeze!(dir = "pyenv/lib/python3.9/site-packages/bs4"));
scope = Some(vm.new_scope_with_builtins());
InitParameter::Internal
});
let scope = scope.unwrap();
interp.enter(|vm| -> Result<(), Box<dyn std::error::Error>> {
// let scope = vm.new_scope_with_builtins();
let code_obj = vm
.compile(
r#"print("Hello World!")"#,
vm::compile::Mode::Exec,
"<embedded>".to_owned(),
)
.map_err(|err| vm.new_syntax_error(&err)).unwrap();
vm.run_code_obj(code_obj, scope).unwrap();
Ok(())
}).unwrap();
}