Stream: wit-bindgen

Topic: (e)println in runtime/main.rs


view this post on Zulip Scott Waye (Feb 09 2025 at 20:17):

How do I get output from this file to appear in the console, it seems to just be swallowed up somewhere?

view this post on Zulip Ramon Klass (Feb 10 2025 at 12:53):

on wasm32-unknown-unknown, println! is a noop, you have to import JS console and call console.log, there are many crates that solve the problem in different ways, for example here's a crate that provides a custom println! macro https://github.com/DeMille/wasm-glue

Get println! & panics to work in WebAssembly. Contribute to DeMille/wasm-glue development by creating an account on GitHub.

view this post on Zulip Scott Waye (Feb 10 2025 at 16:00):

I didn't realise main.rs was compiled to wasm, I thought it was a host that orchestrated the runtime testing (creating the target language projects, compiling those to wasm, and running those)

view this post on Zulip Alex Crichton (Feb 10 2025 at 16:23):

I think stderr may be swallowed by default

A language binding generator for WebAssembly interface types - bytecodealliance/wit-bindgen

view this post on Zulip Alex Crichton (Feb 10 2025 at 16:23):

but if you add inherit_stderr there I think it should work?

view this post on Zulip Scott Waye (Feb 10 2025 at 22:19):

Its the rust I'm trying to instrument, e.g. putting a println in run_test_from_dir

view this post on Zulip Alex Crichton (Feb 10 2025 at 22:21):

oh for that you might need to pass --nocapture to cargo test


Last updated: Feb 28 2025 at 02:27 UTC