[UPDATE] This patch
- lowers @llvm.global_dtors by adding @llvm.global_ctors functions which register the destructors with __cxa_atexit.
- impements @llvm.global_ctors with wasm start functions and linker metadata
See here for more background.
Differential D40759
[WebAssembly] Implement @llvm.global_ctors and @llvm.global_dtors sunfish on Dec 1 2017, 5:09 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions Updated patch:
Comment Actions How would you feel about landing a simplified version of this change that doesn't use the start section (i.e. always put start functions in the metadata)? Seems a little strange to special case the single start function. Also, I like the idea of letting the linker decide if/when to switch to using the start section (for now anyway). Comment Actions I'd like to land this soon if possible (sans the start section if possible) so I start working on the lld side. Comment Actions Omitting the start section part for now is ok with me. It should be sufficient to just remove the Priority == UINT16_MAX special cases. I'm also adding comments for a few minor issues in the patch that I thought of. The COMDAT thing would be nice to do now so that we don't have to coordinate adding it in the future. I won't be able to land anything this week, so I'm ok if you want to land this without the start section parts right now.
Comment Actions I've implemented the Musl side of this change. It was pretty simple really, I've just added the following to crt1.o, which is pulled in by the default link-line: extern void __init_libc(char **envp, char *pn); __attribute__((constructor(1))) void __libc_ctor() { __init_libc((char**)&__wasm_init_data.envp0, (char*)__wasm_init_data.argv0); } It sounds like Sam is working on the LLD-side of this change, to actually use the init-data section to synthesise an entrypoint. I look forward to testing with it!
Comment Actions I landed a modified version of this change in rL320774. I assume its OK to close this now. |