rust-ctor icon indicating copy to clipboard operation
rust-ctor copied to clipboard

Support #[ctor] on wasm target

Open dtolnay opened this issue 5 years ago • 4 comments

I don't know for sure that this is possible, but it seems likely because C++ compiled to wasm would need to support static initializers somehow.

I would love to use this for typetag -- see https://github.com/dtolnay/typetag/issues/8 for a failing repro that shows ctor functions not being invoked.

@cwhakes may be able to help with the implementation or testing.

dtolnay avatar Apr 08 '19 14:04 dtolnay

Ah, seems to be blocked on https://github.com/rustwasm/wasm-bindgen/issues/1216. If you prefer, feel free to close for now and I can follow up later when the necessary functionality has landed in wasm-bindgen.

dtolnay avatar Apr 08 '19 14:04 dtolnay

I'll leave this one open for now as a tracking issue. Thanks for filing it.

mmastrac avatar Apr 12 '19 21:04 mmastrac

I'm working on landing support for this in rustc, then wasm-bindgen, then I'd be happy to submit a PR to rust-ctor.

https://github.com/rust-lang/rust/issues/82371

chinedufn avatar Feb 21 '21 14:02 chinedufn

Sorry. I am no longer working on rust-ctor support. Going to explore a different approach instead -> https://github.com/rust-lang/rust/issues/82371#issuecomment-782907947

chinedufn avatar Feb 21 '21 19:02 chinedufn

Closing as I would no longer plan to use this in the typetag crate, which was the original motivation.

dtolnay avatar Jan 16 '23 00:01 dtolnay