My main motivation here is using typetag, which depends 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 central configuration. The problem is that this depends on Windows/Mac/Linux specific link sections, and there is no equivalent for wasm32.
I'm opening this issue for discussion of static constructors (also called global or module constructors) and wasm-bindgen. . My ideal resolution would be adding support for something to wasm-bindgen, and then rust-ctor could use that support and crates like typetag would simply work.
I opened stdweb#321 earlier for the same issue, but @koute mentioned that it might be a good idea to coordinate how this is done across the ecosystem rather than having stdweb and wasm-bindgen implement separate measures.
Arbitrary discussions I've found about ctors and WASM which may or may not be relevant:
I don't have a concrete proposal, mostly just opening this up for discussion. Also, if anyone knows any prior work on ctors+rust+wasm that could be linked, I'd greatly appreciate it!
My main motivation here is using typetag, which depends 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 central configuration. The problem is that this depends on Windows/Mac/Linux specific link sections, and there is no equivalent for wasm32.I'm opening this issue for discussion of static constructors (also called global or module constructors) and wasm-bindgen. . My ideal resolution would be adding support for something to
wasm-bindgen, and then rust-ctor could use that support and crates like typetag would simply work.I opened stdweb#321 earlier for the same issue, but @koute mentioned that it might be a good idea to coordinate how this is done across the ecosystem rather than having stdweb and wasm-bindgen implement separate measures.
Arbitrary discussions I've found about ctors and WASM which may or may not be relevant:
wasm-ctor-evalpre-executes a list of functions meant as static constructors.I don't have a concrete proposal, mostly just opening this up for discussion. Also, if anyone knows any prior work on ctors+rust+wasm that could be linked, I'd greatly appreciate it!