blob: 97d1a68d233cc26b8fe3c9c4580f9e6740849e23 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env bash
2
3# This script run one cycle of the bisect, by building (or self-hosting)
4# LLVM+Clang, running the compiler tests and the test-suite, if required.
5# Please, use the sequential.sh script to drive this one.
6
7. common.sh
8
9CORE=`grep "CPU part" /proc/cpuinfo | awk '{print $4}'`
10if [[ $CORE = '0xc08' ]]; then
11 CORE="-mcpu=cortex-a8"
Renato Golin250b7aa2016-09-17 18:22:38 +010012elif [[ $CORE = '0xc09' ]]; then
Renato Golin94cc1042016-04-26 11:02:23 +010013 CORE="-mcpu=cortex-a9"
Renato Golin250b7aa2016-09-17 18:22:38 +010014elif [[ $CORE = '0xc0f' ]]; then
Renato Golin94cc1042016-04-26 11:02:23 +010015 CORE="-mcpu=cortex-a15"
Renato Golin250b7aa2016-09-17 18:22:38 +010016elif [[ $CORE = '0xd03' ]]; then
Renato Golin94cc1042016-04-26 11:02:23 +010017 CORE="-mcpu=cortex-a53"
Renato Golin250b7aa2016-09-17 18:22:38 +010018elif [[ $CORE = '0xd07' ]]; then
Renato Golin94cc1042016-04-26 11:02:23 +010019 CORE="-mcpu=cortex-a57"
20else
21 CORE=''
Renato Golin250b7aa2016-09-17 18:22:38 +010022fi
Renato Golin94cc1042016-04-26 11:02:23 +010023
Renato Golin250b7aa2016-09-17 18:22:38 +010024CPUS=$(grep -c proc /proc/cpuinfo)
25PARALLEL=-j$CPUS
26LINK=$(free -g | awk '/Mem/ {print $2}')
27if [ "$LINK" -gt "$CPUS" ]; then
28 LINK=$CPUS
29else
30 LINK=$((LINK+1))
31fi
32
Diana Picus0df00012016-09-15 16:10:44 +030033
Renato Golin94cc1042016-04-26 11:02:23 +010034selfhost=false
35check=false
36cflags=$CORE
37full=false
38keepbuild=false
39while getopts "sct:hfvk" opt; do
40 case $opt in
41 s)
42 selfhost=true
43 ;;
44 c)
45 check=true
46 ;;
47 t)
48 test=$OPTARG
49 ;;
50 h)
51 cflags="$cflags -mthumb"
52 ;;
53 v)
54 cflags="$cflags -mfpu=vfpv3"
55 ;;
56 f)
57 full=true
58 ;;
59 k)
60 keepbuild=true
61 ;;
62 *)
63 echo "Syntax: $0 [-(s)elfhost | -(c)heck-all | -(t)est <test-suite-name>] | -T(h)umb | -(v)fp3 | -(f)ull-with-RT | -(k)eep build dir"
64 exit 1
65 ;;
66 esac
67done
68
69flush() {
70 if ! $keepbuild; then
71 if [[ -d $1 && $1 != '/' ]]; then
72 rm -rf $1
73 fi
74 fi
75 mkdir -p $1
76 cd $1
77}
78
79build() {
80 CC=gcc
81 CXX=g++
82 if [[ $1 != '' ]]; then
83 CC=$1/bin/clang
84 CXX=$1/bin/clang++
85 fi
86 CC=$CC CXX=$CXX \
87 cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release \
88 -DCMAKE_C_FLAGS="$cflags" \
89 -DCMAKE_CXX_FLAGS="$cflags" \
90 -DLLVM_TARGETS_TO_BUILD="ARM;AArch64" \
91 -DLLVM_BUILD_TESTS=True \
Diana Picus0df00012016-09-15 16:10:44 +030092 -DLLVM_ENABLE_ASSERTIONS=True \
Renato Golin250b7aa2016-09-17 18:22:38 +010093 -DLLVM_LIT_ARGS="-sv $PARALLEL" \
94 -DLLVM_PARALLEL_LINK_JOBS=$LINK
Diana Picus0df00012016-09-15 16:10:44 +030095 safe_run ninja $PARALLEL
Renato Golin94cc1042016-04-26 11:02:23 +010096 if $check; then
97 safe_run ninja check-all
98 fi
99}
100
101ROOT=`pwd`
102
103if $full; then
104 ln -sf `pwd`/compiler-rt `pwd`/llvm/projects/compiler-rt
105else
106 rm -f `pwd`/llvm/projects/compiler-rt
107fi
108
109# Native build
110flush $ROOT/build
111build
112
113if $selfhost; then
114 # Self-hosting build
115 flush $ROOT/build2
116 build $ROOT/build
117fi
118
119if [[ $test != '' ]]; then
120 cd $ROOT
121 safe_run ./test.sh $test
122fi
123
124# SVN info
125cd $ROOT
126svn info llvm