Stream: wasm

Topic: References


view this post on Zulip Andrew Brown (Sep 02 2021 at 16:59):

@Alex Crichton, a question about references: if I'm writing Rust and compiling to wasm32 and I want a certain function to be added as an element in a funcref table, what is the cleanest way to do that?

view this post on Zulip Andrew Brown (Sep 02 2021 at 17:00):

@fitzgen (he/him) mentioned using the function as a function pointer in some non-dead code... any other way? An attribute of some kind?

view this post on Zulip fitzgen (he/him) (Sep 02 2021 at 17:05):

it would be cool if there were #[put_in_wasm_function_table] but I kinda suspect there isn't anything like that

view this post on Zulip Alex Crichton (Sep 02 2021 at 17:05):

@Andrew Brown there's no programmatic way to do that sort of, but all indirectly-called functions will be there. So if you return a function pointer, for example, in an exported function then that it'll be in the funcref table

view this post on Zulip Andrew Brown (Sep 02 2021 at 17:07):

The second question is how then to export the table? I think the answer is to get the --export-table flag to lld somehow--what is the best way to do that?

view this post on Zulip Alex Crichton (Sep 02 2021 at 17:18):

I think it's probably through RUSTFLAGS=-Clink-args=--export-table or something like that


Last updated: Nov 22 2024 at 17:03 UTC