blob: 2e07ff12b36d5dfd74793e03834a676f97ad2e2f [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env bash
2
3# This script prepares and builds LLVM+Clang in a cycle
4# There are two purposes:
5# 1. Make sure the board can cope with sequential builds
6# for as long as you wish (at least 2 days non-stop)
7# 2. Make sure the builds take reasonably the same time
8#
9# That's why the script has the following features:
10#
11# * "set +e" to not fail even if the build fails, as a
12# subsequent commit can fix that, or even if the build
13# fails, we're still stressing the hardware, not the build
14# * `date` before each step, so that you can compare
15# multiple runs without having to find the `time` output
16# * Use -jCPUS, since we're not trying to get it faster, but
17# reliable, and that tells us more than -jCPUS+2, etc.
18# * Time builds and tests separately, since tests tend to be
19# more stable
20# * Don't use CCACHE, since that will defeat the purpose
21
22set +e
23
Renato Golin250b7aa2016-09-17 18:22:38 +010024ROOT=$(pwd)
25CPUS=$(grep -c proc /proc/cpuinfo)
26LINK=$(free -g | awk '/Mem/ {print $2}')
27if [ "$LINK" -gt "$CPUS" ]; then
28 LINK=$CPUS
29else
30 LINK=$((LINK+1))
31fi
Renato Golin94cc1042016-04-26 11:02:23 +010032LINK_JOBS=
Renato Golin9f393da2016-05-01 18:17:39 +010033GEN="Unix Makefiles"
34BUILD="make"
Renato Golin94cc1042016-04-26 11:02:23 +010035if ninja --version > /dev/null; then
Renato Golin94cc1042016-04-26 11:02:23 +010036 LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK"
Renato Golin9f393da2016-05-01 18:17:39 +010037 GEN="Ninja"
38 BUILD="ninja"
Renato Golin94cc1042016-04-26 11:02:23 +010039fi
40
41mkdir -p build
42if [ ! -d src ]; then
43 git clone http://llvm.org/git/llvm.git src
44fi
45if [ ! -d src/tools/clang ]; then
46 cd src/tools
47 git clone http://llvm.org/git/clang.git
48fi
49cd $ROOT/build
50if [ ! -f Makefile ]; then
Renato Golin9f393da2016-05-01 18:17:39 +010051 cmake ../src -G "$GEN" \
Renato Golin94cc1042016-04-26 11:02:23 +010052 -DCMAKE_BUILD_TYPE=Release \
53 -DLLVM_BUILD_TESTS=True \
54 -DLLVM_ENABLE_ASSERTIONS=True \
Diana Picus0df00012016-09-15 16:10:44 +030055 -DLLVM_LIT_ARGS="-sv -j$CPUS" \
Renato Golin94cc1042016-04-26 11:02:23 +010056 $LINK_JOBS
57fi
58
59while /bin/true; do
60 echo -n "Updating sources at "
61 date
62 cd $ROOT/src
63 git fetch origin; git pull
64 cd tools/clang
65 git fetch origin; git pull
66 cd $ROOT/build
67 echo -n "Cleaning at "
68 date
Renato Golin9f393da2016-05-01 18:17:39 +010069 $BUILD -j$CPUS clean
Renato Golin94cc1042016-04-26 11:02:23 +010070 echo -n "Building at "
71 date
Renato Golin9f393da2016-05-01 18:17:39 +010072 $BUILD -j$CPUS
Renato Golin94cc1042016-04-26 11:02:23 +010073 echo -n "Testing at "
74 date
Renato Golin9f393da2016-05-01 18:17:39 +010075 $BUILD -j$CPUS check-all
Renato Golin94cc1042016-04-26 11:02:23 +010076done