Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/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 | |
| 22 | set +e |
| 23 | |
Renato Golin | 250b7aa | 2016-09-17 18:22:38 +0100 | [diff] [blame] | 24 | ROOT=$(pwd) |
| 25 | CPUS=$(grep -c proc /proc/cpuinfo) |
| 26 | LINK=$(free -g | awk '/Mem/ {print $2}') |
| 27 | if [ "$LINK" -gt "$CPUS" ]; then |
| 28 | LINK=$CPUS |
| 29 | else |
| 30 | LINK=$((LINK+1)) |
| 31 | fi |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 32 | LINK_JOBS= |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 33 | GEN="Unix Makefiles" |
| 34 | BUILD="make" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 35 | if ninja --version > /dev/null; then |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 36 | LINK_JOBS="-DLLVM_PARALLEL_LINK_JOBS=$LINK" |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 37 | GEN="Ninja" |
| 38 | BUILD="ninja" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 39 | fi |
| 40 | |
| 41 | mkdir -p build |
| 42 | if [ ! -d src ]; then |
| 43 | git clone http://llvm.org/git/llvm.git src |
| 44 | fi |
| 45 | if [ ! -d src/tools/clang ]; then |
| 46 | cd src/tools |
| 47 | git clone http://llvm.org/git/clang.git |
| 48 | fi |
| 49 | cd $ROOT/build |
| 50 | if [ ! -f Makefile ]; then |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 51 | cmake ../src -G "$GEN" \ |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 52 | -DCMAKE_BUILD_TYPE=Release \ |
| 53 | -DLLVM_BUILD_TESTS=True \ |
| 54 | -DLLVM_ENABLE_ASSERTIONS=True \ |
Diana Picus | 0df0001 | 2016-09-15 16:10:44 +0300 | [diff] [blame] | 55 | -DLLVM_LIT_ARGS="-sv -j$CPUS" \ |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 56 | $LINK_JOBS |
| 57 | fi |
| 58 | |
| 59 | while /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 Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 69 | $BUILD -j$CPUS clean |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 70 | echo -n "Building at " |
| 71 | date |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 72 | $BUILD -j$CPUS |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 73 | echo -n "Testing at " |
| 74 | date |
Renato Golin | 9f393da | 2016-05-01 18:17:39 +0100 | [diff] [blame] | 75 | $BUILD -j$CPUS check-all |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 76 | done |