2 #===-- test-release.sh - Test the LLVM release candidates ------------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===------------------------------------------------------------------------===#
10 # Download, build, and test the release candidate for an LLVM release.
12 #===------------------------------------------------------------------------===#
15 if [ "$System" = "FreeBSD" ]; then
20 generator
="Unix Makefiles"
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 " -use-ninja Use ninja instead of make/gmake."
62 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
63 echo " -svn-path DIR Use the specified DIR instead of a release."
64 echo " For example -svn-path trunk or -svn-path branches/release_37"
65 echo " -no-rt Disable check-out & build Compiler-RT"
66 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
67 echo " -no-libcxxabi Disable check-out & build libcxxabi"
68 echo " -no-libunwind Disable check-out & build libunwind"
69 echo " -no-test-suite Disable check-out & build test-suite"
70 echo " -no-openmp Disable check-out & build libomp"
71 echo " -no-lld Disable check-out & build lld"
72 echo " -lldb Enable check-out & build lldb"
73 echo " -no-lldb Disable check-out & build lldb (default)"
74 echo " -no-polly Disable check-out & build Polly"
77 while [ $# -gt 0 ]; do
79 -release |
--release )
82 Release_no_dot
="`echo $1 | sed -e 's,\.,,g'`"
84 -rc |
--rc |
-RC |
--RC )
91 -svn-path |
--svn-path )
96 RC
="`echo $ExportBranch | sed -e 's,/,_,g'`"
97 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
98 echo " This is intended to aid new packagers in trialing "
99 echo " builds without requiring a tag to be created first"
105 -configure-flags |
--configure-flags )
107 ExtraConfigureFlags
="$1"
110 NumJobs
="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
111 if [ -z "$NumJobs" ]; then
120 -build-dir |
--build-dir |
-builddir |
--builddir )
124 -no-checkout |
--no-checkout )
127 -test-debug |
--test-debug )
130 -test-asserts |
--test-asserts )
133 -no-compare-files |
--no-compare-files )
136 -use-gzip |
--use-gzip )
169 -help |
--help |
-h |
--h |
-\? )
174 echo "unknown option: $1"
182 # Check required arguments.
183 if [ -z "$Release" ]; then
184 echo "error: no release number specified"
187 if [ -z "$RC" ]; then
188 echo "error: no release candidate number specified"
191 if [ -z "$ExportBranch" ]; then
192 ExportBranch
="tags/RELEASE_$Release_no_dot/$RC"
194 if [ -z "$Triple" ]; then
195 echo "error: no target triple specified"
199 # Figure out how many make processes to run.
200 if [ -z "$NumJobs" ]; then
201 NumJobs
=`sysctl -n hw.activecpu 2> /dev/null || true`
203 if [ -z "$NumJobs" ]; then
204 NumJobs
=`sysctl -n hw.ncpu 2> /dev/null || true`
206 if [ -z "$NumJobs" ]; then
207 NumJobs
=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
209 if [ -z "$NumJobs" ]; then
214 projects
="llvm cfe clang-tools-extra"
215 if [ $do_rt = "yes" ]; then
216 projects
="$projects compiler-rt"
218 if [ $do_libs = "yes" ]; then
219 projects
="$projects libcxx"
220 if [ $do_libcxxabi = "yes" ]; then
221 projects
="$projects libcxxabi"
223 if [ $do_libunwind = "yes" ]; then
224 projects
="$projects libunwind"
227 case $do_test_suite in
229 projects
="$projects test-suite"
232 if [ $do_openmp = "yes" ]; then
233 projects
="$projects openmp"
235 if [ $do_lld = "yes" ]; then
236 projects
="$projects lld"
238 if [ $do_lldb = "yes" ]; then
239 projects
="$projects lldb"
241 if [ $do_polly = "yes" ]; then
242 projects
="$projects polly"
245 # Go to the build directory (may be different from CWD)
246 BuildDir
=$BuildDir/$RC
250 # Location of log files.
251 LogDir
=$BuildDir/logs
254 # Final package name.
255 Package
=clang
+llvm-
$Release
256 if [ $RC != "final" ]; then
259 Package
=$Package-$Triple
261 # Errors to be highlighted at the end are written to this file.
262 echo -n > $LogDir/deferred_errors.log
264 function deferred_error
() {
268 echo "[${Flavor} Phase${Phase}] ${Msg}" |
tee -a $LogDir/deferred_errors.log
271 # Make sure that a required program is available
272 function check_program_exists
() {
274 if ! type -P $program > /dev
/null
2>&1 ; then
275 echo "program '$1' not found !"
280 if [ "$System" != "Darwin" -a "$System" != "SunOS" ]; then
281 check_program_exists
'chrpath'
284 if [ "$System" != "Darwin" ]; then
285 check_program_exists
'file'
286 check_program_exists
'objdump'
289 check_program_exists
${MAKE}
291 # Make sure that the URLs are valid.
292 function check_valid_urls
() {
293 for proj
in $projects ; do
294 echo "# Validating $proj SVN URL"
296 if ! svn
ls $Base_url/$proj/$ExportBranch > /dev
/null
2>&1 ; then
297 echo "$proj does not have a $ExportBranch branch/tag!"
303 # Export sources to the build directory.
304 function export_sources
() {
307 for proj
in $projects ; do
313 projsrc
=llvm.src
/tools
/clang
316 projsrc
=llvm.src
/tools
/$proj
319 projsrc
=llvm.src
/tools
/clang
/tools
/extra
321 compiler-rt|libcxx|libcxxabi|libunwind|openmp
)
322 projsrc
=llvm.src
/projects
/$proj
328 echo "error: unknown project $proj"
333 if [ -d $projsrc ]; then
334 echo "# Reusing $proj $Release-$RC sources in $projsrc"
337 echo "# Exporting $proj $Release-$RC sources to $projsrc"
338 if ! svn
export -q $Base_url/$proj/$ExportBranch $projsrc ; then
339 echo "error: failed to export $proj project"
347 function configure_llvmCore
() {
366 echo "# Invalid flavor '$Flavor'"
372 echo "# Using C compiler: $c_compiler"
373 echo "# Using C++ compiler: $cxx_compiler"
376 echo "# Configuring llvm $Release-$RC $Flavor"
378 echo "#" env CC
="$c_compiler" CXX
="$cxx_compiler" \
379 cmake
-G "$generator" \
380 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
381 $ExtraConfigureFlags $BuildDir/llvm.src \
382 2>&1 |
tee $LogDir/llvm.configure-Phase
$Phase-$Flavor.log
383 env CC
="$c_compiler" CXX
="$cxx_compiler" \
384 cmake
-G "$generator" \
385 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
386 $ExtraConfigureFlags $BuildDir/llvm.src \
387 2>&1 |
tee $LogDir/llvm.configure-Phase
$Phase-$Flavor.log
392 function build_llvmCore
() {
399 if [ ${MAKE} = 'ninja' ]; then
404 echo "# Compiling llvm $Release-$RC $Flavor"
405 echo "# ${MAKE} -j $NumJobs $Verbose"
406 ${MAKE} -j $NumJobs $Verbose \
407 2>&1 |
tee $LogDir/llvm.make-Phase
$Phase-$Flavor.log
409 echo "# Installing llvm $Release-$RC $Flavor"
410 echo "# ${MAKE} install"
411 DESTDIR
="${DestDir}" ${MAKE} install \
412 2>&1 |
tee $LogDir/llvm.install-Phase
$Phase-$Flavor.log
416 function test_llvmCore
() {
422 if [ ${MAKE} = 'ninja' ]; then
423 # Ninja doesn't have a documented "keep-going-forever" mode, we need to
424 # set a limit on how many jobs can fail before we give up.
429 if ! ( ${MAKE} -j $NumJobs $KeepGoing check-all \
430 2>&1 |
tee $LogDir/llvm.check-Phase
$Phase-$Flavor.log
) ; then
431 deferred_error
$Phase $Flavor "check-all failed"
434 if [ $do_test_suite = 'yes' ]; then
435 cd $TestSuiteBuildDir
436 env CC
="$c_compiler" CXX
="$cxx_compiler" \
437 cmake
$TestSuiteSrcDir -G "$generator" -DTEST_SUITE_LIT=$Lit
439 if ! ( ${MAKE} -j $NumJobs $KeepGoing check \
440 2>&1 |
tee $LogDir/llvm.check-Phase
$Phase-$Flavor.log
) ; then
441 deferred_error
$Phase $Flavor "test suite failed"
447 # Clean RPATH. Libtool adds the build directory to the search path, which is
448 # not necessary --- and even harmful --- for the binary packages we release.
449 function clean_RPATH
() {
450 if [ "$System" = "Darwin" -o "$System" = "SunOS" ]; then
453 local InstallPath
="$1"
454 for Candidate
in `find $InstallPath/{bin,lib} -type f`; do
455 if file $Candidate |
grep ELF |
egrep 'executable|shared object' > /dev
/null
2>&1 ; then
456 if rpath
=`objdump -x $Candidate | grep 'RPATH'` ; then
457 rpath
=`echo $rpath | sed -e's/^ *RPATH *//'`
458 if [ -n "$rpath" ]; then
459 newrpath
=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
460 chrpath
-r $newrpath $Candidate 2>&1 > /dev
/null
2>&1
467 # Create a package of the release binaries.
468 function package_release
() {
470 cd $BuildDir/Phase
3/Release
471 mv llvmCore-
$Release-$RC.install
/usr
/local $Package
472 if [ "$use_gzip" = "yes" ]; then
473 tar cfz
$BuildDir/$Package.
tar.gz
$Package
475 tar cfJ
$BuildDir/$Package.
tar.xz
$Package
477 mv $Package llvmCore-
$Release-$RC.install
/usr
/local
481 # Exit if any command fails
482 # Note: pipefail is necessary for running build commands through
483 # a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
487 if [ "$do_checkout" = "yes" ]; then
491 # Setup the test-suite. Do this early so we can catch failures before
492 # we do the full 3 stage build.
493 if [ $do_test_suite = "yes" ]; then
494 SandboxDir
="$BuildDir/sandbox"
495 Lit
=$SandboxDir/bin
/lit
496 TestSuiteBuildDir
="$BuildDir/test-suite-build"
497 TestSuiteSrcDir
="$BuildDir/test-suite.src"
499 virtualenv
$SandboxDir
500 $SandboxDir/bin
/python
$BuildDir/llvm.src
/utils
/lit
/setup.py
install
501 mkdir
-p $TestSuiteBuildDir
506 if [ "$do_debug" = "yes" ]; then
507 Flavors
="Debug $Flavors"
509 if [ "$do_asserts" = "yes" ]; then
510 Flavors
="$Flavors Release+Asserts"
513 for Flavor
in $Flavors ; do
516 echo "********************************************************************************"
517 echo " Release: $Release-$RC"
518 echo " Build: $Flavor"
519 echo " System Info: "
521 echo "********************************************************************************"
526 llvmCore_phase1_objdir
=$BuildDir/Phase
1/$Flavor/llvmCore-
$Release-$RC.obj
527 llvmCore_phase1_destdir
=$BuildDir/Phase
1/$Flavor/llvmCore-
$Release-$RC.
install
529 llvmCore_phase2_objdir
=$BuildDir/Phase
2/$Flavor/llvmCore-
$Release-$RC.obj
530 llvmCore_phase2_destdir
=$BuildDir/Phase
2/$Flavor/llvmCore-
$Release-$RC.
install
532 llvmCore_phase3_objdir
=$BuildDir/Phase
3/$Flavor/llvmCore-
$Release-$RC.obj
533 llvmCore_phase3_destdir
=$BuildDir/Phase
3/$Flavor/llvmCore-
$Release-$RC.
install
535 rm -rf $llvmCore_phase1_objdir
536 rm -rf $llvmCore_phase1_destdir
538 rm -rf $llvmCore_phase2_objdir
539 rm -rf $llvmCore_phase2_destdir
541 rm -rf $llvmCore_phase3_objdir
542 rm -rf $llvmCore_phase3_destdir
544 mkdir
-p $llvmCore_phase1_objdir
545 mkdir
-p $llvmCore_phase1_destdir
547 mkdir
-p $llvmCore_phase2_objdir
548 mkdir
-p $llvmCore_phase2_destdir
550 mkdir
-p $llvmCore_phase3_objdir
551 mkdir
-p $llvmCore_phase3_destdir
553 ############################################################################
554 # Phase 1: Build llvmCore and clang
555 echo "# Phase 1: Building llvmCore"
556 configure_llvmCore
1 $Flavor $llvmCore_phase1_objdir
557 build_llvmCore
1 $Flavor \
558 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
559 clean_RPATH
$llvmCore_phase1_destdir/usr
/local
561 ########################################################################
562 # Phase 2: Build llvmCore with newly built clang from phase 1.
563 c_compiler
=$llvmCore_phase1_destdir/usr
/local
/bin
/clang
564 cxx_compiler
=$llvmCore_phase1_destdir/usr
/local
/bin
/clang
++
565 echo "# Phase 2: Building llvmCore"
566 configure_llvmCore
2 $Flavor $llvmCore_phase2_objdir
567 build_llvmCore
2 $Flavor \
568 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
569 clean_RPATH
$llvmCore_phase2_destdir/usr
/local
571 ########################################################################
572 # Phase 3: Build llvmCore with newly built clang from phase 2.
573 c_compiler
=$llvmCore_phase2_destdir/usr
/local
/bin
/clang
574 cxx_compiler
=$llvmCore_phase2_destdir/usr
/local
/bin
/clang
++
575 echo "# Phase 3: Building llvmCore"
576 configure_llvmCore
3 $Flavor $llvmCore_phase3_objdir
577 build_llvmCore
3 $Flavor \
578 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
579 clean_RPATH
$llvmCore_phase3_destdir/usr
/local
581 ########################################################################
582 # Testing: Test phase 3
583 c_compiler
=$llvmCore_phase3_destdir/usr
/local
/bin
/clang
584 cxx_compiler
=$llvmCore_phase3_destdir/usr
/local
/bin
/clang
++
585 echo "# Testing - built with clang"
586 test_llvmCore
3 $Flavor $llvmCore_phase3_objdir
588 ########################################################################
589 # Compare .o files between Phase2 and Phase3 and report which ones
591 if [ "$do_compare" = "yes" ]; then
593 echo "# Comparing Phase 2 and Phase 3 files"
594 for p2
in `find $llvmCore_phase2_objdir -name '*.o'` ; do
595 p3
=`echo $p2 | sed -e 's,Phase2,Phase3,'`
596 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
597 # case there are build paths in the debug info. Do the same sub-
598 # stitution on both files in case the string occurrs naturally.
600 <(env LC_CTYPE
=C
sed -e 's,Phase1,Phase2,g' -e 's,Phase2,Phase3,g' $p2) \
601 <(env LC_CTYPE
=C
sed -e 's,Phase1,Phase2,g' -e 's,Phase2,Phase3,g' $p3) \
603 echo "file `basename $p2` differs between phase 2 and phase 3"
609 ) 2>&1 |
tee $LogDir/testing.
$Release-$RC.log
611 if [ "$use_gzip" = "yes" ]; then
612 echo "# Packaging the release as $Package.tar.gz"
614 echo "# Packaging the release as $Package.tar.xz"
621 echo "### Testing Finished ###"
622 echo "### Logs: $LogDir"
625 if [ -s "$LogDir/deferred_errors.log" ]; then
626 cat "$LogDir/deferred_errors.log"