So I am under the suspicion that one, some or all of
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
is breaking WASM if you optimize with either of these settings: --snip-rust-fmt-code--snip-rust-panicking-code
I'm pretty sure fmt and panicking code should be safe to strip out, if you don't want it in a production release.
So the problem is, how can I build a minimal WASM example that uses these structs (so they don't get optimized away), and then test it, so that I can identify the culprit and later report it?
What do you mean by "breaking"? Can you show us a crash message or explain what you are seeing?
If stripping out the machinery for panicking and formatting causes your code to crash, there's a good chance that's because it's being used by your code. Can you get some sort of backtrace to see where it's being triggered?
the error is in the JS console, that says, unreachable code.
I'm in a rush right now, but if you're curious, here is a mostly minimal example: https://github.com/Arifd/miniquad_async
You need to put the generated wasm file in the same folder as this index.html:
wasm_snip replaces snipped code with unreachable, so if you hit this error with wasm_snip, but not without it, this means that you have some calls to fmt in your compiled code. I'm not sure why snipping panics triggers this too, however, since hitting the panic would result in an error, too.
Hi @bjorn3, if you run the Miniquad library without the async modification you can wasm-snip without problem. As such, do you still believe that this is where the problem lies?
I locally built it. After running wasm-snip the way you mentioned I looked for mentions of fmt in the disassembly created by wabt's wasm-objdump. This is what I found: