[PATCH] D40559: Run Wasm entrypoint on load

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 13:54:18 PST 2017


sunfish added a comment.

Thinking about this issue, I find myself going back to main. Besides asm.js/etc. compatibility, is there a reason we don't want to call main from the wasm start function, along with all the static constructors? Doing so would be pretty tidy from an ABI perspective.

main having a return value doesn't seem to be it, because musl (and all others) handle this by passing main's return value to a call to exit.

Is it needing to return to the browser event loop between the static constructors and main? However, it seems like in web contexts, modules often wouldn't have a normal main, but would either be libraries that just exist to be called from other code, or would integrate with an event loop <https://kripken.github.io/emscripten-site/docs/porting/emscripten-runtime-environment.html#implementing-an-asynchronous-main-loop-in-c-c>.

Is it to have more control over C++ static constructor order? I haven't looked at this closely, but it seems like the C++ rules have enough wiggle room. Wasm loaders should do the right thing with an acyclic dependency graph, and if it's cyclic, C++ doesn't seem to have anything to help.

Are there other issues?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D40559





More information about the llvm-commits mailing list