test-release.sh revision 540d5b7406a9aeb75492adfa58f0b5b4a2b9442a
1b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#!/bin/bash
2b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#===-- test-release.sh - Test the LLVM release candidates ------------------===#
3b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#
4b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#                     The LLVM Compiler Infrastructure
5b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#
6b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# This file is distributed under the University of Illinois Open Source
7b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# License.
8b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#
9b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#===------------------------------------------------------------------------===#
10b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#
11b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Download, build, and test the release candidate for an LLVM release.
12b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#
13b91c71299a819e2d20786b629376f119085e8b28Bill Wendling#===------------------------------------------------------------------------===#
14b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
15e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendlingset -e                          # Exit if any command fails
16b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
1741adc5fb8bd0d81f07d93754868bd9f27b6fd9afBill Wendlingprojects="llvm cfe dragonegg test-suite"
181416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling
191416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling# Base SVN URL for the sources.
201416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill WendlingBase_url="http://llvm.org/svn/llvm-project"
211416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling
22b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRelease=""
23b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRelease_no_dot=""
24b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRC=""
25b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_checkout="yes"
26b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_ada="no"
27c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendlingdo_objc="yes"
281416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingdo_fortran="no"
29b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_64bit="yes"
301416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingdo_debug="no"
31a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendlingdo_asserts="no"
32b91c71299a819e2d20786b629376f119085e8b28Bill WendlingBuildDir="`pwd`"
33b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
34b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction usage() {
35b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "usage: `basename $0` -release X.Y -rc NUM [OPTIONS]"
36b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
37b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -release X.Y      The release number to test."
38b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -rc NUM           The pre-release candidate number."
39b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -j NUM            Number of compile jobs to run. [default: 3]"
40b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -build-dir DIR    Directory to perform testing in. [default: pwd]"
41b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -no-checkout      Don't checkout the sources from SVN."
42b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -no-64bit         Don't test the 64-bit version. [default: yes]"
43e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling    echo " -enable-ada       Build Ada. [default: disable]"
441416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo " -enable-fortran   Enable Fortran build. [default: disable]"
45e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling    echo " -disable-objc     Disable ObjC build. [default: enable]"
461416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo " -test-debug       Test the debug build. [default: no]"
47a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    echo " -test-asserts     Test with asserts on. [default: no]"
48b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
49b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
50b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingwhile [ $# -gt 0 ]; do
51b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    case $1 in
52b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -release | --release )
53b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
54b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Release="$1"
55b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Release_no_dot="`echo $1 | sed -e 's,\.,,'`"
56b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
57b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -rc | --rc | -RC | --RC )
58b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
59b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            RC=$1
60b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
61b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -j* )
62b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
63b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            if [ -z "$NumJobs" ]; then
64b91c71299a819e2d20786b629376f119085e8b28Bill Wendling                shift
65b91c71299a819e2d20786b629376f119085e8b28Bill Wendling                NumJobs="$1"
66b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            fi
67b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
68b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -build-dir | --build-dir | -builddir | --builddir )
69b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
70b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            BuildDir="$1"
71b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
72b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -no-checkout | --no-checkout )
73b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_checkout="no"
74b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
75b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -no-64bit | --no-64bit )
76b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_64bit="no"
77b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
78e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling        -enable-ada | --enable-ada )
79b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_ada="yes"
80b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
811416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        -enable-fortran | --enable-fortran )
821416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            do_fortran="yes"
831416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            ;;
84c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling        -disable-objc | --disable-objc )
85c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling            do_objc="no"
86c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling            ;;
871416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        -test-debug | --test-debug )
881416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            do_debug="yes"
89b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
90a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        -test-asserts | --test-asserts )
91a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling            do_asserts="yes"
92a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling            ;;
93b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -help | --help | -h | --h | -\? )
94b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            usage
95b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            exit 0
96b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
97b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        * )
98b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo "unknown option: $1"
99b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            usage
100b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            exit 1
101b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
102b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    esac
103b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    shift
104b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdone
105b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
106b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Check required arguments.
107b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$Release" ]; then
1081416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "error: no release number specified"
109b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    exit 1
110b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
111b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$RC" ]; then
1121416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "error: no release candidate number specified"
113b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    exit 1
114b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
115b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
116d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands# Figure out how many make processes to run.
117d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
118d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
119d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
120d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
121d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
122d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
123d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
124d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
125d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
126b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$NumJobs" ]; then
127b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    NumJobs=3
128b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
129b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
1301416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling# Go to the build directory (may be different from CWD)
1311416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill WendlingBuildDir=$BuildDir/rc$RC
1321416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingmkdir -p $BuildDir
1331416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingcd $BuildDir
134b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
135f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands# Location of log files.
1361416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill WendlingLogDir=$BuildDir/logs
137f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sandsmkdir -p $LogDir
138f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands
1391416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling# Find a compilers.
1401416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingc_compiler="`which clang`"
1411416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingif [ -z "$c_compiler" ]; then
1421416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    c_compiler="`which gcc`"
1431416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    if [ -z "$c_compiler" ]; then
1441416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        c_compiler="`which cc`"
1451416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        if [ -z "$c_compiler" ]; then
1461416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            echo "error: cannot find a working C compiler"
1471416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        fi
1481416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    fi
1491416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingfi
1501416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingcxx_compiler="`which clang++`"
1511416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingif [ -z "$cxx_compiler" ]; then
1521416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cxx_compiler="`which g++`"
1531416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    if [ -z "$cxx_compiler" ]; then
1541416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        cxx_compiler="`which c++`"
1551416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        if [ -z "$cxx_compiler" ]; then
1561416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            echo "error: cannot find a working C++ compiler"
1571416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        fi
1581416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    fi
1591416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingfi
160b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
161b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Make sure that the URLs are valid.
162b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction check_valid_urls() {
1631416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    for proj in $projects ; do
1641416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        echo "# Validating $proj SVN URL"
1651416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling
166540d5b7406a9aeb75492adfa58f0b5b4a2b9442aBill Wendling        if ! svn ls $Base_url/$proj/tags/RELEASE_$Release_no_dot/rc$RC > /dev/null 2>&1 ; then
1671416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            echo "llvm $Release release candidate $RC doesn't exist!"
1681416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            exit 1
1691416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        fi
1701416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    done
171b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
172b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
173b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Export sources to the the build directory.
174b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction export_sources() {
175b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    check_valid_urls
176b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
1771416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    for proj in $projects ; do
1781416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        echo "# Exporting $proj $Release-RC$RC sources"
1791416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        if ! svn export -q $Base_url/$proj/tags/RELEASE_$Release_no_dot/rc$RC $proj.src ; then
1801416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            echo "error: failed to export $proj project"
1811416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            exit 1
1821416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        fi
1831416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    done
1841416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling
1851416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "# Creating symlinks"
1861416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir/llvm.src/tools
1871416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    if [ ! -h clang ]; then
1881416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        ln -s $BuildDir/cfe.src clang
1891416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    fi
1901416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir/llvm.src/projects
1911416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    if [ ! -h llvm-test ]; then
1921416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        ln -s $BuildDir/test-suite.src llvm-test
1931416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    fi
1941416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir
195b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
196b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
197b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction configure_llvmCore() {
198b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
199b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
200b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
201b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    InstallDir="$4"
202b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
203b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    case $Flavor in
204b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        Release | Release-64 )
205b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="yes"
2068a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands            Assertions="no"
207b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
2088a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands        Release+Asserts )
209b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="yes"
2108a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands            Assertions="yes"
211b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
212b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        Debug )
213b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="no"
214b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Assertions="yes"
215b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
216b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        * )
2171416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling            echo "# Invalid flavor '$Flavor'"
218b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo ""
219b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            return
220b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
221b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    esac
222b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
2231416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "# Using C compiler: $c_compiler"
2241416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "# Using C++ compiler: $cxx_compiler"
2251416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling
226b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
227b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Configuring llvm $Release-rc$RC $Flavor"
2281416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "# $BuildDir/llvm.src/configure --prefix=$InstallDir \
229b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-optimized=$Optimized \
2301416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        --enable-assertions=$Assertions"
2311416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    env CC=$c_compiler CXX=$cxx_compiler \
2321416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    $BuildDir/llvm.src/configure --prefix=$InstallDir \
233b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-optimized=$Optimized \
234b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-assertions=$Assertions \
2351416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
2361416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir
237b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
238b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
239b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction build_llvmCore() {
240b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
241b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
242b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
243b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ExtraOpts=""
244b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
245b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$Flavor" = "Release-64" ]; then
246b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        ExtraOpts="EXTRA_OPTIONS=-m64"
247b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
248b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
249b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
250b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Compiling llvm $Release-rc$RC $Flavor"
251b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make -j $NumJobs VERBOSE=1 $ExtraOpts"
2521416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    make -j $NumJobs VERBOSE=1 $ExtraOpts \
2531416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
254b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
255b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Installing llvm $Release-rc$RC $Flavor"
256b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make install"
257f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make install \
2581416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
2591416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir
260b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
261b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
262b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction test_llvmCore() {
263b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
264b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
265b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
266b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
267b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
2681416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    make check-all \
2691416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log
270f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make unittests \
27141adc5fb8bd0d81f07d93754868bd9f27b6fd9afBill Wendling        2>&1 | tee $LogDir/llvm.unittests-Phase$Phase-$Flavor.log
2721416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cd $BuildDir
273b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
274b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
275b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ "$do_checkout" = "yes" ]; then
276b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    export_sources
277b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
278b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
279f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands(
280a854f5d6f9394212319f4e00b6396900f6e62864Bill WendlingFlavors="Release"
2811416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingif [ "$do_debug" = "yes" ]; then
2821416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    Flavors="Debug $Flavors"
2831416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendlingfi
284a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendlingif [ "$do_asserts" = "yes" ]; then
285a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    Flavors="$Flavors Release+Asserts"
286a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendlingfi
287b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ "$do_64bit" = "yes" ]; then
288b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavors="$Flavors Release-64"
289b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
290b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
291b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfor Flavor in $Flavors ; do
292b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
293b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
294b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "********************************************************************************"
295b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  Release:     $Release-rc$RC"
296b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  Build:       $Flavor"
297b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  System Info: "
298b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "    `uname -a`"
299b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "********************************************************************************"
300b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
301b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
302b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.obj
303b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase1_installdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.install
304b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
305b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.obj
306b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.install
307b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
308a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-rc$RC.obj
309a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    llvmCore_phase3_installdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-rc$RC.install
310a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling
311b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase1_objdir
312b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase1_installdir
313b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase2_objdir
314b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase2_installdir
315a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    rm -rf $llvmCore_phase3_objdir
316a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    rm -rf $llvmCore_phase3_installdir
317b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
318b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase1_objdir
319b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase1_installdir
320b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase2_objdir
321b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase2_installdir
322a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    mkdir -p $llvmCore_phase3_objdir
323a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    mkdir -p $llvmCore_phase3_installdir
324b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
325b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ############################################################################
326b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    # Phase 1: Build llvmCore and llvmgcc42
327b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 1: Building llvmCore"
328b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvmCore 1 $Flavor \
3291416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        $llvmCore_phase1_objdir $llvmCore_phase1_installdir
330b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvmCore 1 $Flavor \
331b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase1_objdir
332b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
333b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ############################################################################
3341416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    # Phase 2: Build llvmCore with newly built clang from phase 1.
3351416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    c_compiler=$llvmCore_phase1_installdir/bin/clang
3361416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    cxx_compiler=$llvmCore_phase1_installdir/bin/clang++
337b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 2: Building llvmCore"
338b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvmCore 2 $Flavor \
3391416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling        $llvmCore_phase2_objdir $llvmCore_phase2_installdir
340b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvmCore 2 $Flavor \
341b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase2_objdir
342b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
343a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    ############################################################################
344a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    # Phase 3: Build llvmCore with newly built clang from phase 2.
345a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    c_compiler=$llvmCore_phase2_installdir/bin/clang
346a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    cxx_compiler=$llvmCore_phase2_installdir/bin/clang++
347a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    echo "# Phase 3: Building llvmCore"
348a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    configure_llvmCore 3 $Flavor \
349a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        $llvmCore_phase3_objdir $llvmCore_phase3_installdir
350a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    build_llvmCore 3 $Flavor \
351a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        $llvmCore_phase3_objdir
352a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling
353a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    ############################################################################
354a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    # Testing: Test phase 3
3551416dc29d8573e58c8b2d7fe0715f3e289d03ab8Bill Wendling    echo "# Testing - built with clang"
356a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
357a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling
358a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    ############################################################################
359a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    # Compare .o files between Phase2 and Phase3 and report which ones differ.
360a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    echo
361a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    echo "# Comparing Phase 2 and Phase 3 files"
362a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    for o in `find $llvmCore_phase2_objdir -name '*.o'` ; do
363a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        p3=`echo $o | sed -e 's,Phase2,Phase3,'`
364a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        if ! cmp --ignore-initial=16 $o $p3 > /dev/null 2>&1 ; then
365a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling            echo "file `basename $o` differs between phase 2 and phase 3"
366a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling        fi
367a854f5d6f9394212319f4e00b6396900f6e62864Bill Wendling    done
368b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdone
369f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands) 2>&1 | tee $LogDir/testing.$Release-rc$RC.log
370b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
371b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Woo hoo!
372b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingecho "### Testing Finished ###"
373f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sandsecho "### Logs: $LogDir"
374b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingexit 0
375