Skip to content

New WebAssembly Backend

Alon Zakai edited this page Aug 28, 2016 · 3 revisions

The new WebAssembly backend in LLVM is not yet stable, but you can test it. Build with something like

EMCC_WASM_BACKEND=1 emcc -s BINARYEN=1 input.cpp [..]

The EMCC_WASM_BACKEND env var tells emscripten to use the wasm backend.

Note that when using the WebAssembly backend in this manner, you do not actually need Emscripten's asm.js backend, which means you don't need Emscripten's "fastcomp" fork of LLVM. Instead you can use "vanilla" LLVM (that is, pure upstream LLVM, with no Emscripten additions). When doing so, you do not need the EMCC_WASM_BACKEND=1 env var, as emcc will detect the lack of the asm.js backend and infer it must use the wasm backend. (However, you can still set it, and it's a little faster, since it avoids the check).