With [WebAssembly/wasi-libc#328], we no longer want the behavior of
automatically inserting constructor calls on every command export.
The libc is now responsible for calling constructor calls in its
_start entrypoint. So it makes sense to remove support for
auto-wrapping command exports now.
At the same time, with [WebAssembly/wasi-libc#328], we are moving to
a place where users who had previously been building reactors and
getting away with not running the constructors will suddenly have a
harder time doing so.
And as in [WebAssembly/wasi-libc#329], we're anticipating Wasm modules
being used in more environments where these invariants won't be as easy
to enforce.
So instead of removing the auto-wrapping *command* export code entirely,
convert into code to code that auto-wraps *reactor* exports. And give
it logic to call __wasm_call_ctors only if it hasn't been called yet.
That way, constructors will run automatically on the first export call,
so existing users won't be suddenly broken, and so reactors in general
won't be as tricky to use.
[WebAssembly/wasi-libc#328]: https://github.com/WebAssembly/wasi-libc/pull/328
[WebAssembly/wasi-libc#338]: https://github.com/WebAssembly/wasi-libc/pull/338
[WebAssembly/wasi-libc#329]: https://github.com/WebAssembly/wasi-libc/pull/329
These days we can use llvm-object -d to disassembly the code here, making the test more readable. See lld/test/wasm/tls.s for example.