#!/usr/bin/env bash # This script prepares and builds LLVM+Clang in a cycle # There are two purposes: # 1. Make sure the board can cope with sequential builds # for as long as you wish (at least 2 days non-stop) # 2. Make sure the builds take reasonably the same time # # That's why the script has the following features: # # * "set +e" to not fail even if the build fails, as a # subsequent commit can fix that, or even if the build # fails, we're still stressing the hardware, not the build # * `date` before each step, so that you can compare # multiple runs without having to find the `time` output # * Use -jCPUS, since we're not trying to get it faster, but # reliable, and that tells us more than -jCPUS+2, etc. # * Time builds and tests separately, since tests tend to be # more stable # * Don't use CCACHE, since that will defeat the purpose set +e ROOT=`pwd` CPUS=`grep -c proc /proc/cpuinfo` LINK_JOBS= GEN="Unix Makefiles" BUILD="make" if ninja --version > /dev/null; then LINK=`free -g | awk '/Mem/ {print $2}'` LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK" GEN="Ninja" BUILD="ninja" fi mkdir -p build if [ ! -d src ]; then git clone http://llvm.org/git/llvm.git src fi if [ ! -d src/tools/clang ]; then cd src/tools git clone http://llvm.org/git/clang.git fi cd $ROOT/build if [ ! -f Makefile ]; then cmake ../src -G "$GEN" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_BUILD_TESTS=True \ -DLLVM_ENABLE_ASSERTIONS=True \ -DLLVM_LIT_ARGS="-sv -j$CPUS" \ $LINK_JOBS fi while /bin/true; do echo -n "Updating sources at " date cd $ROOT/src git fetch origin; git pull cd tools/clang git fetch origin; git pull cd $ROOT/build echo -n "Cleaning at " date $BUILD -j$CPUS clean echo -n "Building at " date $BUILD -j$CPUS echo -n "Testing at " date $BUILD -j$CPUS check-all done