Understanding various levels of optimizations
C/C++ programs are compiled and converted into native code via Clang or the GCC compiler. Clang or the GCC compiler converts the C/C++ program based on the target. Target here refers to the end machine where the code is executed. emcc has the Clang compiler built in. The emcc compiler is responsible for converting the C or C++ source code into LLVM byte code.
In this section, we will see how to improve the optimization and code size of the generated WebAssembly binary code.
To improve the efficiency and generated code size, the Emscripten compiler has the following options:
- Optimizations
- Closure Compiler
Lets talk about optimizations first.
Optimizations
The goal of the compiler is to reduce the cost of compilation, that is, the compile time. With the -O
optimization flag, the compiler tries to improve the code size and/or the performance at the expense of the compile time. In terms of compiler optimizations...