blob: 465a51f896cc10c7cf2e12d9e12c1e7cc47e910b [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
24ROOT=`pwd`
25CPUS=`grep -c proc /proc/cpuinfo`
26LINK_JOBS=
27NINJA=
28if ninja --version > /dev/null; then
29 LINK=`free -g | awk '/Mem/ {print $2}'`
30 LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK"
31 NINJA="-G Ninja"
32fi
33
34mkdir -p build
35if [ ! -d src ]; then
36 git clone http://llvm.org/git/llvm.git src
37fi
38if [ ! -d src/tools/clang ]; then
39 cd src/tools
40 git clone http://llvm.org/git/clang.git
41fi
42cd $ROOT/build
43if [ ! -f Makefile ]; then
44 cmake ../src $NINJA \
45 -DCMAKE_BUILD_TYPE=Release \
46 -DLLVM_BUILD_TESTS=True \
47 -DLLVM_ENABLE_ASSERTIONS=True \
48 $LINK_JOBS
49fi
50
51while /bin/true; do
52 echo -n "Updating sources at "
53 date
54 cd $ROOT/src
55 git fetch origin; git pull
56 cd tools/clang
57 git fetch origin; git pull
58 cd $ROOT/build
59 echo -n "Cleaning at "
60 date
61 make -j$CPUS clean
62 echo -n "Building at "
63 date
64 make -j$CPUS
65 echo -n "Testing at "
66 date
67 make -j$CPUS check-all
68done