emscripten-core / emscripten-core/emscripten
PURE_WASI option
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
In #9479 it was mentioned that `PURE_WASI` might be eventually implemented in Emscripten, to enable targeting WASI. This was a year ago. I wonder what is the current status. Is it still under consideration?
To give you some context, I ported LLVM's `llc` tool to WASI. I tried `wasi-sdk` first but ran into multiple issues, like the lack of atomics in the shipped C++ library, so I switched to Emscripten.
I implemented a subset of syscalls `llc` depends on. Since my library goes first in the linker invocation, this alternative syscall implementation displaces the Emscripten's one.
So I have my problem solved, but I wonder if there's any interest to have this code in Emscripten to jumpstart `PURE_WASI` mode.
Note: in the linked issue it was mentioned that Emscripten might eventually adopt a subset of WASI in the regular mode when it doesn't lead to regressions (e.g: UNIX permissions not exposed). The problem here is that WASI filesystem model does not assume the whole filesystem to be exposed. You get a set of "mapped" directories available via pre-opened file descriptors. When accessing a file by path, one has to find the matching pre-opened directory, convert the path to a one relative to that directory and pass the directory descriptor and a relative path to WASI call.
So in order to do anything with the filesystem in WASI you need this mapping logic. It is completely unnecessary when targeting non-WASI mode. Therefore I doubt if Emscripten "regular" mode could adopt much from WASI.
Contributor guide
Assessment
This issue has not been assessed yet.