aboutsummaryrefslogtreecommitdiff
path: root/stress/build-llvm-forever.sh
blob: 5fc40962814a4b0ed3ea619abc6f0e0b8d42968f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/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