Table of Contents generated with DocToc
- CMake,
brew install cmake
- Python 2.7+
- One of: GCC for Linux, Xcode for MacOS, VisualStudio 2015+ for Windows
- Toolchain
- I also use
wabt
from the tools section.
-
To compile C/C++
emcc hw.c -s WASM=1 -s SIDE_MODULE=1 -o hw.wasm
emcc hw.cpp -s WASM=1 -o hw.html
em++ hw.cpp -s WASM=1 --bind --std=c++11 -o hw.js
-
To update emsdk source run
emsdk update
orgit pull&&emsdk update-tags
(for the github repo clone) -
To update emsdk used run
emsdk install sdk-1.38.24-64bit
change version to the latest (seeemsdk list
), this action will install 3 components: emscripten-1.38.24, clang-e1.38.24-64bit, node-8.9.1-64bit -
To activate emsdk run
emsdk activate sdk-1.38.24-64bit
Options emscripten
all options here settings
-Os
optimizations (O0, O1, O2, O3, Os, Oz)-g
generate wast, wasm, wasm.map-s WASM=1
with JS polyfill-s "BINARYEN_METHOD='native-wasm'"
without polyfill (default)- methods:
['native-wasm', 'interpret-s-expr', 'interpret-binary', 'interpret-asm2wasm', 'asmjs']
- methods:
-o <target>
one of<name> + '.js' || '.html' || '.bc'(default) || '.o'
-s MAIN_MODULE=1
system libraries linked in or-s SIDE_MODULE=1
without-s BINARYEN_ASYNC_COMPILATION=1
-s ONLY_MY_CODE=1
only compiles your methods, and stops Emscripten including parts of its standard library-s EXPORTED_FUNCTIONS="['_my_func','_my_2d_func']"
lists the methods we'd like to access from JavaScript. Note that these names are from the source, with a prefixed underscore.
- binaryen asm2wasm, s2wasm, wasm2asm, mir2wasm
- wabt wat2wasm, wasm2wat, wasm-objdump, wasm-interp, wat-desugar, wasm-link
- emscripten
- WasmExplorer
- webassembly.studio
- WasmCodeExplorer
- WasmFiddle
- AssemblyScript
- wasm-pack