WebAssembly / WebAssembly/WASI
Separate initialization and finalization
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.8k
- Forks
- 333
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
Right now, _start initializes global state, calls main(), and then tears down global state.
This is fine for executable modules, but not for modules designed to be used as libraries.
For a library, I would like to initialize global state right after the library is loaded, and then tear down global state right before shutting the library down.
I am proposing separating the initialization part into a separate exported function (call it _init) and, similarly, splitting the finalization into a separate exported function (call it _fini).
Then _start becomes (pseudocode):
void _start() {
_init();
// set up arguments for main(), call main()
_fini();
}
but people who intend to use the module as a library have the option to call _init() and _fini() directly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the current _start implementation and tracing how it initializes global state, calls main(), and tears that state down. Define the exported _init and _fini entry points so library users can call them independently, while _start preserves the existing sequence; done means both executable and library use cases are supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100