Building with Emscriptenlink
Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform. Emscripten can be used to compile parts of IREE to WebAssembly for execution within web browsers or other Wasm runtimes.
Statuslink
IREE's runtime can be compiled through Emscripten in some limited configurations. More of the runtime will be supported over time.
IREE's compiler can be compiled through Emscripten with local changes. More work is needed for this to be generally supported.
Prerequisiteslink
Read https://emscripten.org/docs/getting_started/downloads.html and run
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
Building IREE's runtime with Emscriptenlink
Host configurationlink
Build and install at least the compiler tools on your host machine, or install them from a binary distribution:
$ cmake -G Ninja -B ../iree-build-host/ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX=../iree-build-host/install \
.
$ cmake --build ../iree-build-host/ --target install
Target configurationlink
$ emcmake cmake -G Ninja -B ../iree-build-emscripten/ \
-DCMake_BUILD_TYPE=Release \
-DIREE_HOST_BIN_DIR=$(realpath ../iree-build-host/install/bin) \
-DIREE_BUILD_TESTS=OFF \
-DIREE_BUILD_COMPILER=OFF \
.
Build:
cmake --build ../iree-build-emscripten/ \
--target iree_samples_simple_embedding_simple_embedding_vmvx_sync
Load into a WebAssembly environmentlink
Copy the outputs from the build process (e.g. simple_embedding_vmvx_sync.js
and simple_embedding_vmvx_sync.wasm
) into your application and follow
instructions at either https://webassembly.org/getting-started/developers-guide/
or https://developer.mozilla.org/en-US/docs/WebAssembly/Loading_and_running.