#!/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" elif [[ $CORE = '0xc09' ]]; then CORE="-mcpu=cortex-a9" elif [[ $CORE = '0xc0f' ]]; then CORE="-mcpu=cortex-a15" elif [[ $CORE = '0xd03' ]]; then CORE="-mcpu=cortex-a53" elif [[ $CORE = '0xd07' ]]; then CORE="-mcpu=cortex-a57" else CORE='' fi CPUS=$(grep -c proc /proc/cpuinfo) PARALLEL=-j$CPUS LINK=$(free -g | awk '/Mem/ {print $2}') if [ "$LINK" -gt "$CPUS" ]; then LINK=$CPUS else LINK=$((LINK+1)) 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 ] | -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 \ -DLLVM_LIT_ARGS="-sv $PARALLEL" \ -DLLVM_PARALLEL_LINK_JOBS=$LINK safe_run ninja $PARALLEL 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