Open netolcc06 opened 7 months ago
Technically, in C/C++, you should only call the main
function once, so you would need to re-instantiate the module for each call to main. If you want to call a function more than once per instantiation I would create a C function with a different name. Then you could have the function take just a simple string instead of the argc, argv pair which (as you have seen) is non-trivial to pass from JS.
Having said that there are two well supported ways to pass arguments to main.
-sINVOKE_RUN=0
and then call .callMain([foo, bar])
on the instance.-sINVOKE_RUN=0
and pass the arguments
as a property on the incoming module API object:m({'arguments': [foo, bar]).then((instance) => {
// At this point main has already been run for you
})
Hello,
I am trying to build a wasm version of the cvc5 application using Emscripten 3.1.18. I have two main objectives:
Currently I am trying to export the main function only, but I am having issues to call it implicitly passing arguments to the Module or calling cwrap/ccall. The flags I used:
-s MODULARIZE -s EXPORTED_RUNTIME_METHODS=ccall,cwrap -s ENVIRONMENT=node -s EXPORTED_FUNCTIONS=_main -s INVOKE_RUN=1 -s EXIT_RUNTIME=0 -s INCOMING_MODULE_JS_API=arguments'
For comparison purposes, if I generate a html page without the
-s MODULARIZE
, I can see that the input I am passing to the page is being used by theget_char
function and the application works as intended. For instance, in the end you can see the sat/unsat result for the operation (check-sat).However, I couldn't make it to work with the Node version. Things I've tried:
index.js
cvc5.js
or directly in the get_char
In both cases I get the exception
EAGAIN: resource temporarily unavailable, read
which is thrown and caught at theget_char
function. Program still exits with 0.ccall
andcwrap
function, which leads me to have the same exception being thrown (for the ccall it throws another exception in the end: RuntimeError: memory access out of bounds):I also tried:
With that said, my questions are:
ccall
/cwrap
)?