Building the Source

Source for tiny-wasm-runtime

The source can be found at:

https://github.com/twiddlingbits/tiny-wasm-runtime

The main branch contains the latest release. The dev branch is work in progress.

Tools needed

You will need these core tools:

  • NPM - package manager
  • Typescript
  • clang tool chain - for C/C++ code
  • wasm-ld - to link the .wasm files
  • wat2wasm - to compile web assembly (.wat) files of which I have a few
  • GNU make
  • git - to clone tiny-wasm-runtime source, or to clone llvm, if you want to build libc++

In addition, you might need:

  • VS Code - to use the debug launcher and build tasks
  • Parcel v2 - to bundle the examples
  • mkdocs - to build the documentation static web site
  • python - mkdocs is built with python, and you need python to run server.py in examples
  • CMake and ninja - to build llvm libc++

There is a deprecated gcc build that I used to use for testing, but now the tests are executed in wasm.

To Build the Libraries (lib-c, lib-js)

cd source
make

or on windows

cd source
mingw32-make

To Build the Examples

See examples/readme.md for more information.

To build the examples, but not bundle them.

cd examples
sh buildall.sh

To build bundles:

sh buildbundles.sh

To Build the docs

In tiny-wasm-runtime root folder:

mkdocs build

The destination of the build is found in the mkdocs.yml file (site_dir: azure/docsite/).

Usually the docs are built as part of building the static web site that hosts the docs and examples. This is accomplished using this shell script (found in examples folder):

buildazure.sh

To Build libc++ for wasm and tiny-wasm-runtime

See the instructions in the comments in the shell script source\libcxx\buildlibcxx.sh

Installing clang and wasm-ld on Windows

Here is how I installed the tools for windows:

 install  MSYS2 
   1. https://www.msys2.org/
   2. After the install completes, run UCRT64 terminal by clicking on the MSYS2 UCRT64 in the Start menu
   3. pacman -Syuu

 install gcc using MSYS2 UCRT64
   1. Use MSYS2 UCRT64 terminal (per above)
   1. pacman -S mingw-w64-ucrt-x86_64-toolchain

 install clang and wasm-ld using MSYS2 UCRT64
   2. Use MSYS2 UCRT64  (per above)
      1. pacman -S mingw-w64-ucrt-x86_64-clang
      2. pacman -S mingw-w64-x86_64-lld

update PATH env variable using the windows control panel (search for path)
   2. added C:\msys64\ucrt64\bin 
   3. added C:\msys64\mingw64\bin 
   4. added C:\msys64\usr\bin (for sh.exe used by mingw32-make)

wabt tools: can be found here https://github.com/WebAssembly/wabt/releases