New WebAssembly Backend

Derek Schuff edited this page Dec 13, 2016 · 5 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 WASM=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 must 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).
  • If you build LLVM by yourself, note that WebAssembly is not built by default. You should pass -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly to cmake.