Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a toolchain-independent ABI document, and propose
_initialize
#203base: main
Are you sure you want to change the base?
Add a toolchain-independent ABI document, and propose
_initialize
#203Changes from 2 commits
19a35b8
710ec66
875879d
8e07360
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the relationship with similar functions like __wasm_call_ctors?
eg. which one to call if multiple of them are exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, and indeed, it may be too late to try to design anything, to avoid breaking existing setups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
_initialize
and_start
functions are in charge of calling__wasm_call_ctors
.I see
__wasm_call_ctors
as an llvm-internal function which is not designed to be called directly by users but instead by higher level toolchain functions like_start
and_initialize
(or other crt1-type functions).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. but there are existing conventions to call exported
__wasm_call_ctors
.eg. https://github.com/emscripten-core/emscripten/blob/bec42dac7873903d09d713963e34020c22a8bd2d/src/library_dylink.js#L846
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that is because emscripten does it own thing here and basically implements
_start
/_initialize
in JavaScript. I wouldn't worry about this case since emscripten only ever loads modules that is builds itself.. we may convert to using a more standards-based approach in the future, but for now emscripten-built wasm modules are fairly specific to emscripten.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words, the standard-based way to go is to export either
_start
or_initialize
. Exporting and directly callingmain
and/or__wasm_call_ctors
(as emscripten does) is non-standard.It would also be non-standard/undefined, for example, to call
__wasm_call_ctors
directly from user C/C++ code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, the standard thing suggested here is to ignore
__wasm_call_ctors
__post_instantiate
etc even if they are exported, and only cares_initialize
? (besides that,_start
in case of wasi)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make sense to me yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. it makes sense to me too.