The support for WebAssembly (abbreviated Wasm) is a critical part of the VGG engine. Due to performance and cross-platform support considerations, the VGG engine is written in C++. It could be compiled into WebAssembly, so that we are able to run it in browsers. More importantly, it also supports user-generated Wasm files to be plugged into the designs.
WebAssembly is an executable binary format for a stack-based virtual machine.
There have been plenty of previous work, including blog posts, papers, books, etc, that help us understand the WebAssembly format. However, few of them focus on the compiling process of C++ to WebAssembly.
In this post, we share the process of using Emscripten, a de-facto compiler toolchain for WebAssembly, to compile C++ code into WebAssembly. Hope you enjoy it!