aboutsummaryrefslogtreecommitdiff
path: root/bisect/run.sh
blob: 6219248e3e3401c9c0c8388c2886d66f2a8aac39 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash

# This script run one cycle of the bisect, by building (or self-hosting)
# LLVM+Clang, running the compiler tests and the test-suite, if required.
# Please, use the sequential.sh script to drive this one.

. common.sh

CORE=`grep "CPU part" /proc/cpuinfo | awk '{print $4}'`
if [[ $CORE = '0xc08' ]]; then
  CORE="-mcpu=cortex-a8"
else if [[ $CORE = '0xc09' ]]; then
  CORE="-mcpu=cortex-a9"
else if [[ $CORE = '0xc0f' ]]; then
  CORE="-mcpu=cortex-a15"
else if [[ $CORE = '0xd03' ]]; then
  CORE="-mcpu=cortex-a53"
else if [[ $CORE = '0xd07' ]]; then
  CORE="-mcpu=cortex-a57"
else
  CORE=''
fi fi fi fi fi

selfhost=false
check=false
cflags=$CORE
full=false
keepbuild=false
while getopts "sct:hfvk" opt; do
  case $opt in
    s)
      selfhost=true
      ;;
    c)
      check=true
      ;;
    t)
      test=$OPTARG
      ;;
    h)
      cflags="$cflags -mthumb"
      ;;
    v)
      cflags="$cflags -mfpu=vfpv3"
      ;;
    f)
      full=true
      ;;
    k)
      keepbuild=true
      ;;
    *)
      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"
      exit 1
      ;;
  esac
done

flush() {
  if ! $keepbuild; then
    if [[ -d $1 && $1 != '/' ]]; then
      rm -rf $1
    fi
  fi
  mkdir -p $1
  cd $1
}

build() {
  CC=gcc
  CXX=g++
  if [[ $1 != '' ]]; then
    CC=$1/bin/clang
    CXX=$1/bin/clang++
  fi
  CC=$CC CXX=$CXX \
    cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release \
                           -DCMAKE_C_FLAGS="$cflags" \
                           -DCMAKE_CXX_FLAGS="$cflags" \
                           -DLLVM_TARGETS_TO_BUILD="ARM;AArch64" \
                           -DLLVM_BUILD_TESTS=True \
                           -DLLVM_ENABLE_ASSERTIONS=True
  safe_run ninja
  if $check; then
    safe_run ninja check-all
  fi
}

ROOT=`pwd`

if $full; then
  ln -sf `pwd`/compiler-rt `pwd`/llvm/projects/compiler-rt
else
  rm -f `pwd`/llvm/projects/compiler-rt
fi

# Native build
flush $ROOT/build
build

if $selfhost; then
  # Self-hosting build
  flush $ROOT/build2
  build $ROOT/build
fi

if [[ $test != '' ]]; then
  cd $ROOT
  safe_run ./test.sh $test
fi

# SVN info
cd $ROOT
svn info llvm