Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__ATINIT__ defined in JS #5841

Closed
tjpalmer opened this issue Nov 23, 2017 · 7 comments
Closed

__ATINIT__ defined in JS #5841

tjpalmer opened this issue Nov 23, 2017 · 7 comments
Labels

Comments

@tjpalmer
Copy link

tjpalmer commented Nov 23, 2017

Would it be possible to have __ATINIT__ entries added by wasm modules themselves in some fashion?

I'm trying to make a common js environment for somewhat arbitrary wasm modules, and this is one of the compatibility problems I've found.

@kripken
Copy link
Member

kripken commented Nov 27, 2017

A wasm module might be able to use the wasm start method, that code will run as the module is instantiated - is that good enough for your use case?

Otherwise, if you need a more C-like environment, there currently isn't a way to do that - there is atexit for adding exit callbacks, but not the reverse. We could add it, though, it would be just a few lines.

@tjpalmer
Copy link
Author

Any general solution needs to be contained within the wasm module itself. If there's a common method that's the same for all emscripten-generated modules (such as the start you mention), that would be fine. Having to guess arbitrary entries to add from the js side is what I need to avoid.

Or if there is a way to guess which atinits to add, that would work, too, I guess.

@kripken
Copy link
Member

kripken commented Nov 30, 2017

Yeah, if start can work it's the best option. However, it doesn't support reentrancy (it's called before the module was fully created and received on the outside).

In a dynamic linking context, you can use __post_instantiate (docs, but dynamic linking is not stable).

@tjpalmer
Copy link
Author

tjpalmer commented Dec 1, 2017

Is it possible to modify emscripten to put the atinit registrations there, then? Any pointers if I or others would have a chance to contribute in the regard? I can't make promises, but I might be interested, if it seems doable, and if you'd be willing to take a contribution in this regard.

@kripken
Copy link
Member

kripken commented Dec 5, 2017

__post_instantiate is meant for dynamic linking, though, and we don't emit dynamic libraries by default.

Overall, a lot of this is up in the air, see e.g. WebAssembly/tool-conventions#25 for a discussion. Sorry this isn't in clearer shape yet.

@tjpalmer
Copy link
Author

tjpalmer commented Dec 5, 2017

Thanks for the feedback and the link. That's interesting reading.

@stale
Copy link

stale bot commented Sep 19, 2019

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Sep 19, 2019
@stale stale bot closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants