Hacker News new | past | comments | ask | show | jobs | submit login

My first thought after reading the problem was "WASM?" and I was glad to see a detailed writeup in the same.

Have a question: Isn't the wasm file compiled by rust already a binary? Why do we need to compile it first and then run it in the Go code?

Thanks!




It is a binary, a WASM binary. However, your CPU can't execute WASM binaries. That's why you would either have to use an interpreter to execute them (which would be slow), or compile the WASM code into native machine code for your CPU first. Then you can run that machine code directly.

The wazero library supports both of those options AFAIK.


Thanks.

> CPU can't execute WASM binaries

How was OP able to pipe the output of echo directly to the wasm binary initially?


I think they probably registered a WASM interpreter like wasmtime to automatically run any .wasm files. You can do that using binfmt_misc on Linux.


Yeah, my dev box has a binfmt_misc interpreter for .wasm files set to wasmtime. It's pretty neat!


Writing / edition error? This is before the article notes that:

> However this still depends on the program being compiled for your native OS and distribution as well as present in a folder in your $PATH.

Though it’s also possibly that the author has a wasm interpreter registered (or the wasm file has a shebang for one).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: