This article introduces Fastcomp, Emscripten’s LLVM + Clang implementation. It explains how you can obtain the tool, why it replaced the original compiler core, and how you can turn off Fastcomp if needed. There is also a FAQ at the very end for troubleshooting Fastcomp problems.
Fastcomp is the default compiler core for Emscripten. Implemented as an LLVM backend, its role is to convert the LLVM Intermediate Representation (IR) created by Clang (from C/C++) into JavaScript.
Fastcomp has the following features:
Fastcomp is maintained in two repositories:
Fastcomp (Clang) is part of the Emscripten SDK, and the binaries are automatically provided during installation (except on Linux, where pre-built binaries are not supplied so the SDK builds them for you).
If you need to build from source you can:
Warning
The backend is still too new to be in the upstream LLVM repository. As such, builds from Linux distributions will not contain Fastcomp, and Emscripten will report an error if you try to use them.
The original compiler supported dozens of different code generation modes (no-typed arrays, typed arrays in various modes, asm.js vs. non-asm.js, etc.), many of which were not very efficient. Over time, the compiler became harder to maintain and was susceptible to unpredictable compiler slow-downs.
Fastcomp was turned on by default in version 1.12.1. The original compiler is now “deprecated”.
Note
While it is possible to manually disable Fastcomp and build the original compiler from source, this is discouraged.
As a result of the problems with the original compiler, we developed Fastcomp, which is a much better compiler:
The main downside is that Emscripten can no longer use a stock build of LLVM, because we have made changes that must be built with LLVM.
There are also a few features that were present in the original compiler that are not present in Fastcomp (see the next section).
Note
We hope that the new Emscripten backend will eventually become part of the upstream LLVM, and hence become available in stock builds.
Some features that were present in the original compiler that are not present in Fastcomp include:
Various deprecated settings.js options (FORCE_ALIGNMENT, HEAP_INIT, etc.) You should receive a compile-time error if you use a setting which is not supported.
Linking of asm.js shared modules. This is not deprecated, but may need to be reconsidered.
Note
Normal static linking as used by almost all projects works fine; it is just specifically the options MAIN_MODULE and SIDE_MODULE that do not work.
Fastcomp is now the only supported compiler and the old compiler has been removed from emscripten.
You are linking together bitcode files compiled with the old compiler (or older versions of Fastcomp) with bitcode files from the new one. This may work in some cases but is dangerous and should be avoided. To fix it, just recompile all your bitcode with the new compiler.