WebAssembly / WebAssembly/wasi-libc
Make errno a macro like on other platforms
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1k
- Forks
- 251
- Avg merge
- 7h 15m
- Merged PRs (30d)
- 3
Description
Currently wasi-libc makes errno a globally visible thread-local variable: https://github.com/WebAssembly/wasi-libc/blob/38f48942fabf1b59e73bca126340b219fa9a78aa/libc-bottom-half/cloudlibc/src/libc/errno/errno.c#L87
This differs from most other platforms - including underlying musl libc https://github.com/WebAssembly/wasi-libc/blob/38f48942fabf1b59e73bca126340b219fa9a78aa/libc-top-half/musl/include/errno.h#L10-L21 - that define errno as just a macro that calls an internal function.
Would it be possible to change this to align the behaviour? I know it's somewhat niche usecase, but it seems to be the only big difference that prevents linking pre-existing object files produced by clang -target wasm32-wasi with Emscripten executables (https://github.com/emscripten-core/emscripten/issues/19236) as object files depend on errno and it's not declared anywhere except wasi-libc.
Contributor guide
No contributing guide indexed for this repository
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 with libc-bottom-half/cloudlibc/src/libc/errno/errno.c and compare it with libc-top-half/musl/include/errno.h. Trace how errno is declared and referenced for the wasm32-wasi target, then verify that pre-existing clang-produced object files can link with Emscripten executables without an undeclared errno dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, wasm
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100