Skip to content
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 handles stdout and stderr (at last). #518

Merged
merged 1 commit into from
Jun 12, 2023
Merged

Conversation

charlielye
Copy link
Contributor

@charlielye charlielye commented Jun 9, 2023

Description

I'm not sure if it was a restriction of WASI-12 (maybe something around static initialisation), or if I just never expended the small amount of effort, but our WASM code has never been able to handle writing to stdout/stderr. It's basically why we had logstr.

This PR stubs the writes to stdout/stderr in the C++ code, such that the text is then forwarded to our logstr import.
This means that both bb.js and circuits benefit without needing to writing their own host imports.

An alternative would be to get rid of logstr, but its a simpler function that already exists, and saves us writing some fd_write imports in our TS code.

Bit of side note, I'll mention it here, but one caveat to this kind of wasi stubbing, is that we will need to rethink things a bit if we choose to run the WASM in a full WASI runtime. It's not an issue when we run tests in wasmtime, because we dont link in the "wasi" module where these stubs exist.

Eventually we maybe able to use something like wasmer in the browser to provide a full WASI runtime with threading. Word on the street is that they recently introduced pthread support. We would need to make sure we can also provide our get_data/set_data functions for handling memory swapping.

image

@charlielye charlielye requested review from ludamad and codygunton June 9, 2023 11:49
@charlielye charlielye merged commit cee3e9c into master Jun 12, 2023
@charlielye charlielye deleted the cl/wasm_stdout_stderr branch June 12, 2023 17:03
ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 22, 2023
ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants