[PATCH] D41375: [WebAssembly] Add support for writing out init functions in linking section
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 03:23:09 PST 2017
ncw accepted this revision.
ncw added a comment.
This revision is now accepted and ready to land.
It's a start!
For full support, I guess we're going to change things as follows?
1. Scrap the `--entry` and `--no-entry` arguments, entrypoints are now specified via llvm global ctors instead.
2. When not relocatable, synthesise a function that calls the InitFuncs
3. Add a new argument `--start-entry` / `--export-entry=NAME` which determines whether the synthesised function is added as the start func or exported by name. (These are exclusive choices, the last-specified of `--start-entry` and `--export-entry` wins). The default could be either `--start-entry` or `--export-entry=_start`, I don't particularly mind.
Alternatively for (1), we could retain `--entry` / `--no-entry`, and simply have them specify a function that will be added to the very end of the InitFuncs. I suppose the use-case would be to maybe specify some sort of `void _start_main() { exit(main()); }` function? We can certainly provide a `_start_main` symbol like that in Musl, and allow users to choose whether or not main will be invoked by passing `--entry=_start_main` if they want it (not by default). Or we could be "clever" and see if the user has actually provided a function called "main", and change the default accordingly!
I've updated my Musl fork to expect these semantics, by changing it to do libc initialisation using a ctor function at highest priority:
https://github.com/NWilson/musl/pull/1/files#diff-ee27602452b4de86f218293f457baa93
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41375
More information about the llvm-commits
mailing list