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

How hard would module initalizations / ctors be? #321

Open
daboross opened this issue Jan 29, 2019 · 2 comments
Open

How hard would module initalizations / ctors be? #321

daboross opened this issue Jan 29, 2019 · 2 comments

Comments

@daboross
Copy link
Contributor

daboross commented Jan 29, 2019

I've recently been interested in using some libraries, mainly typetag, which depend on rust-ctor to function.

rust-ctor uses link sections on Windows, Mac and Linux to allow functions to run main. Any crate can add these functions, and then they'll all be run without needing for central configuration.

If you could estimate, would it be possible to add support for this to stdweb?

Asking here rather than in rust-ctor since I'm 95% sure this needs support from cargo-web. If there's an existing way to write static constructors in wasm32-unknown-unknown, though, my apologies. Still, any solution would be good.

@koute
Copy link
Owner

koute commented Jan 29, 2019

I don't think wasm32-unknown-unknown can do this out-of-box. It would be possible to add it relatively easily, although, yes, it would require support from cargo-web.

It would be a good idea to ask the wasm-bindgen folks about this though, as I'd prefer to pick a common approach which will work across the whole ecosystem both with cargo-web and with wasm-bindgen.

@daboross
Copy link
Contributor Author

Alright, that makes sense. Glad I didn't miss something obvious in the rustc documentation!

I've opened rustwasm/wasm-bindgen#1216 to continue the discussion and include wasm-bindgen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants