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 if [ `uname -s` = "FreeBSD" ]; then
21 projects="llvm cfe dragonegg compiler-rt libcxx test-suite clang-tools-extra"
23 # Base SVN URL for the sources.
24 Base_url="http://llvm.org/svn/llvm-project"
42 echo "usage: `basename $0` -release X.Y -rc NUM [OPTIONS]"
44 echo " -release X.Y The release number to test."
45 echo " -rc NUM The pre-release candidate number."
46 echo " -final The final release candidate."
47 echo " -j NUM Number of compile jobs to run. [default: 3]"
48 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
49 echo " -no-checkout Don't checkout the sources from SVN."
50 echo " -no-64bit Don't test the 64-bit version. [default: yes]"
51 echo " -enable-ada Build Ada. [default: disable]"
52 echo " -disable-clang Do not test clang. [default: enable]"
53 echo " -enable-dragonegg Test dragonegg. [default: disable]"
54 echo " -enable-fortran Enable Fortran build. [default: disable]"
55 echo " -disable-objc Disable ObjC build. [default: enable]"
56 echo " -test-debug Test the debug build. [default: no]"
57 echo " -test-asserts Test with asserts on. [default: no]"
58 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
61 while [ $# -gt 0 ]; do
63 -release | --release )
66 Release_no_dot="`echo $1 | sed -e 's,\.,,'`"
68 -rc | --rc | -RC | --RC )
76 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
77 if [ -z "$NumJobs" ]; then
82 -build-dir | --build-dir | -builddir | --builddir )
86 -no-checkout | --no-checkout )
89 -no-64bit | --no-64bit )
92 -enable-ada | --enable-ada )
95 -disable-clang | --disable-clang )
98 -enable-dragonegg | --enable-dragonegg )
101 -enable-fortran | --enable-fortran )
104 -disable-objc | --disable-objc )
107 -test-debug | --test-debug )
110 -test-asserts | --test-asserts )
113 -no-compare-files | --no-compare-files )
116 -help | --help | -h | --h | -\? )
121 echo "unknown option: $1"
129 # Check required arguments.
130 if [ -z "$Release" ]; then
131 echo "error: no release number specified"
134 if [ -z "$RC" ]; then
135 echo "error: no release candidate number specified"
139 # Figure out how many make processes to run.
140 if [ -z "$NumJobs" ]; then
141 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
143 if [ -z "$NumJobs" ]; then
144 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
146 if [ -z "$NumJobs" ]; then
147 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
149 if [ -z "$NumJobs" ]; then
153 # Go to the build directory (may be different from CWD)
154 BuildDir=$BuildDir/$RC
158 # Location of log files.
159 LogDir=$BuildDir/logs
163 if [ "$do_dragonegg" = "yes" ]; then
165 if [ -z "$gcc_compiler" ]; then
166 gcc_compiler="`which gcc`"
167 if [ -z "$gcc_compiler" ]; then
168 echo "error: cannot find gcc to use with dragonegg"
174 if [ -z "$gxx_compiler" ]; then
175 gxx_compiler="`which g++`"
176 if [ -z "$gxx_compiler" ]; then
177 echo "error: cannot find g++ to use with dragonegg"
183 # Make sure that a required program is available
184 function check_program_exists() {
186 if ! type -P $program > /dev/null 2>&1 ; then
187 echo "program '$1' not found !"
192 check_program_exists 'chrpath'
193 check_program_exists 'file'
194 check_program_exists 'objdump'
196 # Make sure that the URLs are valid.
197 function check_valid_urls() {
198 for proj in $projects ; do
199 echo "# Validating $proj SVN URL"
201 if ! svn ls $Base_url/$proj/tags/RELEASE_$Release_no_dot/$RC > /dev/null 2>&1 ; then
202 echo "llvm $Release release candidate $RC doesn't exist!"
208 # Export sources to the build directory.
209 function export_sources() {
212 for proj in $projects ; do
213 echo "# Exporting $proj $Release-RC$RC sources"
214 if ! svn export -q $Base_url/$proj/tags/RELEASE_$Release_no_dot/$RC $proj.src ; then
215 echo "error: failed to export $proj project"
220 echo "# Creating symlinks"
221 cd $BuildDir/llvm.src/tools
222 if [ ! -h clang ]; then
223 ln -s ../../cfe.src clang
225 cd $BuildDir/llvm.src/tools/clang/tools
226 if [ ! -h clang-tools-extra ]; then
227 ln -s ../../../../clang-tools-extra.src extra
229 cd $BuildDir/llvm.src/projects
230 if [ ! -h test-suite ]; then
231 ln -s ../../test-suite.src test-suite
233 if [ ! -h compiler-rt ]; then
234 ln -s ../../compiler-rt.src compiler-rt
236 if [ ! -h libcxx ]; then
237 ln -s ../../libcxx.src libcxx
242 function configure_llvmCore() {
249 Release | Release-64 )
262 echo "# Invalid flavor '$Flavor'"
268 echo "# Using C compiler: $c_compiler"
269 echo "# Using C++ compiler: $cxx_compiler"
272 echo "# Configuring llvm $Release-$RC $Flavor"
273 echo "# $BuildDir/llvm.src/configure --prefix=$InstallDir \
274 --enable-optimized=$Optimized \
275 --enable-assertions=$Assertions"
276 env CC="$c_compiler" CXX="$cxx_compiler" \
277 $BuildDir/llvm.src/configure --prefix=$InstallDir \
278 --enable-optimized=$Optimized \
279 --enable-assertions=$Assertions \
280 --disable-timestamps \
281 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
285 function build_llvmCore() {
291 if [ "$Flavor" = "Release-64" ]; then
292 ExtraOpts="EXTRA_OPTIONS=-m64"
296 echo "# Compiling llvm $Release-$RC $Flavor"
297 echo "# ${MAKE} -j $NumJobs VERBOSE=1 $ExtraOpts"
298 ${MAKE} -j $NumJobs VERBOSE=1 $ExtraOpts \
299 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
301 echo "# Installing llvm $Release-$RC $Flavor"
302 echo "# ${MAKE} install"
304 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
308 function build_dragonegg() {
313 LLVM_CONFIG=$LLVMInstallDir/bin/llvm-config
314 TOP_DIR=$BuildDir/dragonegg.src
316 echo "# Targeted compiler: $gcc_compiler"
319 echo "# Compiling phase $Phase dragonegg $Release-$RC $Flavor"
320 echo -n "# CXX=$cxx_compiler TOP_DIR=$TOP_DIR GCC=$gcc_compiler "
321 echo -n "LLVM_CONFIG=$LLVM_CONFIG ${MAKE} -f $TOP_DIR/Makefile "
322 echo "-j $NumJobs VERBOSE=1"
323 CXX="$cxx_compiler" TOP_DIR="$TOP_DIR" GCC="$gcc_compiler" \
324 LLVM_CONFIG="$LLVM_CONFIG" ${MAKE} -f $TOP_DIR/Makefile \
325 -j $NumJobs VERBOSE=1 \
326 2>&1 | tee $LogDir/dragonegg-Phase$Phase-$Flavor.log
330 function test_llvmCore() {
336 ${MAKE} -k check-all \
337 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log
338 ${MAKE} -k unittests \
339 2>&1 | tee $LogDir/llvm.unittests-Phase$Phase-$Flavor.log
343 # Clean RPATH. Libtool adds the build directory to the search path, which is
344 # not necessary --- and even harmful --- for the binary packages we release.
345 function clean_RPATH() {
346 local InstallPath="$1"
347 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
348 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
349 rpath=`objdump -x $Candidate | grep 'RPATH' | sed -e's/^ *RPATH *//'`
350 if [ -n "$rpath" ]; then
351 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
352 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
358 set -e # Exit if any command fails
360 if [ "$do_checkout" = "yes" ]; then
366 if [ "$do_debug" = "yes" ]; then
367 Flavors="Debug $Flavors"
369 if [ "$do_asserts" = "yes" ]; then
370 Flavors="$Flavors Release+Asserts"
372 if [ "$do_64bit" = "yes" ]; then
373 Flavors="$Flavors Release-64"
376 for Flavor in $Flavors ; do
379 echo "********************************************************************************"
380 echo " Release: $Release-$RC"
381 echo " Build: $Flavor"
382 echo " System Info: "
384 echo "********************************************************************************"
390 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
391 llvmCore_phase1_installdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
392 dragonegg_phase1_objdir=$BuildDir/Phase1/$Flavor/DragonEgg-$Release-$RC.obj
394 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
395 llvmCore_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
396 llvmCore_de_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-DragonEgg-$Release-$RC.obj
397 llvmCore_de_phase2_installdir=$BuildDir/Phase2/$Flavor/llvmCore-DragonEgg-$Release-$RC.install
398 dragonegg_phase2_objdir=$BuildDir/Phase2/$Flavor/DragonEgg-$Release-$RC.obj
400 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
401 llvmCore_phase3_installdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
402 llvmCore_de_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-DragonEgg-$Release-$RC.obj
403 llvmCore_de_phase3_installdir=$BuildDir/Phase3/$Flavor/llvmCore-DragonEgg-$Release-$RC.install
404 dragonegg_phase3_objdir=$BuildDir/Phase3/$Flavor/DragonEgg-$Release-$RC.obj
406 rm -rf $llvmCore_phase1_objdir
407 rm -rf $llvmCore_phase1_installdir
408 rm -rf $dragonegg_phase1_objdir
410 rm -rf $llvmCore_phase2_objdir
411 rm -rf $llvmCore_phase2_installdir
412 rm -rf $llvmCore_de_phase2_objdir
413 rm -rf $llvmCore_de_phase2_installdir
414 rm -rf $dragonegg_phase2_objdir
416 rm -rf $llvmCore_phase3_objdir
417 rm -rf $llvmCore_phase3_installdir
418 rm -rf $llvmCore_de_phase3_objdir
419 rm -rf $llvmCore_de_phase3_installdir
420 rm -rf $dragonegg_phase3_objdir
422 mkdir -p $llvmCore_phase1_objdir
423 mkdir -p $llvmCore_phase1_installdir
424 mkdir -p $dragonegg_phase1_objdir
426 mkdir -p $llvmCore_phase2_objdir
427 mkdir -p $llvmCore_phase2_installdir
428 mkdir -p $llvmCore_de_phase2_objdir
429 mkdir -p $llvmCore_de_phase2_installdir
430 mkdir -p $dragonegg_phase2_objdir
432 mkdir -p $llvmCore_phase3_objdir
433 mkdir -p $llvmCore_phase3_installdir
434 mkdir -p $llvmCore_de_phase3_objdir
435 mkdir -p $llvmCore_de_phase3_installdir
436 mkdir -p $dragonegg_phase3_objdir
438 ############################################################################
439 # Phase 1: Build llvmCore and clang
440 echo "# Phase 1: Building llvmCore"
441 configure_llvmCore 1 $Flavor \
442 $llvmCore_phase1_objdir $llvmCore_phase1_installdir
443 build_llvmCore 1 $Flavor \
444 $llvmCore_phase1_objdir
445 clean_RPATH $llvmCore_phase1_installdir
448 if [ "$do_clang" = "yes" ]; then
449 ########################################################################
450 # Phase 2: Build llvmCore with newly built clang from phase 1.
451 c_compiler=$llvmCore_phase1_installdir/bin/clang
452 cxx_compiler=$llvmCore_phase1_installdir/bin/clang++
453 echo "# Phase 2: Building llvmCore"
454 configure_llvmCore 2 $Flavor \
455 $llvmCore_phase2_objdir $llvmCore_phase2_installdir
456 build_llvmCore 2 $Flavor \
457 $llvmCore_phase2_objdir
458 clean_RPATH $llvmCore_phase2_installdir
460 ########################################################################
461 # Phase 3: Build llvmCore with newly built clang from phase 2.
462 c_compiler=$llvmCore_phase2_installdir/bin/clang
463 cxx_compiler=$llvmCore_phase2_installdir/bin/clang++
464 echo "# Phase 3: Building llvmCore"
465 configure_llvmCore 3 $Flavor \
466 $llvmCore_phase3_objdir $llvmCore_phase3_installdir
467 build_llvmCore 3 $Flavor \
468 $llvmCore_phase3_objdir
469 clean_RPATH $llvmCore_phase3_installdir
471 ########################################################################
472 # Testing: Test phase 3
473 echo "# Testing - built with clang"
474 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
476 ########################################################################
477 # Compare .o files between Phase2 and Phase3 and report which ones
479 if [ "$do_compare" = "yes" ]; then
481 echo "# Comparing Phase 2 and Phase 3 files"
482 for o in `find $llvmCore_phase2_objdir -name '*.o'` ; do
483 p3=`echo $o | sed -e 's,Phase2,Phase3,'`
484 if ! cmp --ignore-initial=16 $o $p3 > /dev/null 2>&1 ; then
485 echo "file `basename $o` differs between phase 2 and phase 3"
492 if [ "$do_dragonegg" = "yes" ]; then
493 # Build dragonegg using the targeted gcc. This isn't necessary, but
494 # helps avoid using broken versions of gcc (which are legion), tests
495 # that the targeted gcc is basically sane and is consistent with the
496 # later phases in which the targeted gcc + dragonegg are used.
497 c_compiler="$gcc_compiler"
498 cxx_compiler="$gxx_compiler"
499 build_dragonegg 1 $Flavor $llvmCore_phase1_installdir $dragonegg_phase1_objdir
501 ########################################################################
502 # Phase 2: Build llvmCore with newly built dragonegg from phase 1.
503 c_compiler="$gcc_compiler -fplugin=$dragonegg_phase1_objdir/dragonegg.so"
504 cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase1_objdir/dragonegg.so"
505 echo "# Phase 2: Building llvmCore with dragonegg"
506 configure_llvmCore 2 $Flavor \
507 $llvmCore_de_phase2_objdir $llvmCore_de_phase2_installdir
508 build_llvmCore 2 $Flavor \
509 $llvmCore_de_phase2_objdir
510 build_dragonegg 2 $Flavor $llvmCore_de_phase2_installdir $dragonegg_phase2_objdir
511 clean_RPATH $llvmCore_de_phase2_installdir
513 ########################################################################
514 # Phase 3: Build llvmCore with newly built dragonegg from phase 2.
515 c_compiler="$gcc_compiler -fplugin=$dragonegg_phase2_objdir/dragonegg.so"
516 cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase2_objdir/dragonegg.so"
517 echo "# Phase 3: Building llvmCore with dragonegg"
518 configure_llvmCore 3 $Flavor \
519 $llvmCore_de_phase3_objdir $llvmCore_de_phase3_installdir
520 build_llvmCore 3 $Flavor \
521 $llvmCore_de_phase3_objdir
522 build_dragonegg 3 $Flavor $llvmCore_de_phase3_installdir $dragonegg_phase3_objdir
523 clean_RPATH $llvmCore_de_phase3_installdir
525 ########################################################################
526 # Testing: Test phase 3
527 c_compiler="$gcc_compiler -fplugin=$dragonegg_phase3_objdir/dragonegg.so"
528 cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase3_objdir/dragonegg.so"
529 echo "# Testing - built with dragonegg"
530 test_llvmCore 3 $Flavor $llvmCore_de_phase3_objdir
532 ########################################################################
533 # Compare .o files between Phase2 and Phase3 and report which ones differ.
535 echo "# Comparing Phase 2 and Phase 3 files"
536 for o in `find $llvmCore_de_phase2_objdir -name '*.o'` \
537 `find $dragonegg_phase2_objdir -name '*.o'` ; do
538 p3=`echo $o | sed -e 's,Phase2,Phase3,'`
539 if ! cmp --ignore-initial=16 $o $p3 > /dev/null 2>&1 ; then
540 echo "file `basename $o` differs between dragonegg phase 2 and phase 3"
545 # Otherwise just test the core.
546 if [ "$do_clang" != "yes" -a "$do_dragonegg" != "yes" ]; then
547 echo "# Testing - built with system compiler"
548 test_llvmCore 1 $Flavor $llvmCore_phase1_objdir
551 ) 2>&1 | tee $LogDir/testing.$Release-$RC.log
556 echo "### Testing Finished ###"
557 echo "### Logs: $LogDir"