-
Notifications
You must be signed in to change notification settings - Fork 199
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
Make try_init_allocator() a ctor #338
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 entire range of 0-100 I believe is reserved for system functions like this. I'm not convinced 0 is the best choice here, but its not not hard to change in the future.
In emscripten we document the priorities in order to keep track of all the order which this stuff happens: https://github.com/emscripten-core/emscripten/blob/main/system/lib/README.md?plain=1#L9-L28
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.
Practically speaking, right now whenever we add a new constructor in wasi-libc, we just grep for all the constructors in the wasi-libc tree to figure out the ordering constraints, which seems ok for now, as there aren't very many.
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 believe assigning priority
0
is a correct choice, given:try_init_allocator
itself doesn't rely on other ctors to be run beforeWe can also have a documentation somewhere to list all our ctors. I can add one in this PR if you folks think it's appropriate, though not sure where's the best place to add it.
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 think its ok to simply use grep as Dan says, I was just pointing out that it can get complicated, and that one needs to be careful when choosing the order of these things, once there is more than one.
There are also some things that might (one day) need to happen before malloc initialization (e.g. TLS setup, application of relocations in PIC code) although I don't think any of those apply yet in wasi-libc.