2 #===-- test-release.sh - Test the LLVM release candidates ------------------===#
4 # The LLVM Compiler Infrastructure
6 # This file is distributed under the University of Illinois Open Source
9 #===------------------------------------------------------------------------===#
11 # Download, build, and test the release candidate for an LLVM release.
13 #===------------------------------------------------------------------------===#
15 set -e # Exit if any command fails
17 projects="llvm cfe dragonegg test-suite compiler-rt libcxx libcxxabi"
19 # Base SVN URL for the sources.
20 Base_url="http://llvm.org/svn/llvm-project"
34 echo "usage: `basename $0` -release X.Y -rc NUM [OPTIONS]"
36 echo " -release X.Y The release number to test."
37 echo " -rc NUM The pre-release candidate number."
38 echo " -j NUM Number of compile jobs to run. [default: 3]"
39 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
40 echo " -no-checkout Don't checkout the sources from SVN."
41 echo " -no-64bit Don't test the 64-bit version. [default: yes]"
42 echo " -enable-ada Build Ada. [default: disable]"
43 echo " -enable-fortran Enable Fortran build. [default: disable]"
44 echo " -disable-objc Disable ObjC build. [default: enable]"
45 echo " -test-debug Test the debug build. [default: no]"
48 while [ $# -gt 0 ]; do
50 -release | --release )
53 Release_no_dot="`echo $1 | sed -e 's,\.,,'`"
55 -rc | --rc | -RC | --RC )
60 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
61 if [ -z "$NumJobs" ]; then
66 -build-dir | --build-dir | -builddir | --builddir )
70 -no-checkout | --no-checkout )
73 -no-64bit | --no-64bit )
76 -enable-ada | --enable-ada )
79 -enable-fortran | --enable-fortran )
82 -disable-objc | --disable-objc )
85 -test-debug | --test-debug )
88 -help | --help | -h | --h | -\? )
93 echo "unknown option: $1"
101 # Check required arguments.
102 if [ -z "$Release" ]; then
103 echo "error: no release number specified"
106 if [ -z "$RC" ]; then
107 echo "error: no release candidate number specified"
111 # Figure out how many make processes to run.
112 if [ -z "$NumJobs" ]; then
113 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
115 if [ -z "$NumJobs" ]; then
116 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
118 if [ -z "$NumJobs" ]; then
119 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
121 if [ -z "$NumJobs" ]; then
125 # Go to the build directory (may be different from CWD)
126 BuildDir=$BuildDir/rc$RC
130 # Location of log files.
131 LogDir=$BuildDir/logs
135 c_compiler="`which clang`"
136 if [ -z "$c_compiler" ]; then
137 c_compiler="`which gcc`"
138 if [ -z "$c_compiler" ]; then
139 c_compiler="`which cc`"
140 if [ -z "$c_compiler" ]; then
141 echo "error: cannot find a working C compiler"
145 cxx_compiler="`which clang++`"
146 if [ -z "$cxx_compiler" ]; then
147 cxx_compiler="`which g++`"
148 if [ -z "$cxx_compiler" ]; then
149 cxx_compiler="`which c++`"
150 if [ -z "$cxx_compiler" ]; then
151 echo "error: cannot find a working C++ compiler"
156 # Make sure that the URLs are valid.
157 function check_valid_urls() {
158 for proj in $projects ; do
159 echo "# Validating $proj SVN URL"
161 if ! svn ls $Base_url/tags/RELEASE_$Release_no_dot/rc$RC > /dev/null 2>&1 ; then
162 echo "llvm $Release release candidate $RC doesn't exist!"
168 # Export sources to the the build directory.
169 function export_sources() {
172 for proj in $projects ; do
173 echo "# Exporting $proj $Release-RC$RC sources"
174 if ! svn export -q $Base_url/$proj/tags/RELEASE_$Release_no_dot/rc$RC $proj.src ; then
175 echo "error: failed to export $proj project"
180 echo "# Creating symlinks"
181 cd $BuildDir/llvm.src/tools
182 if [ ! -h clang ]; then
183 ln -s $BuildDir/cfe.src clang
185 cd $BuildDir/llvm.src/projects
186 if [ ! -h llvm-test ]; then
187 ln -s $BuildDir/test-suite.src llvm-test
192 function configure_llvmCore() {
199 Release | Release-64 )
212 echo "# Invalid flavor '$Flavor'"
218 echo "# Using C compiler: $c_compiler"
219 echo "# Using C++ compiler: $cxx_compiler"
222 echo "# Configuring llvm $Release-rc$RC $Flavor"
223 echo "# $BuildDir/llvm.src/configure --prefix=$InstallDir \
224 --enable-optimized=$Optimized \
225 --enable-assertions=$Assertions"
226 env CC=$c_compiler CXX=$cxx_compiler \
227 $BuildDir/llvm.src/configure --prefix=$InstallDir \
228 --enable-optimized=$Optimized \
229 --enable-assertions=$Assertions \
230 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
234 function build_llvmCore() {
240 if [ "$Flavor" = "Release-64" ]; then
241 ExtraOpts="EXTRA_OPTIONS=-m64"
245 echo "# Compiling llvm $Release-rc$RC $Flavor"
246 echo "# make -j $NumJobs VERBOSE=1 $ExtraOpts"
247 make -j $NumJobs VERBOSE=1 $ExtraOpts \
248 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
250 echo "# Installing llvm $Release-rc$RC $Flavor"
251 echo "# make install"
253 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
257 function test_llvmCore() {
264 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log
266 2>&1 | tee $LogDir/llvm.unittests--Phase$Phase-$Flavor.log
270 if [ "$do_checkout" = "yes" ]; then
275 Flavors="Release Release+Asserts"
276 if [ "$do_debug" = "yes" ]; then
277 Flavors="Debug $Flavors"
279 if [ "$do_64bit" = "yes" ]; then
280 Flavors="$Flavors Release-64"
283 for Flavor in $Flavors ; do
286 echo "********************************************************************************"
287 echo " Release: $Release-rc$RC"
288 echo " Build: $Flavor"
289 echo " System Info: "
291 echo "********************************************************************************"
294 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.obj
295 llvmCore_phase1_installdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-rc$RC.install
297 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.obj
298 llvmCore_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-rc$RC.install
300 rm -rf $llvmCore_phase1_objdir
301 rm -rf $llvmCore_phase1_installdir
302 rm -rf $llvmCore_phase2_objdir
303 rm -rf $llvmCore_phase2_installdir
305 mkdir -p $llvmCore_phase1_objdir
306 mkdir -p $llvmCore_phase1_installdir
307 mkdir -p $llvmCore_phase2_objdir
308 mkdir -p $llvmCore_phase2_installdir
310 ############################################################################
311 # Phase 1: Build llvmCore and llvmgcc42
312 echo "# Phase 1: Building llvmCore"
313 configure_llvmCore 1 $Flavor \
314 $llvmCore_phase1_objdir $llvmCore_phase1_installdir
315 build_llvmCore 1 $Flavor \
316 $llvmCore_phase1_objdir
318 ############################################################################
319 # Phase 2: Build llvmCore with newly built clang from phase 1.
320 c_compiler=$llvmCore_phase1_installdir/bin/clang
321 cxx_compiler=$llvmCore_phase1_installdir/bin/clang++
322 echo "# Phase 2: Building llvmCore"
323 configure_llvmCore 2 $Flavor \
324 $llvmCore_phase2_objdir $llvmCore_phase2_installdir
325 build_llvmCore 2 $Flavor \
326 $llvmCore_phase2_objdir
328 echo "# Testing - built with clang"
329 test_llvmCore 2 $Flavor $llvmCore_phase2_objdir
331 ) 2>&1 | tee $LogDir/testing.$Release-rc$RC.log
334 echo "### Testing Finished ###"
335 echo "### Logs: $LogDir"