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 #===------------------------------------------------------------------------===#
16 if [ "$System" = "FreeBSD" ]; then
22 # Base SVN URL for the sources.
23 Base_url
="http://llvm.org/svn/llvm-project"
44 ExtraConfigureFlags
=""
48 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
50 echo " -release X.Y.Z The release version to test."
51 echo " -rc NUM The pre-release candidate number."
52 echo " -final The final release candidate."
53 echo " -triple TRIPLE The target triple for this machine."
54 echo " -j NUM Number of compile jobs to run. [default: 3]"
55 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
56 echo " -no-checkout Don't checkout the sources from SVN."
57 echo " -test-debug Test the debug build. [default: no]"
58 echo " -test-asserts Test with asserts on. [default: no]"
59 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
60 echo " -use-gzip Use gzip instead of xz."
61 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
62 echo " -svn-path DIR Use the specified DIR instead of a release."
63 echo " For example -svn-path trunk or -svn-path branches/release_37"
64 echo " -no-rt Disable check-out & build Compiler-RT"
65 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
66 echo " -no-libcxxabi Disable check-out & build libcxxabi"
67 echo " -no-libunwind Disable check-out & build libunwind"
68 echo " -no-test-suite Disable check-out & build test-suite"
69 echo " -no-openmp Disable check-out & build libomp"
70 echo " -no-lld Disable check-out & build lld"
71 echo " -lldb Enable check-out & build lldb"
72 echo " -no-lldb Disable check-out & build lldb (default)"
73 echo " -no-polly Disable check-out & build Polly"
76 while [ $# -gt 0 ]; do
78 -release |
--release )
81 Release_no_dot
="`echo $1 | sed -e 's,\.,,g'`"
83 -rc |
--rc |
-RC |
--RC )
90 -svn-path |
--svn-path )
95 RC
="`echo $ExportBranch | sed -e 's,/,_,g'`"
96 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
97 echo " This is intended to aid new packagers in trialing "
98 echo " builds without requiring a tag to be created first"
104 -configure-flags |
--configure-flags )
106 ExtraConfigureFlags
="$1"
109 NumJobs
="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
110 if [ -z "$NumJobs" ]; then
115 -build-dir |
--build-dir |
-builddir |
--builddir )
119 -no-checkout |
--no-checkout )
122 -test-debug |
--test-debug )
125 -test-asserts |
--test-asserts )
128 -no-compare-files |
--no-compare-files )
131 -use-gzip |
--use-gzip )
164 -help |
--help |
-h |
--h |
-\? )
169 echo "unknown option: $1"
177 # Check required arguments.
178 if [ -z "$Release" ]; then
179 echo "error: no release number specified"
182 if [ -z "$RC" ]; then
183 echo "error: no release candidate number specified"
186 if [ -z "$ExportBranch" ]; then
187 ExportBranch
="tags/RELEASE_$Release_no_dot/$RC"
189 if [ -z "$Triple" ]; then
190 echo "error: no target triple specified"
194 # Figure out how many make processes to run.
195 if [ -z "$NumJobs" ]; then
196 NumJobs
=`sysctl -n hw.activecpu 2> /dev/null || true`
198 if [ -z "$NumJobs" ]; then
199 NumJobs
=`sysctl -n hw.ncpu 2> /dev/null || true`
201 if [ -z "$NumJobs" ]; then
202 NumJobs
=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
204 if [ -z "$NumJobs" ]; then
209 projects
="llvm cfe clang-tools-extra"
210 if [ $do_rt = "yes" ]; then
211 projects
="$projects compiler-rt"
213 if [ $do_libs = "yes" ]; then
214 projects
="$projects libcxx"
215 if [ $do_libcxxabi = "yes" ]; then
216 projects
="$projects libcxxabi"
218 if [ $do_libunwind = "yes" ]; then
219 projects
="$projects libunwind"
222 case $do_test_suite in
224 projects
="$projects test-suite"
227 if [ $do_openmp = "yes" ]; then
228 projects
="$projects openmp"
230 if [ $do_lld = "yes" ]; then
231 projects
="$projects lld"
233 if [ $do_lldb = "yes" ]; then
234 projects
="$projects lldb"
236 if [ $do_polly = "yes" ]; then
237 projects
="$projects polly"
240 # Go to the build directory (may be different from CWD)
241 BuildDir
=$BuildDir/$RC
245 # Location of log files.
246 LogDir
=$BuildDir/logs
249 # Final package name.
250 Package
=clang
+llvm-
$Release
251 if [ $RC != "final" ]; then
254 Package
=$Package-$Triple
256 # Errors to be highlighted at the end are written to this file.
257 echo -n > $LogDir/deferred_errors.log
259 function deferred_error
() {
263 echo "[${Flavor} Phase${Phase}] ${Msg}" |
tee -a $LogDir/deferred_errors.log
266 # Make sure that a required program is available
267 function check_program_exists
() {
269 if ! type -P $program > /dev
/null
2>&1 ; then
270 echo "program '$1' not found !"
275 if [ "$System" != "Darwin" ]; then
276 check_program_exists
'chrpath'
277 check_program_exists
'file'
278 check_program_exists
'objdump'
281 # Make sure that the URLs are valid.
282 function check_valid_urls
() {
283 for proj
in $projects ; do
284 echo "# Validating $proj SVN URL"
286 if ! svn
ls $Base_url/$proj/$ExportBranch > /dev
/null
2>&1 ; then
287 echo "$proj does not have a $ExportBranch branch/tag!"
293 # Export sources to the build directory.
294 function export_sources
() {
297 for proj
in $projects ; do
303 projsrc
=llvm.src
/tools
/clang
306 projsrc
=llvm.src
/tools
/$proj
309 projsrc
=llvm.src
/tools
/clang
/tools
/extra
311 compiler-rt|libcxx|libcxxabi|libunwind|openmp
)
312 projsrc
=llvm.src
/projects
/$proj
318 echo "error: unknown project $proj"
323 if [ -d $projsrc ]; then
324 echo "# Reusing $proj $Release-$RC sources in $projsrc"
327 echo "# Exporting $proj $Release-$RC sources to $projsrc"
328 if ! svn
export -q $Base_url/$proj/$ExportBranch $projsrc ; then
329 echo "error: failed to export $proj project"
337 function configure_llvmCore
() {
356 echo "# Invalid flavor '$Flavor'"
362 echo "# Using C compiler: $c_compiler"
363 echo "# Using C++ compiler: $cxx_compiler"
366 echo "# Configuring llvm $Release-$RC $Flavor"
368 echo "#" env CC
="$c_compiler" CXX
="$cxx_compiler" \
369 cmake
-G "Unix Makefiles" \
370 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
371 $ExtraConfigureFlags $BuildDir/llvm.src \
372 2>&1 |
tee $LogDir/llvm.configure-Phase
$Phase-$Flavor.log
373 env CC
="$c_compiler" CXX
="$cxx_compiler" \
374 cmake
-G "Unix Makefiles" \
375 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
376 $ExtraConfigureFlags $BuildDir/llvm.src \
377 2>&1 |
tee $LogDir/llvm.configure-Phase
$Phase-$Flavor.log
382 function build_llvmCore
() {
389 echo "# Compiling llvm $Release-$RC $Flavor"
390 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
391 ${MAKE} -j $NumJobs VERBOSE
=1 \
392 2>&1 |
tee $LogDir/llvm.make-Phase
$Phase-$Flavor.log
394 echo "# Installing llvm $Release-$RC $Flavor"
395 echo "# ${MAKE} install"
397 DESTDIR
="${DestDir}" \
398 2>&1 |
tee $LogDir/llvm.install-Phase
$Phase-$Flavor.log
402 function test_llvmCore
() {
408 if ! ( ${MAKE} -j $NumJobs -k check-all \
409 2>&1 |
tee $LogDir/llvm.check-Phase
$Phase-$Flavor.log
) ; then
410 deferred_error
$Phase $Flavor "check-all failed"
413 if [ $do_test_suite = 'yes' ]; then
414 cd $TestSuiteBuildDir
415 env CC
="$c_compiler" CXX
="$cxx_compiler" \
416 cmake
$TestSuiteSrcDir -DTEST_SUITE_LIT=$Lit
417 if ! ( ${MAKE} -j $NumJobs -k check \
418 2>&1 |
tee $LogDir/llvm.check-Phase
$Phase-$Flavor.log
) ; then
419 deferred_error
$Phase $Flavor "test suite failed"
425 # Clean RPATH. Libtool adds the build directory to the search path, which is
426 # not necessary --- and even harmful --- for the binary packages we release.
427 function clean_RPATH
() {
428 if [ "$System" = "Darwin" ]; then
431 local InstallPath
="$1"
432 for Candidate
in `find $InstallPath/{bin,lib} -type f`; do
433 if file $Candidate |
grep ELF |
egrep 'executable|shared object' > /dev
/null
2>&1 ; then
434 if rpath
=`objdump -x $Candidate | grep 'RPATH'` ; then
435 rpath
=`echo $rpath | sed -e's/^ *RPATH *//'`
436 if [ -n "$rpath" ]; then
437 newrpath
=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
438 chrpath
-r $newrpath $Candidate 2>&1 > /dev
/null
2>&1
445 # Create a package of the release binaries.
446 function package_release
() {
448 cd $BuildDir/Phase
3/Release
449 mv llvmCore-
$Release-$RC.install
/usr
/local $Package
450 if [ "$use_gzip" = "yes" ]; then
451 tar cfz
$BuildDir/$Package.
tar.gz
$Package
453 tar cfJ
$BuildDir/$Package.
tar.xz
$Package
455 mv $Package llvmCore-
$Release-$RC.install
/usr
/local
459 # Exit if any command fails
460 # Note: pipefail is necessary for running build commands through
461 # a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
465 if [ "$do_checkout" = "yes" ]; then
469 # Setup the test-suite. Do this early so we can catch failures before
470 # we do the full 3 stage build.
471 if [ $do_test_suite = "yes" ]; then
472 SandboxDir
="$BuildDir/sandbox"
473 Lit
=$SandboxDir/bin
/lit
474 TestSuiteBuildDir
="$BuildDir/test-suite-build"
475 TestSuiteSrcDir
="$BuildDir/test-suite.src"
477 virtualenv
$SandboxDir
478 $SandboxDir/bin
/python
$BuildDir/llvm.src
/utils
/lit
/setup.py
install
479 mkdir
-p $TestSuiteBuildDir
484 if [ "$do_debug" = "yes" ]; then
485 Flavors
="Debug $Flavors"
487 if [ "$do_asserts" = "yes" ]; then
488 Flavors
="$Flavors Release+Asserts"
491 for Flavor
in $Flavors ; do
494 echo "********************************************************************************"
495 echo " Release: $Release-$RC"
496 echo " Build: $Flavor"
497 echo " System Info: "
499 echo "********************************************************************************"
504 llvmCore_phase1_objdir
=$BuildDir/Phase
1/$Flavor/llvmCore-
$Release-$RC.obj
505 llvmCore_phase1_destdir
=$BuildDir/Phase
1/$Flavor/llvmCore-
$Release-$RC.
install
507 llvmCore_phase2_objdir
=$BuildDir/Phase
2/$Flavor/llvmCore-
$Release-$RC.obj
508 llvmCore_phase2_destdir
=$BuildDir/Phase
2/$Flavor/llvmCore-
$Release-$RC.
install
510 llvmCore_phase3_objdir
=$BuildDir/Phase
3/$Flavor/llvmCore-
$Release-$RC.obj
511 llvmCore_phase3_destdir
=$BuildDir/Phase
3/$Flavor/llvmCore-
$Release-$RC.
install
513 rm -rf $llvmCore_phase1_objdir
514 rm -rf $llvmCore_phase1_destdir
516 rm -rf $llvmCore_phase2_objdir
517 rm -rf $llvmCore_phase2_destdir
519 rm -rf $llvmCore_phase3_objdir
520 rm -rf $llvmCore_phase3_destdir
522 mkdir
-p $llvmCore_phase1_objdir
523 mkdir
-p $llvmCore_phase1_destdir
525 mkdir
-p $llvmCore_phase2_objdir
526 mkdir
-p $llvmCore_phase2_destdir
528 mkdir
-p $llvmCore_phase3_objdir
529 mkdir
-p $llvmCore_phase3_destdir
531 ############################################################################
532 # Phase 1: Build llvmCore and clang
533 echo "# Phase 1: Building llvmCore"
534 configure_llvmCore
1 $Flavor $llvmCore_phase1_objdir
535 build_llvmCore
1 $Flavor \
536 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
537 clean_RPATH
$llvmCore_phase1_destdir/usr
/local
539 ########################################################################
540 # Phase 2: Build llvmCore with newly built clang from phase 1.
541 c_compiler
=$llvmCore_phase1_destdir/usr
/local
/bin
/clang
542 cxx_compiler
=$llvmCore_phase1_destdir/usr
/local
/bin
/clang
++
543 echo "# Phase 2: Building llvmCore"
544 configure_llvmCore
2 $Flavor $llvmCore_phase2_objdir
545 build_llvmCore
2 $Flavor \
546 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
547 clean_RPATH
$llvmCore_phase2_destdir/usr
/local
549 ########################################################################
550 # Phase 3: Build llvmCore with newly built clang from phase 2.
551 c_compiler
=$llvmCore_phase2_destdir/usr
/local
/bin
/clang
552 cxx_compiler
=$llvmCore_phase2_destdir/usr
/local
/bin
/clang
++
553 echo "# Phase 3: Building llvmCore"
554 configure_llvmCore
3 $Flavor $llvmCore_phase3_objdir
555 build_llvmCore
3 $Flavor \
556 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
557 clean_RPATH
$llvmCore_phase3_destdir/usr
/local
559 ########################################################################
560 # Testing: Test phase 3
561 c_compiler
=$llvmCore_phase3_destdir/usr
/local
/bin
/clang
562 cxx_compiler
=$llvmCore_phase3_destdir/usr
/local
/bin
/clang
++
563 echo "# Testing - built with clang"
564 test_llvmCore
3 $Flavor $llvmCore_phase3_objdir
566 ########################################################################
567 # Compare .o files between Phase2 and Phase3 and report which ones
569 if [ "$do_compare" = "yes" ]; then
571 echo "# Comparing Phase 2 and Phase 3 files"
572 for p2
in `find $llvmCore_phase2_objdir -name '*.o'` ; do
573 p3
=`echo $p2 | sed -e 's,Phase2,Phase3,'`
574 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
575 # case there are build paths in the debug info. On some systems,
576 # sed adds a newline to the output, so pass $p3 through sed too.
578 <(env LC_CTYPE
=C
sed -e 's,Phase2,Phase3,g' -e 's,Phase1,Phase2,g' $p2) \
579 <(env LC_CTYPE
=C
sed -e '' $p3) 16 16; then
580 echo "file `basename $p2` differs between phase 2 and phase 3"
586 ) 2>&1 |
tee $LogDir/testing.
$Release-$RC.log
588 if [ "$use_gzip" = "yes" ]; then
589 echo "# Packaging the release as $Package.tar.gz"
591 echo "# Packaging the release as $Package.tar.xz"
598 echo "### Testing Finished ###"
599 echo "### Logs: $LogDir"
602 if [ -s "$LogDir/deferred_errors.log" ]; then
603 cat "$LogDir/deferred_errors.log"