[PATCH] D135903: [wasm-ld] Add support for calling constructors in reactors.

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 14:24:18 PDT 2022


sunfish added a comment.

In D135903#3856577 <https://reviews.llvm.org/D135903#3856577>, @sbc100 wrote:

> Aren't reactors supposed to define an `_initialize` function that takes care of this?

Yes, but there are two considerations. One, not everyone is calling `_initialize` today, because in some situations today things work without it, however with the change to make `malloc` have a constructor, that will change. The other is that I'm anticipating use cases, such as loading a wasm module in JS, where `_initialize` might not be automatically called, and developers won't know to manually call it.

> Perhaps the idea is to make the reactor model work even for users that don't link against `crt1_reactor.o`?

Yep. It'll be a transition, but that's one of the things this will enable.

> In that case could we instead create a default `_initialize` function here and avoid the wrappers completely?

I don't think we can avoid the wrappers, if there are constructors. The wasm start function is too early for user constructors, because it's limited in what it can do. As I mentioned above, I want to avoid the requirement that `_initialize` be called explicitly, so wrappers seem like the only option.

One way we eventually can avoid the wrappers is to eliminate all the constructors, such as by writing a malloc which doesn't need them, and making other changes, and encouraging users to avoid static constructors. That is a longer-term goal though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135903/new/

https://reviews.llvm.org/D135903



More information about the llvm-commits mailing list