You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PRINTING FROM THE HOST: "before"
PRINTING FROM THE HOST: "after"
<call to wasi::fd_write: fd=1>
ABC
FOUND SIZE 2
FOUND SIZE 2
defg
75
There are a number of things going on here:
The host call, host_print prints the string using printf with a terminating new line.
clang changes calls to printf with a static string into calls to puts
wasi::fd_write is only called once; this is not a buffering issue in the runtime
writes to stdout are buffered despite new lines: notice that the host calls come before the other prints. Additionally, I've verified that it hasn't reordered the print statements in the generated Wasm.
passing in an argument large enough that about 1000 bytes are written
I spent some time looking into this, but ran into some issues and didn't want to spend too much time on this before asking for help.
I'm happy to fix this and submit a patch, but I got a bit lost in the code and print statements weren't working in all the places I'd like them to to quickly debug the issue. I'd really appreciate any pointers in the right direction you all can give!
edit:
I'm using clang source.c -Os -o wasi_example.wasm --target=wasm32-wasi -Wl,--allow-undefined -Wl,--export-all to compile in case that helps.
The text was updated successfully, but these errors were encountered:
I am just guessing, but as far as I know, in musl line-buffered (lbf = '\n') or non-buffered mode (lbf = -1) is completely depend on a type of the stdout device. So, for terminals it is enabled by default, but for other it is implementation specific and musl mainteiners recommend to explicitly set it. Then it seems that in WASI it is determined by __isatty function (here and here).
In its turn, __isatty uses __wasi_fd_fdstat_get to check that file has __WASI_FILETYPE_CHARACTER_DEVICE type. But Wasmer doesn't return this type of device. So probably the issue could be in this fact. But it is just my guess and it is difficult to answer without full source code. You can check it by debugging __wasi_fd_fdstat_get in Wasmer.
Hello!
I have some C code that I'm compiling with clang 8.0 and a sysroot compiled from master.
And here's a trace:
There are a number of things going on here:
host_print
prints the string using printf with a terminating new line.printf
with a static string into calls toputs
The following things make it work correctly:
fflush(stdout)
setbuf(stdout, NULL);
I spent some time looking into this, but ran into some issues and didn't want to spend too much time on this before asking for help.
I'm happy to fix this and submit a patch, but I got a bit lost in the code and print statements weren't working in all the places I'd like them to to quickly debug the issue. I'd really appreciate any pointers in the right direction you all can give!
edit:
I'm using
clang source.c -Os -o wasi_example.wasm --target=wasm32-wasi -Wl,--allow-undefined -Wl,--export-all
to compile in case that helps.The text was updated successfully, but these errors were encountered: