4 ms·
Can emscripten compile to JS? I thought it could only compile to WASM.
by Hasnep 4y ago
Can emscripten compile to JS? I thought it could only compile to WASM.
- jcelerier 4y agoEmscripten started as an asm.js compiler iirc ? Or even "plain" js
- azakai 4y agoYes, historically Emscripten began before asm.js, targeting pure JS. That JS backend was replaced by an asm.js backend, which was later replaced by the current wasm backend (the wasm backend in upstream LLVM). (But as already mentioned, JS is still supported today, using wasm2js.)
- leodriesch 4y agoIIRC emscripten was around before Browser support for WASM was really a thing.
- danShumway 4y agoI'm not sure which they're targeting, but early emscripten targeted asm.js, it predated WASM. I would consider asm.js to still be Javascript, it's just an optimized subset of the language. I'll concede though that if they're targeting WASM it's not technically pure Javascript, but it still feels a bit to me like splitting hairs since it's always been explained to me that WASM and the Javascript runtime under the hood have a lot of overlap.
- azakai 4y agoEmscripten can target both WebAssembly and JavaScript. The JavaScript option uses wasm2js - it compiles first to wasm, then compiles that to JS. https://github.com/WebAssembly/binaryen#wasm2js https://github.com/WebAssembly/binaryen#wasm2js The emcc flag -sWASM=0 disables the wasm final output and emits JS instead.