test-release.sh revision f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dc
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
17b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRelease=""
18b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRelease_no_dot=""
19b91c71299a819e2d20786b629376f119085e8b28Bill WendlingRC=""
20b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_checkout="yes"
21b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_ada="no"
22c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendlingdo_objc="yes"
23b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_fortran="yes"
24b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdo_64bit="yes"
25b91c71299a819e2d20786b629376f119085e8b28Bill WendlingBuildDir="`pwd`"
26b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
27b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction usage() {
28b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "usage: `basename $0` -release X.Y -rc NUM [OPTIONS]"
29b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
30b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -release X.Y      The release number to test."
31b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -rc NUM           The pre-release candidate number."
32b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -j NUM            Number of compile jobs to run. [default: 3]"
33b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -build-dir DIR    Directory to perform testing in. [default: pwd]"
34b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -no-checkout      Don't checkout the sources from SVN."
35b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo " -no-64bit         Don't test the 64-bit version. [default: yes]"
36e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling    echo " -enable-ada       Build Ada. [default: disable]"
37e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling    echo " -disable-objc     Disable ObjC build. [default: enable]"
38e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling    echo " -disable-fortran  Disable Fortran build. [default: enable]"
39b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
40b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
41b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingwhile [ $# -gt 0 ]; do
42b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    case $1 in
43b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -release | --release )
44b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
45b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Release="$1"
46b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Release_no_dot="`echo $1 | sed -e 's,\.,,'`"
47b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
48b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -rc | --rc | -RC | --RC )
49b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
50b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            RC=$1
51b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
52b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -j* )
53b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
54b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            if [ -z "$NumJobs" ]; then
55b91c71299a819e2d20786b629376f119085e8b28Bill Wendling                shift
56b91c71299a819e2d20786b629376f119085e8b28Bill Wendling                NumJobs="$1"
57b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            fi
58b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
59b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -build-dir | --build-dir | -builddir | --builddir )
60b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            shift
61b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            BuildDir="$1"
62b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
63b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -no-checkout | --no-checkout )
64b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_checkout="no"
65b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
66b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -no-64bit | --no-64bit )
67b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_64bit="no"
68b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
69e7e9a60df6ea92460337569e24746f390cbd56e3Bill Wendling        -enable-ada | --enable-ada )
70b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_ada="yes"
71b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
72c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling        -disable-objc | --disable-objc )
73c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling            do_objc="no"
74c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling            ;;
75b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -disable-fortran | --disable-fortran )
76b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo "WARNING: Do you *really* need to disable Fortran?"
77b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            sleep 5
78b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            do_fortran="no"
79b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
80b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        -help | --help | -h | --h | -\? )
81b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            usage
82b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            exit 0
83b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
84b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        * )
85b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo "unknown option: $1"
86b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            usage
87b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            exit 1
88b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
89b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    esac
90b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    shift
91b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdone
92b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
93b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Check required arguments.
94b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$Release" ]; then
95b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "No release number specified!"
96b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    exit 1
97b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
98b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$RC" ]; then
99b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "No release candidate number specified!"
100b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    exit 1
101b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
102b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
103d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands# Figure out how many make processes to run.
104d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
105d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
106d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
107d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
108d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
109d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
110d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsif [ -z "$NumJobs" ]; then
111d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sands    NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
112d357d747ded75c3eae9238f23e1c05d621d915e8Duncan Sandsfi
113b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ -z "$NumJobs" ]; then
114b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    NumJobs=3
115b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
116b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
117b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Location of sources.
118b91c71299a819e2d20786b629376f119085e8b28Bill WendlingllvmCore_srcdir=$BuildDir/llvmCore-$Release-rc$RC.src
119b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingllvmgcc42_srcdir=$BuildDir/llvmgcc42-$Release-rc$RC.src
120b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
121f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands# Location of log files.
122f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan SandsLogDirName="$Release-rc$RC.logs"
123f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan SandsLogDir=$BuildDir/$LogDirName
124f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sandsmkdir -p $LogDir
125f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands
126b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# SVN URLs for the sources.
127b91c71299a819e2d20786b629376f119085e8b28Bill WendlingBase_url="http://llvm.org/svn/llvm-project"
128b91c71299a819e2d20786b629376f119085e8b28Bill WendlingllvmCore_RC_url="$Base_url/llvm/tags/RELEASE_$Release_no_dot/rc$RC"
129b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingllvmgcc42_RC_url="$Base_url/llvm-gcc-4.2/tags/RELEASE_$Release_no_dot/rc$RC"
130b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingclang_RC_url="$Base_url/cfe/tags/RELEASE_$Release_no_dot/rc$RC"
131b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingtest_suite_RC_url="$Base_url/test-suite/tags/RELEASE_$Release_no_dot/rc$RC"
132b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
133b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Make sure that the URLs are valid.
134b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction check_valid_urls() {
135b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Validating SVN URLs"
136b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if ! svn ls $llvmCore_RC_url > /dev/null 2>&1 ; then
137b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        echo "llvm $Release release candidate $RC doesn't exist!"
138b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        exit 1
139b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
140b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if ! svn ls $llvmgcc42_RC_url > /dev/null 2>&1 ; then
141b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        echo "llvm-gcc-4.2 $Release release candidate $RC doesn't exist!"
142b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        exit 1
143b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
144b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if ! svn ls $clang_RC_url > /dev/null 2>&1 ; then
145b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        echo "clang $Release release candidate $RC doesn't exist!"
146b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        exit 1
147b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
148b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if ! svn ls $test_suite_RC_url > /dev/null 2>&1 ; then
149b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        echo "test-suite $Release release candidate $RC doesn't exist!"
150b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        exit 1
151b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
152b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
153b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
154b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Export sources to the the build directory.
155b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction export_sources() {
156b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    check_valid_urls
157b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
158b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Exporting llvm $Release-RC$RC sources"
159b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    svn export -q $llvmCore_RC_url $llvmCore_srcdir
160b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Exporting llvm-gcc-4.2 $Release-rc$RC  sources"
161b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    svn export -q $llvmgcc42_RC_url $llvmgcc42_srcdir
162b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Exporting clang $Release-rc$RC sources"
163b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    svn export -q $clang_RC_url $llvmCore_srcdir/tools/clang
164b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Exporting llvm test suite $Release-rc$RC sources"
165b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    svn export -q $test_suite_RC_url $llvmCore_srcdir/projects/llvm-test
166b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
167b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
168b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction configure_llvmCore() {
169b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
170b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
171b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
172b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    InstallDir="$4"
173b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgccDir="$5"
174b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
175b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    case $Flavor in
176b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        Release | Release-64 )
177b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="yes"
1788a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands            Assertions="no"
179b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
1808a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands        Release+Asserts )
181b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="yes"
1828a6e53e1162663dd2bc1da783fe2ff5947fba9e0Duncan Sands            Assertions="yes"
183b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
184b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        Debug )
185b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Optimized="no"
186b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            Assertions="yes"
187b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
188b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        * )
189b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo "# Invalid flavor $Flavor!"
190b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            echo ""
191b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            return
192b91c71299a819e2d20786b629376f119085e8b28Bill Wendling            ;;
193b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    esac
194b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
195b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
196b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Configuring llvm $Release-rc$RC $Flavor"
197cff1dbfa186b2d69237392f0064fe543e10ff119Duncan Sands    echo "# $llvmCore_srcdir/configure --prefix=$InstallDir \
198b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-optimized=$Optimized \
199b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-assertions=$Assertions \
200b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --with-llvmgccdir=$llvmgccDir"
201b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    $llvmCore_srcdir/configure --prefix=$InstallDir \
202b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-optimized=$Optimized \
203b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --enable-assertions=$Assertions \
204f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        --with-llvmgccdir=$llvmgccDir \
205f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm.configure.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
206b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd -
207b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
208b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
209b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction build_llvmCore() {
210b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
211b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
212b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
213b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ExtraOpts=""
214b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
215b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    CompilerFlags=""
216b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$Phase" = "2" ]; then
217b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        CompilerFlags="CC=$llvmgccDir/bin/llvm-gcc CXX=$llvmgccDir/bin/llvm-g++"
218b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
219b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$Flavor" = "Release-64" ]; then
220b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        ExtraOpts="EXTRA_OPTIONS=-m64"
221b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
222b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
223b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
224b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Compiling llvm $Release-rc$RC $Flavor"
225b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make -j $NumJobs VERBOSE=1 $ExtraOpts"
226f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make -j $NumJobs VERBOSE=1 $ExtraOpts $CompilerFlags \
227f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm.make.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
228b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
229b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Installing llvm $Release-rc$RC $Flavor"
230b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make install"
231f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make install \
232f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm.install.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
233b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd -
234b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
235b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
236b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction test_llvmCore() {
237b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
238b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
239b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
240b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
241b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
242f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make check \
243f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm.check.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
244f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make -C tools/clang test \
245f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/clang.check.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
246f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make unittests \
247f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm.unittests.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
248b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd -
249b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
250b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
251b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction configure_llvm_gcc() {
252b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
253b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
254b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
255b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    InstallDir="$4"
256b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmObjDir="$5"
257b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
258c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling    languages="c,c++"
259c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling    if [ "$do_objc" = "yes" ]; then
260c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling        languages="$languages,objc,obj-c++"
261c248bbab04cb674bde5de8d6e2b2736a574fa0f8Bill Wendling    fi
262b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$do_fortran" = "yes" ]; then
263b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        languages="$languages,fortran"
264b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
265b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$do_ada" = "yes" ]; then
266b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        languages="$languages,ada"
267b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
268b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
269b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
270b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Configuring llvm-gcc $Release-rc$RC $Flavor"
271b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# $llvmgcc42_srcdir/configure --prefix=$InstallDir \
272b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --program-prefix=llvm- --enable-llvm=$llvmObjDir \
2738be4e032bd178d825bf28a7eeb39e5390cc7a507Bill Wendling        --enable-languages=$languages"
274b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    $llvmgcc42_srcdir/configure --prefix=$InstallDir \
275b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        --program-prefix=llvm- --enable-llvm=$llvmObjDir \
276f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        --enable-languages=$languages \
277f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm-gcc.configure.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
278b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd -
279b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
280b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
281b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfunction build_llvm_gcc() {
282b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Phase="$1"
283b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavor="$2"
284b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ObjDir="$3"
285b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgccDir="$4"
286b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
287b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    CompilerFlags=""
288b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    if [ "$Phase" = "2" ]; then
289b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        CompilerFlags="CC=$llvmgccDir/bin/llvm-gcc CXX=$llvmgccDir/bin/llvm-g++"
290b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    fi
291b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
292b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd $ObjDir
293b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Compiling llvm-gcc $Release-rc$RC $Flavor"
294b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make -j $NumJobs bootstrap LLVM_VERSION_INFO=$Release"
295f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make -j $NumJobs bootstrap LLVM_VERSION_INFO=$Release $CompilerFlags \
296f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm-gcc.make.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
297b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
298b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Installing llvm-gcc $Release-rc$RC $Flavor"
299b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# make install"
300f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands    make install \
301f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands        > $LogDir/llvm-gcc.install.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1
302b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    cd -
303b91c71299a819e2d20786b629376f119085e8b28Bill Wendling}
304b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
305b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ "$do_checkout" = "yes" ]; then
306b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    export_sources
307b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
308b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
309f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands(
31040989a40f085ca027ba322fbcffc771cb360e854Duncan SandsFlavors="Debug Release Release+Asserts"
311b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingif [ "$do_64bit" = "yes" ]; then
312b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    Flavors="$Flavors Release-64"
313b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfi
314b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
315b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingfor Flavor in $Flavors ; do
316b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
317b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
318b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "********************************************************************************"
319b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  Release:     $Release-rc$RC"
320b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  Build:       $Flavor"
321b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "  System Info: "
322b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "    `uname -a`"
323b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "********************************************************************************"
324b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo ""
325b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
326b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.obj
327b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase1_installdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.install
328b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
329b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.obj
330b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmCore_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.install
331b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
332b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase1_objdir
333b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase1_installdir
334b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase2_objdir
335b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmCore_phase2_installdir
336b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
337b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase1_objdir
338b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase1_installdir
339b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase2_objdir
340b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmCore_phase2_installdir
341b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
342b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgcc42_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmgcc42-$Release-rc$RC.obj
343b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgcc42_phase1_installdir=$BuildDir/Phase1/$Flavor/llvmgcc42-$Release-rc$RC.install
344b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
345b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgcc42_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmgcc42-$Release-rc$RC.obj
346b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    llvmgcc42_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmgcc42-$Release-rc$RC.install
347b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
348b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmgcc42_phase1_objdir
349b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmgcc42_phase1_installdir
350b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmgcc42_phase2_objdir
351b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    rm -rf $llvmgcc42_phase2_installdir
352b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
353b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmgcc42_phase1_objdir
354b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmgcc42_phase1_installdir
355b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmgcc42_phase2_objdir
356b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    mkdir -p $llvmgcc42_phase2_installdir
357b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
358b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ############################################################################
359b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    # Phase 1: Build llvmCore and llvmgcc42
360b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 1: Building llvmCore"
361b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvmCore 1 $Flavor \
362b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase1_objdir $llvmCore_phase1_installdir \
363b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase1_installdir
364b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvmCore 1 $Flavor \
365b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase1_objdir
366b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
367b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 1: Building llvmgcc42"
368b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvm_gcc 1 $Flavor \
369b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase1_objdir $llvmgcc42_phase1_installdir \
370b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase1_objdir
371b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvm_gcc 1 $Flavor \
372b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase1_objdir $llvmgcc42_phase1_installdir
373b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
374b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    ############################################################################
375b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    # Phase 2: Build llvmCore with newly built llvmgcc42 from phase 1.
376b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 2: Building llvmCore"
377b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvmCore 2 $Flavor \
378b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase2_objdir $llvmCore_phase2_installdir \
379b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase1_installdir
380b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvmCore 2 $Flavor \
381b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase2_objdir
382b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
383b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Phase 2: Building llvmgcc42"
384b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    configure_llvm_gcc 2 $Flavor \
385b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase2_objdir $llvmgcc42_phase2_installdir \
386b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmCore_phase2_objdir
387b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    build_llvm_gcc 2 $Flavor \
388b91c71299a819e2d20786b629376f119085e8b28Bill Wendling        $llvmgcc42_phase2_objdir $llvmgcc42_phase1_installdir
389b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
390b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    echo "# Testing - built with llvmgcc42"
391b91c71299a819e2d20786b629376f119085e8b28Bill Wendling    test_llvmCore 2 $Flavor $llvmCore_phase2_objdir
392b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingdone
393f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sands) 2>&1 | tee $LogDir/testing.$Release-rc$RC.log
394b91c71299a819e2d20786b629376f119085e8b28Bill Wendling
395b91c71299a819e2d20786b629376f119085e8b28Bill Wendling# Woo hoo!
396b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingecho "### Testing Finished ###"
397f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dcDuncan Sandsecho "### Logs: $LogDir"
398b91c71299a819e2d20786b629376f119085e8b28Bill Wendlingexit 0
399