4 ms·
`zig cc` is also amazing to compile C and C++ code to WebAssembly. For standalone WebAssembly or WASI. No need to install yet another toolchain, this is just a
by jedisct1 5y ago
`zig cc` is also amazing to compile C and C++ code to WebAssembly. For standalone WebAssembly or WASI.
No need to install yet another toolchain, this is just another target Zig can compile to, out of the box.
- pjmlp 5y agoActually you can do the same with clang. Emscripten just installs a bunch of stuff to make it easier to use existing libraries. If you just want to use standard library, no need for extra stuff. https://surma.dev/things/c-to-webassembly/ https://surma.dev/things/c-to-webassembly/
- jedisct1 5y agoOnly for freestanding webassembly. In order to target WASI, you have to install the builtins (https://github.com/jedisct1/libclang_rt.builtins-wasm32.a https://github.com/jedisct1/libclang_rt.builtins-wasm32.a), as well as the WASI libc, and fiddle with `—-sysroot`. Zig can target both without having to install anything else.
- pjmlp 5y agoAssuming that you even need them. Zig packages them, naturally you don't need to install them a second time.