3 ms·
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 r
by kretaceous 4y ago
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!
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- hmry 4y agoIt 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.
- kretaceous 4y agoThanks. > CPU can't execute WASM binaries How was OP able to pipe the output of echo directly to the wasm binary initially?
- hmry 4y agoI think they probably registered a WASM interpreter like wasmtime to automatically run any .wasm files. You can do that using binfmt_misc on Linux.
- xena 4y agoYeah, my dev box has a binfmt_misc interpreter for .wasm files set to wasmtime. It's pretty neat!
- masklinn 4y agoWriting / 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).