Does this Hello-World WASM Rust Example Build for You?

Hello, I'm looking at Rust's ability to target WebAssembly. I tried the tutorial here for a "Hello World":

"Compiling Rust to WebAssembly: A Simple Example"

It makes a large .wasm file, but then in the wasm-gc step I get an error:

$ wasm-gc target/wasm32-unknown-unknown/release/hello.wasm
thread 'main' panicked at 'failed to parse wasm module: Error(HeapOther("I/O Error: UnexpectedEof"))', /home/ae1020/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-gc-0.1.6/src/main.rs:45:36
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Aborted (core dumped)

(Running with RUST_BACKTRACE=1 didn't offer much of a smoking gun beyond 'it was an error'.)

Previously when I'd tried building a more ambitious paint example found on GitHub, I also got a similar-looking error ("Unexpected EOF (at offset 2076395)")

Do these cases work for other people, and it's just something about my installation? Or has something changed?

I installed Rust via the curl https://sh.rustup.rs -sSf | sh method on an Ubuntu 20.04.1 virtual machine. It reports rustc as version 1.46.0.

Hi, I've retitled my post to maybe focus the question so that it's clear that I'm asking something pretty simple...

Really I'm just wondering if other people get the same outcome when trying to follow this very simple "Hello World" WASM tutorial:

"Compiling Rust to WebAssembly: A Simple Example"

I get an error on the wasm-gc step, and if I try to run the page with the un-compacted wasm I get an error in the browser on that as well.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.