alexthomas1 opened issue #5260:
I have a WASM file that calls a function in the host, but the name of the label becomes env::_Z5hellov.
How do I register the binding in C++? Thank you!
bjorn3 commented on issue #5260:
You have to put the function prototype in a
extern "C" { ... }
block to disable name mangling.
alexthomas1 commented on issue #5260:
Thank you, I did that and I get
(import "env" "_Z5hellov" (func $hello__ (type 2)))
and
unknown import:
env::_Z5hellov
has not been definedwhen I put the function prototype in the extern block.
bjorn3 commented on issue #5260:
What is the exact code you used?
alexthomas1 commented on issue #5260:
I have been trying to modify the example: third_party/wasmtime/examples/hello.c, to load the binary directly (instead of using the wat representation).
`#include <stdio.h>
extern "C" {
void hello();
}int main(int argc, char **argv){
hello();
}`This is what my hello.cc looks like.
alexthomas1 edited a comment on issue #5260:
I have been trying to modify the example: third_party/wasmtime/examples/hello.c, to load the binary directly (instead of using the wat representation).
`#include <stdio.h> extern "C" { void hello(); } int main(int argc, char **argv){ hello(); }`
This is what my hello.cc looks like.
bjorn3 commented on issue #5260:
It works for me: https://godbolt.org/z/YGccKMhWY
__main_argc_argv: # @__main_argc_argv call hello i32.const 0 end_function
alexthomas1 commented on issue #5260:
On the host-side, in third_party/wasmtime/examples/hello.c, how does wasmtime know the correct symbol to use (i.e. hello)?
bjorn3 commented on issue #5260:
I think it sets hello_callback as the first import, not for the import named "hello".
alexthomas1 commented on issue #5260:
So when I have multiple imports, how does that work? Are there any examples of this?
I also still get:
unknown import:
env::_Z5hellovhas not been defined
alexthomas1 edited a comment on issue #5260:
So when I have multiple imports, how does that work? Are there any examples of this?
I also still get:
unknown import:
env::hellohas not been defined
alexcrichton closed issue #5260:
I have a WASM file that calls a function in the host, but the name of the label becomes env::_Z5hellov.
How do I register the binding in C++? Thank you!
Last updated: Nov 22 2024 at 16:03 UTC