While I was poking around inside wasm32-wasi
programs generated by Rust, I noticed that the incredibly simple program
#![no_main]
curiously imports "env" "main"
, which is (indirectly) called by _start
, in place of where the crate's usual main
function would be called
This behavior is pretty strange to me, I'd expect it to do one of the following:
- Create a empty
main
function (which it looks like it does, inmain.1
and__main_void
, but those ultimately call the importedmain
) - Simple do nothing where
main
would normally be called - Have a completely empty
_start
But it doesn't do any of those, and instead yields its execution path to the host environment. I guess if that import mapped to another non-wasi module's main
function, it could be used to wrap it to be called like it was wasi-compliant
Any ideas why it does this?