You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using wasmer python to execute the tmp.wasm with wasi.
The wasm file is : tmp-wasm.txt
The python file is :
import os
from wasmer import engine, wat2wasm, Store, Module, Instance, wasi
from wasmer_compiler_cranelift import Compiler
# from wasmer_compiler_llvm import Compiler
# from wasmer_compiler_singlepass import Compiler
engine = engine.Universal(Compiler)
# Create a store, that holds the engine.
store = Store(engine)
# Let's compile the Wasm module with the Cranelift compiler.
__dir__ = os.path.dirname(os.path.realpath(__file__))
module = Module(Store(), open(__dir__ + './tmp.wasm', 'rb').read())
# Get the WASI version.
wasi_version = wasi.get_version(module, strict=True)
# Build a WASI environment for the imports.
wasi_env = wasi.StateBuilder('test-program').argument('--foo').finalize()
# Generate an `ImportObject` from the WASI environment.
import_object = wasi_env.generate_import_object(store, wasi_version)
# Now we are ready to instantiate the module.
instance = Instance(module, import_object)
# Here we go, let's start the program.
# instance.exports._start()
# Let's instantiate the Wasm module.
# instance = Instance(module)
# Let's call the `sum` exported function.
func1 = instance.exports._start
results = func1()
print(results)
Steps to reproduce
python tmp.py
Expected behavior
Print:
Hello world!
buf ptr: 0x500d88
buf: 1234
Actual behavior
Print:
Hello world!
buf ptr: 0x500d88
buf: 1234
Traceback (most recent call last):
File "wasmer-python-A5-2.py", line 38, in
results = func1()
RuntimeError: RuntimeError: WASI exited with code: 0
The text was updated successfully, but these errors were encountered:
Describe the bug
Using wasmer python to execute the tmp.wasm with wasi.
The wasm file is :
tmp-wasm.txt
The python file is :
Steps to reproduce
Expected behavior
Print:
Hello world!
buf ptr: 0x500d88
buf: 1234
Actual behavior
Print:
Hello world!
buf ptr: 0x500d88
buf: 1234
Traceback (most recent call last):
File "wasmer-python-A5-2.py", line 38, in
results = func1()
RuntimeError: RuntimeError: WASI exited with code: 0
The text was updated successfully, but these errors were encountered: