Chapter 2: Understanding Emscripten
In this chapter, we will learn about Emscripten, which is a toolchain to convert C/C++ code into a WebAssembly module.
Emscripten consists of two components:
- Emscripten compiler frontend
- Emscripten SDK (emsdk)
The Clang compiler frontend compiles C/C++ code into LLVM intermediate representation (LLVM IR) and then uses the LLVM backend to convert the LLVM IR into native code. The Clang compiler is fast, uses little memory, and is compatible with GNU Compiler Collection (GCC). Emscripten is similar to Clang; the former produces a wasm binary while the latter produces a native binary. The Emscripten compiler frontend (emcc) is the compiler frontend that converts C/C++ into LLVM IR (both binary and human-readable form) and into the WebAssembly binary or asm.js, such as JavaScript.
emsdk helps manage and maintain the Emscripten toolchain components and...