Stream: general

Topic: C API get_typed_func


view this post on Zulip MarkJG (May 03 2021 at 13:26):

How do I get a exported function by name? Rust's got get_typed_func, but I can't find anything similar in the C API. Most of the C examples get externs funcs by index.

view this post on Zulip Alex Crichton (May 03 2021 at 14:09):

Currently we don't have an equivalent in the C API

view this post on Zulip Alex Crichton (May 03 2021 at 14:09):

one of the main reasons is that we're not ready to commit yet to a stable ABI for functions, so there's no great way to expose this in C right now (that we know of)

view this post on Zulip MarkJG (May 03 2021 at 16:20):

Thanks for the response, it's quite alright. I've managed to work around it with wasm_module_exports, just by mapping the externtype names to extern indices. It's a glued on solution but seems to work well enough for now.

view this post on Zulip Yury Delendik (May 03 2021 at 17:02):

It is actually not a workaround. That's how you need to do it.

view this post on Zulip MarkJG (May 03 2021 at 18:58):

Hi Yury. What do you mean?

view this post on Zulip MarkJG (May 03 2021 at 18:59):

I'm not interested in the function's signature if that's what you meant.

view this post on Zulip Yury Delendik (May 03 2021 at 19:11):

In most of the cases binding by name is inefficient or tricky at runtime. The C api "suggest" that all inefficient stuff will be accomplish during initial linking and indexes are used instead of names later during runtime.

view this post on Zulip MarkJG (May 03 2021 at 19:33):

That's what I'm doing. I'm building up a map of name's to extern indices after I load the module binary.


Last updated: Dec 23 2024 at 12:05 UTC