4 ms·
If you need really small functions, yes. emscripten is providing all the libc functions, WASM loading code and binding generators. You will probably need some o
by Orphis 8y ago
If you need really small functions, yes.
emscripten is providing all the libc functions, WASM loading code and binding generators. You will probably need some of that when porting existing libraries or applications to the web!
- e12e 8y agoWell, you generally need a libc when compiling for any platform, so that shouldn't be too special?
- steveklabnik 8y agoYou don't inherently need a libc for wasm. That is, libc is usually the API for the platform; wasm doesn't have such a thing really. Your wasm module says "hey, these are the functions I expose, and these are the functions that I am planning to call from the environment" and it's the host's job to wire that up properly. In the browser, that means when you instantiate a wasm module, you need to provide all the required functions, and then you can call the exposed functions from JS. Outside the browser, what things you can call and will be called is defined by the host. A libc can be useful inside of wasm for existing C or C++ code (or whatever) that is built for another platform, so that you can more easily compile to wasm as well. But it's an option, not required.
- e12e 8y agoWell, I meant that if you want to cross compile general code, you might want malloc, printf etc... I'm not sure the primary appeal of wasm is treating it as a low level target (even if that is possible and sometimes useful).
- steveklabnik 8y agoYou can get that stuff without a libc, if you’re not literally compiling C or C++. If you are, you’re right, though.
- Orphis 8y agoYou don't necessarily need it. You could have some math focused code you want to call from JS.