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
WASM_STANDALONE: Errno 63 (Out of stream resources) at fopen call #17167
Comments
Please bear in mind that the WASI standalone support for emscripten is fairly limited. I was looking at extending it but that worked stalled: #12704 In this case it looks like the __syscall_openat function doesn't currently support opening files using fd_open: emscripten/system/lib/standalone/standalone.c Lines 83 to 95 in af2bc43
|
Hi @sbc100, Thank you for your response. I already looked into this code snipped before, because it was linked in another issue. I was wondering why I was getting another error code and as a conclusion, I assumed that in my case, this code path is not getting executed. In some other resources I read that Emscripten uses WASI whenever possible and I assumed that opening a file would be possible. Is there any other way to open, read and write files with Emscripten or do I need to switch to WASI SDK? |
Yes, when you build without However, those binaries won't run on wasmtime since wasmtime doesn't support the emscripten syscalls. |
(BTW, you are implicitly asking for |
Hi @sbc100, I‘m currently working on a research paper with the goal to find out which source languages and compilers are the most suitable ones for targeting server side workloads in standalone WASM runtimes like wasmtime. So for me, it is not an option to switch to browsers or node. Thank you for your help so far! |
If you are only targeting the server then emscripten is likely not the right choice for you. Have you looked at wasi-sdk (https://github.com/WebAssembly/wasi-sdk)? |
Hi @sbc100, I have included WASI-SDK in my evaluation. Works fine! |
@sbc100 I just ran into this limitation too. I read about FS in the documentation, and also ensured it is initialized in the browser, and kept on wondering why the read for the Would it be possible to have |
@turbolent the easiest solution would be to stop building with The long term solution is to land #12704 |
Yes, I use #12704 look good. Is there any reason why it hasn't landed yet? I could help improve WASI support if that's something you'd be happy to accept. Maybe w2c2 could add support or the Emscripten imports, though there seem to be a lot. How stable is that interface, and is there any documentation for it? |
Even if #12704 lands, only the most simple program will contain just wasi imports/exports. Anymore more complex that you could build with wasi-sdk likely contain emscripten-specific imports, so you will be forces to implement some parts of emscripten. The emscripten ABI is relatively stable, but not set in stone and not well documented. Its more of an implementation detail. |
@sbc100 Where can I find the ABI and related documentation? Do you think it is worth it to implement it natively, or would an attempt like that rather futile based on how often it changes? |
The emscripten API between JS and wasm is not fully documented anywhere (at least not that I know of). There is some information here: https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone. And a blog post here: https://v8.dev/blog/emscripten-standalone-wasm. We do (mostly) treat this API as more of an implementation detail. However, we are aware that folks like you would like to target it, and I have been trying to simplify it over time to make the job easier. I would not say it a futile effort to track it, but be prepared for occasional changes. |
@sbc100 I saw that #12704 finally landed, nice! As for the empscripten API between JS and WASM: Has there been any further advanced in stabilizing it? How much did it change over the last year? It would be great to better understand what "occasional changes" to expect, to not make this a futile effort (it's just a side project for me). Also: Do you know of any other implementations of that API apart from the reference JS implementation in this repo? |
I don't know of any other implementations of the emscripten JS API, but I wouldn't be surprised if there was some partial implementation out there. In terms of stability I'm not sure how to quickly come up with an answer for that. I think the |
Error description:
I'm trying to build a standalone WASM module which is reading from a file by using WASI.
The compilation is done by running the following command:
The compilation works fine and succeeds without an error.
I'm using wasmtime in order to run the module:
In my working directory, there is a file 'test.txt', which only contains one line with the content "test".
Running the WASM module by using the previously mentioned command, I'm getting the following output:
Looking up the meaning of errno 63, there seems to be an issue with stream resources:
I also activated the wasmtime WASI trace logging by setting the environment variable RUST_LOG to wasi_common=trace. Running the wasmtime command now prints the following output:
This log shows that no open- or read-call was performed. There is only a fd_write-call, that prints the error message to the stdout file descriptor.
What is the reason behind this error and what can I do in order to get my example running?
Example code:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.13 (5312576)
clang version 15.0.0 (https://github.com/llvm/llvm-project 5c6ed60c517c47b25b6b25d8ac3666d0e746b0c3)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
The text was updated successfully, but these errors were encountered: