How to build Cheerp on Linux
Cheerp is composed of multiple components, they are somewhat interdependent and should be built together. The build instructions are provided for the stable release, Cheerp 3.0, or for the latest / development branch.
Scroll to bottom for the instruction for the latest version, or keep reading to build stable.
Prerequisites
We assume that you have git, cmake, python and a modern C++ compiler properly installed. Example, using apt-get:
sudo apt-get install cmake python3 python3-distutils ninja-build gcc g++ lld git
Build stable version, Cheerp 3.0
Get the sources, stable version
You need to get all the sources first. Please define the CHEERP_DEST
environment variable that will be used in various commands.
mkdir cheerpcd cheerpexport CHEERP_DEST=/opt/cheerpgit clone --branch cheerp-3.0 https://github.com/leaningtech/cheerp-compilergit clone --branch cheerp-3.0 https://github.com/leaningtech/cheerp-utilsgit clone --branch cheerp-3.0 https://github.com/leaningtech/cheerp-muslgit clone --branch cheerp-3.0 https://github.com/leaningtech/cheerp-libs
Build Cheerp/1: compiler, stable version
cd cheerp-compilercmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S llvm -B build -C llvm/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -G Ninjaninja -C buildninja -C build installcd ..
By default Cheerp will be installed in /opt/cheerp
, with the main executable at /opt/cheerp/bin/clang++
.
If you need write privileges to /opt/cheerp
, then prepend all install commands with sudo
.
Build Cheerp/2: utilities and libraries, stable version
cd cheerp-utilscmake -B build -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" .make -C build installcd ..
cd cheerp-muslmkdir build_genericjscd build_genericjsRANLIB="$CHEERP_DEST/bin/llvm-ar s" AR="$CHEERP_DEST/bin/llvm-ar" CC="$CHEERP_DEST/bin/clang -target cheerp" LD="$CHEERP_DEST/bin/llvm-link" CFLAGS="-Wno-int-conversion" ../configure --target=cheerp --disable-shared --prefix="$CHEERP_DEST" --with-malloc=dlmallocmake -jmake installcd ..mkdir build_asmjscd build_asmjsRANLIB="$CHEERP_DEST/bin/llvm-ar s" AR="$CHEERP_DEST/bin/llvm-ar" CC="$CHEERP_DEST/bin/clang -target cheerp-wasm" LD="$CHEERP_DEST/bin/llvm-link" CFLAGS="-Wno-int-conversion" ../configure --target=cheerp-wasm --disable-shared --prefix="$CHEERP_DEST" --with-malloc=dlmallocmake -jmake installcd ../..
cd cheerp-compilercmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S runtimes -B build_runtimes_genericjs -GNinja -C runtimes/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpToolchain.cmake"ninja -C build_runtimes_genericjs
cmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S runtimes -B build_runtimes_wasm -GNinja -C runtimes/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpWasmToolchain.cmake"ninja -C build_runtimes_wasm
ninja -C build_runtimes_genericjs installninja -C build_runtimes_wasm installcd ..
cd cheerp-libsmake -C webgles install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"make -C wasm install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"make -C stdlibs install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"cd systemcmake -B build_genericjs -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpToolchain.cmake" .cmake --build build_genericjscmake --install build_genericjscmake -B build_asmjs -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpWasmToolchain.cmake" .cmake --build build_asmjscmake --install build_asmjscd ../..
Build latest version
This allows one to benefit from the latest developments and bug fixes, but we reserve the possibility of forward-incompatible changes.
Get the sources, latest version
You need to get all the sources first. Please define the CHEERP_DEST
environment variable that will be used in various commands.
mkdir cheerpcd cheerpexport CHEERP_DEST=/opt/cheerpgit clone https://github.com/leaningtech/cheerp-compilergit clone https://github.com/leaningtech/cheerp-utilsgit clone https://github.com/leaningtech/cheerp-muslgit clone https://github.com/leaningtech/cheerp-libs
Quickstart
To quickly build everything, just run cd cheerp-compiler && ./debian/build.sh
.
Build Cheerp/1: compiler, latest version
cd cheerp-compilercmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S llvm -B build -C llvm/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -G Ninjaninja -C buildninja -C build installcd ..
By default Cheerp will be installed in /opt/cheerp
, with the main executable at /opt/cheerp/bin/clang++
.
If you need write privileges to /opt/cheerp
, then prepend all install commands with sudo
.
Build Cheerp/2: utilities and libraries, latest version
cd cheerp-utilscmake -B build -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" .make -C build installcd ..
cd cheerp-muslmkdir build_genericjscd build_genericjsRANLIB="$CHEERP_DEST/bin/llvm-ar s" AR="$CHEERP_DEST/bin/llvm-ar" CC="$CHEERP_DEST/bin/clang -target cheerp" LD="$CHEERP_DEST/bin/llvm-link" CFLAGS="-Wno-int-conversion" ../configure --target=cheerp --disable-shared --prefix="$CHEERP_DEST" --with-malloc=dlmallocmake -jmake installcd ..mkdir build_asmjscd build_asmjsRANLIB="$CHEERP_DEST/bin/llvm-ar s" AR="$CHEERP_DEST/bin/llvm-ar" CC="$CHEERP_DEST/bin/clang -target cheerp-wasm" LD="$CHEERP_DEST/bin/llvm-link" CFLAGS="-Wno-int-conversion" ../configure --target=cheerp-wasm --disable-shared --prefix="$CHEERP_DEST" --with-malloc=dlmallocmake -jmake installcd ../..
cd cheerp-compilercmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S runtimes -B build_runtimes_genericjs -GNinja -C runtimes/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpToolchain.cmake"ninja -C build_runtimes_genericjs
cmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -S runtimes -B build_runtimes_wasm -GNinja -C runtimes/CheerpCmakeConf.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpWasmToolchain.cmake"ninja -C build_runtimes_wasm
ninja -C build_runtimes_genericjs installninja -C build_runtimes_wasm installcd ..
cd cheerp-libsmake -C webgles install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"make -C wasm install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"make -C stdlibs install INSTALL_PREFIX="$CHEERP_DEST" CHEERP_PREFIX="$CHEERP_DEST"cd systemcmake -B build_genericjs -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpToolchain.cmake" .cmake --build build_genericjscmake --install build_genericjscmake -B build_asmjs -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpWasmToolchain.cmake" .cmake --build build_asmjscmake --install build_asmjscd ../..
cd cheerp-compiler/compiler-rtcmake -DCMAKE_INSTALL_PREFIX="$CHEERP_DEST" -B build -C CheerpCmakeConf.cmake -DCMAKE_TOOLCHAIN_FILE="$CHEERP_DEST/share/cmake/Modules/CheerpWasmToolchain.cmake" .make -C build install # parallel builds do NOT work
Cheerp unit tests
In order to run the unit tests you will have to have a JavaScript engine installed.
We recommend NodeJS, installation instructions can be found here: https://nodejs.org/en/download/package-manager
cd cheerp-utils/testspython3 run_tests.py /opt/cheerp/bin/clang++ node --all -j8
This command will compile and execute the Cheerp test suite.