The SDK can be used to fetch and build Emscripten from the latest sources in the Emscripten and Fastcomp repositories. This allows you to obtain new features and defect fixes as soon as they are pushed to Github.
Contributors can replace these sources with their own forks of Emscripten and Fastcomp, build them, and then use the normal process to pull changes into the main repository.
The instructions below explain how use the SDK to build Emscripten from both the main repositories and your own forks (for all supported platforms).
The SDK is recommended if you need to manage both SDK and source-built environments within the same user login.
For contributors the actual process of getting and building the sources for your fork is very similar to the manual build process. However the setup is easier because the SDK automatically installs and validates most of the needed tools and dependencies, and manages the compiler configuration file for you.
Then download and install the compiler toolchain for your platform.
The Emscripten SDK (emsdk) controls which tool and SDK “targets” are installed and activated. To start using the latest upstream git development branch (
incoming), run the following commands:
# Clone, pull, and build the latest "sdk" Emscripten environment ./emsdk install sdk-incoming-64bit # Set the "incoming SDK" as the active version. ./emsdk activate sdk-incoming-64bit
If you want to use the upstream stable branch
-master- in the commands above.
The SDK supplies a number of other “repository” targets. These targets are viewed by entering
./emsdk list on the command prompt:
sdk-incoming-64bit is the target for a complete 64-bit Emscripten environment build from the incoming branch of the Emscripten and Fastcomp repositories. This is equivalent to:
emsdk install clang-incoming-64bit node-0.10.17-64bit python-126.96.36.199-64bit java-7.45-64bit emscripten-incoming git-1.8.3
sdk-targets are provided for the master branch and 32bit builds.
emscripten-master are targets for the Emscripten repository (only)
clang-incoming-64bit is the target for getting and building Fastcomp (only) from its repositories. Other
clang- targets are provided for the master branch and 32bit builds.
Emscripten Contributors need to be able to build Emscripten from their own fork — in order to use pull requests to merge changes back into Emscripten. This is achieved by first installing source from the main repositories (as described in the previous section), and then replacing the sources with those from the fork.
You don’t have to replace all of the code as shown below. If you’re only working on Fastcomp, then there is no need to get your own fork of Emscripten.
After installing the main repositories:
Get your fork of Fastcomp:
# From your emsdk "root" (where emsdk is installed). Navigate to the LLVM clone: cd clang/fastcomp/src # Add a git remote link to your LLVM repository fork git remote add myremote https://github.com/mygituseraccount/emscripten-fastcomp.git # Fetch the changes in the remote. git fetch myremote # Checkout the code in your LLVM fork to replace the original repository code git checkout -b myremote --track myremote/incoming
Get your fork of Fastcomp-Clang:
# Navigate to the tools/clang directory ( <emsdk root>/clang/fastcomp/src/tools/clang ) cd tools/clang # Add a git remote link to your Clang repository fork git remote add myremote https://github.com/mygituseraccount/emscripten-fastcomp-clang.git # Fetch the changes in the remote. git fetch myremote # Checkout the code in your Clang fork to replace the original repository code git checkout -b myremote --track myremote/incoming
The SDK builds Fastcomp into a branch- and build-specific directory — in this case <emsdk root>/clang/fastcomp/build_incoming_64. We need to build to the same location.#Navigate to the /clang/fastcomp/build_incoming_64 cd ../../../build_incoming_64
Configure the build using cmake:cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86;JSBackend" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DCLANG_INCLUDE_EXAMPLES=OFF -DCLANG_INCLUDE_TESTS=OFF
On Windows you will need Visual Studio 2012 or newer to build.
Determine the number of available cores on your system (Emscripten can run many operations in parallel, so using more cores may have a significant impact on compilation time):
- On Mac OS X you can get the number of cores using: Apple menu | About this mac | System report. The Hardware overview on the resulting dialog includes a Total number of cores entry.
- On Linux you can find the number of cores by entering the following command on the terminal:
cat /proc/cpuinfo | grep "^cpu cores" | uniq.
- On Windows the number of cores is listed on the Task Manager | Performance Tab. You can open the Task Manager by entering Ctrl + Shift + Esc from the Desktop.
Call make to build the sources, specifying the number of available cores:make -j1
At this point Fastcomp is compiled, and available in the same location as the original.
Get your fork of Emscripten:
# From your emsdk "root" (where emsdk is installed). Navigate to the Emscripten clone: cd emscripten/incoming # Add a git remote link to your Emscripten repository fork git remote add myremote https://github.com/mygituseraccount/emscripten.git # Fetch the changes in the remote. git fetch myremote # Checkout the code in your LLVM fork to replace the original repository code git checkout -b myremote --track myremote/incoming
You can switch back and forth between remotes (the original sources and your fork, or the incoming and master branches) using the
git checkout command. You can switch between the SDK and source using the
./emsdk activate <target> command.