[PATCH] D40559: Run Wasm entrypoint on load

Derek Schuff via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 14:45:00 PST 2017


dschuff added a comment.

tl;dr: I think I agree with @sunfish

More specifically, if I were starting from scratch, I'd want:

1. Wire up `--entry` in the linker like this (although I might not give it a default; instead make the absence of the flag mean "don't make a start section").
2. In my hypothetical non-emscripten C toolchain, use a `crt1.o` or similar file with a `_start()` function that runs the constructors, calls `main()`, and exits with its result, just like conventional `_start()` functions do today (e.g. musl's `__libc_start_main`). This would work with both web and non-web use cases.
3. For use cases which want to have no `main,` or return to the event loop after constructors, or call the constructors and/or main explicitly, there are lots of options. A toolchain (e.g. emscripten) could use a different crt file (possibly optionally based on a flag), or use `-nostartfiles`, or just make some `libstartup.a` that's linked by default by clang, that a toolchain could replace or cause not to be linked.
4. Non-C toolchains would the also be able to control their startup by using lld's `--entry` flag or not, and they'd have their own standard library startup and language-defined entry point.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D40559





More information about the llvm-commits mailing list