This article provides information that is relevant to people working on Emscripten itself, as opposed to those that use Emscripten in their own projects.
Tip
The information will be less relevant if you’re just using Emscripten, but may still be of interest.
As a contributor you will need to build Emscripten from source in order to integrate fixes back into the main repositories.
The Emscripten main repository is https://github.com/kripken/emscripten. There are two main branches:
Emscripten’s compiler core (Fastcomp) is maintained in two other repositories, which use the same master/incoming branch approach:
When building Emscripten from source you should use the same branch (incoming, or master) for building all three repositories. The topic Branches explains how to ensure that the versions are kept in sync.
Patches should be submitted as pull requests to the incoming branch.
Note
Before submitting your first patch, add yourself to the AUTHORS file. By doing so, you agree to license your code under the project’s open source licenses (MIT/LLVM).
When submitting patches, please:
@kripken reviews all pull requests before merging.
Exceptions are sub-projects that are ‘owned’ by other people. These owners can push to incoming directly:
The Emscripten Compiler Frontend (emcc) is a python script that manages the entire compilation process:
emcc calls Clang to convert C++ to bitcode, llvm-opt to optimize it, llvm-link to link it, etc.
emcc then calls emscripten.py, which performs the LLVM IR to JavaScript conversion:
- emscripten.py first runs the Fastcomp core compiler (previously it ran the old core compiler — src/compiler.js).
- emscripten.py then receives the core compiler output, modifies it slightly (some regexps) and then adds some necessary code around it. This generates the basic emitted JavaScript, which is called emcc-2-original in the intermediate files saved in debug mode.
emcc runs tools/js_optimizer.py to further process and optimize the generated JavaScript.
- js_optimizer.py breaks up the generated JavaScript file into the relevant parts for optimization and calls js-optimizer.js to actually optimize it.
- js-optimizer.js parses and transforms the JavaScript into better JavaScript using the UglifyJS node.js script.
Emscripten has a comprehensive test suite, which covers virtually all Emscripten functionality. These tests must all pass when you are submitting patches.