[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / utils / release / test-release.sh
blob5f602a451aedb4dde8907d950ffc67eb884d9cba
1 #!/usr/bin/env bash
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 #===------------------------------------------------------------------------===#
14 System=`uname -s`
15 if [ "$System" = "FreeBSD" ]; then
16 MAKE=gmake
17 else
18 MAKE=make
20 generator="Unix Makefiles"
22 # Base SVN URL for the sources.
23 Base_url="http://llvm.org/svn/llvm-project"
25 Release=""
26 Release_no_dot=""
27 RC=""
28 Triple=""
29 use_gzip="no"
30 do_checkout="yes"
31 do_debug="no"
32 do_asserts="no"
33 do_compare="yes"
34 do_rt="yes"
35 do_libs="yes"
36 do_libcxxabi="yes"
37 do_libunwind="yes"
38 do_test_suite="yes"
39 do_openmp="yes"
40 do_lld="yes"
41 do_lldb="yes"
42 do_polly="yes"
43 do_mlir="yes"
44 do_flang="yes"
45 BuildDir="`pwd`"
46 ExtraConfigureFlags=""
47 ExportBranch=""
48 git_ref=""
50 function usage() {
51 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
52 echo ""
53 echo " -release X.Y.Z The release version to test."
54 echo " -rc NUM The pre-release candidate number."
55 echo " -final The final release candidate."
56 echo " -triple TRIPLE The target triple for this machine."
57 echo " -j NUM Number of compile jobs to run. [default: 3]"
58 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
59 echo " -no-checkout Don't checkout the sources from SVN."
60 echo " -test-debug Test the debug build. [default: no]"
61 echo " -test-asserts Test with asserts on. [default: no]"
62 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
63 echo " -use-gzip Use gzip instead of xz."
64 echo " -use-ninja Use ninja instead of make/gmake."
65 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
66 echo " -git-ref sha Use the specified git ref for testing instead of a release."
67 echo " -no-rt Disable check-out & build Compiler-RT"
68 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
69 echo " -no-libcxxabi Disable check-out & build libcxxabi"
70 echo " -no-libunwind Disable check-out & build libunwind"
71 echo " -no-test-suite Disable check-out & build test-suite"
72 echo " -no-openmp Disable check-out & build libomp"
73 echo " -no-lld Disable check-out & build lld"
74 echo " -lldb Enable check-out & build lldb"
75 echo " -no-lldb Disable check-out & build lldb (default)"
76 echo " -no-polly Disable check-out & build Polly"
77 echo " -no-mlir Disable check-out & build MLIR"
78 echo " -no-flang Disable check-out & build Flang"
81 while [ $# -gt 0 ]; do
82 case $1 in
83 -release | --release )
84 shift
85 Release="$1"
86 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
88 -rc | --rc | -RC | --RC )
89 shift
90 RC="rc$1"
92 -final | --final )
93 RC=final
95 -git-ref | --git-ref )
96 shift
97 Release="test"
98 Release_no_dot="test"
99 ExportBranch="$1"
100 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
101 git_ref="$1"
102 echo "WARNING: Using the ref $git_ref instead of a release tag"
103 echo " This is intended to aid new packagers in trialing "
104 echo " builds without requiring a tag to be created first"
106 -triple | --triple )
107 shift
108 Triple="$1"
110 -configure-flags | --configure-flags )
111 shift
112 ExtraConfigureFlags="$1"
114 -j* )
115 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
116 if [ -z "$NumJobs" ]; then
117 shift
118 NumJobs="$1"
121 -use-ninja )
122 MAKE=ninja
123 generator=Ninja
125 -build-dir | --build-dir | -builddir | --builddir )
126 shift
127 BuildDir="$1"
129 -no-checkout | --no-checkout )
130 do_checkout="no"
132 -test-debug | --test-debug )
133 do_debug="yes"
135 -test-asserts | --test-asserts )
136 do_asserts="yes"
138 -no-compare-files | --no-compare-files )
139 do_compare="no"
141 -use-gzip | --use-gzip )
142 use_gzip="yes"
144 -no-rt )
145 do_rt="no"
147 -no-libs )
148 do_libs="no"
150 -no-libcxxabi )
151 do_libcxxabi="no"
153 -no-libunwind )
154 do_libunwind="no"
156 -no-test-suite )
157 do_test_suite="no"
159 -no-openmp )
160 do_openmp="no"
162 -no-lld )
163 do_lld="no"
165 -lldb )
166 do_lldb="yes"
168 -no-lldb )
169 do_lldb="no"
171 -no-polly )
172 do_polly="no"
174 -no-mlir )
175 do_mlir="no"
177 -no-flang )
178 do_flang="no"
180 -help | --help | -h | --h | -\? )
181 usage
182 exit 0
185 echo "unknown option: $1"
186 usage
187 exit 1
189 esac
190 shift
191 done
193 if [ $do_mlir = "no" ] && [ $do_flang = "yes" ]; then
194 echo "error: cannot build Flang without MLIR"
195 exit 1
198 # Check required arguments.
199 if [ -z "$Release" ]; then
200 echo "error: no release number specified"
201 exit 1
203 if [ -z "$RC" ]; then
204 echo "error: no release candidate number specified"
205 exit 1
207 if [ -z "$ExportBranch" ]; then
208 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
210 if [ -z "$Triple" ]; then
211 echo "error: no target triple specified"
212 exit 1
215 if [ "$Release" != "test" ]; then
216 if [ -n "$git_ref" ]; then
217 echo "error: can't specify both -release and -git-ref"
218 exit 1
220 git_ref=llvmorg-$Release
221 if [ "$RC" != "final" ]; then
222 git_ref="$git_ref-$RC"
226 # Figure out how many make processes to run.
227 if [ -z "$NumJobs" ]; then
228 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
230 if [ -z "$NumJobs" ]; then
231 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
233 if [ -z "$NumJobs" ]; then
234 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
236 if [ -z "$NumJobs" ]; then
237 NumJobs=3
240 # Projects list
241 projects="llvm clang clang-tools-extra"
242 if [ $do_rt = "yes" ]; then
243 projects="$projects compiler-rt"
245 if [ $do_libs = "yes" ]; then
246 projects="$projects libcxx"
247 if [ $do_libcxxabi = "yes" ]; then
248 projects="$projects libcxxabi"
250 if [ $do_libunwind = "yes" ]; then
251 projects="$projects libunwind"
254 case $do_test_suite in
255 yes|export-only)
256 projects="$projects test-suite"
258 esac
259 if [ $do_openmp = "yes" ]; then
260 projects="$projects openmp"
262 if [ $do_lld = "yes" ]; then
263 projects="$projects lld"
265 if [ $do_lldb = "yes" ]; then
266 projects="$projects lldb"
268 if [ $do_polly = "yes" ]; then
269 projects="$projects polly"
271 if [ $do_mlir = "yes" ]; then
272 projects="$projects mlir"
274 if [ $do_flang = "yes" ]; then
275 projects="$projects flang"
278 # Go to the build directory (may be different from CWD)
279 BuildDir=$BuildDir/$RC
280 mkdir -p $BuildDir
281 cd $BuildDir
283 # Location of log files.
284 LogDir=$BuildDir/logs
285 mkdir -p $LogDir
287 # Final package name.
288 Package=clang+llvm-$Release
289 if [ $RC != "final" ]; then
290 Package=$Package-$RC
292 Package=$Package-$Triple
294 # Errors to be highlighted at the end are written to this file.
295 echo -n > $LogDir/deferred_errors.log
297 function deferred_error() {
298 Phase="$1"
299 Flavor="$2"
300 Msg="$3"
301 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
304 # Make sure that a required program is available
305 function check_program_exists() {
306 local program="$1"
307 if ! type -P $program > /dev/null 2>&1 ; then
308 echo "program '$1' not found !"
309 exit 1
313 if [ "$System" != "Darwin" -a "$System" != "SunOS" ]; then
314 check_program_exists 'chrpath'
317 if [ "$System" != "Darwin" ]; then
318 check_program_exists 'file'
319 check_program_exists 'objdump'
322 check_program_exists ${MAKE}
324 # Export sources to the build directory.
325 function export_sources() {
326 SrcDir=$BuildDir/llvm-project
327 mkdir -p $SrcDir
328 echo "# Using git ref: $git_ref"
330 # GitHub allows you to download a tarball of any commit using the URL:
331 # https://github.com/$organization/$repo/archive/$ref.tar.gz
332 curl -L https://github.com/llvm/llvm-project/archive/$git_ref.tar.gz | \
333 tar -C $SrcDir --strip-components=1 -xzf -
335 if [ "$do_test_suite" = "yes" ]; then
336 TestSuiteSrcDir=$BuildDir/llvm-test-suite
337 mkdir -p $TestSuiteSrcDir
339 # We can only use named refs, like branches and tags, that exist in
340 # both the llvm-project and test-suite repos if we want to run the
341 # test suite.
342 # If the test-suite fails to download assume we are using a ref that
343 # doesn't exist in the test suite and disable it.
344 set +e
345 curl -L https://github.com/llvm/test-suite/archive/$git_ref.tar.gz | \
346 tar -C $TestSuiteSrcDir --strip-components=1 -xzf -
347 if [ $? -ne -0 ]; then
348 echo "$git_ref not found in test-suite repo, test-suite disabled."
349 do_test_suite="no"
351 set -e
354 cd $BuildDir
357 function configure_llvmCore() {
358 Phase="$1"
359 Flavor="$2"
360 ObjDir="$3"
362 case $Flavor in
363 Release )
364 BuildType="Release"
365 Assertions="OFF"
367 Release+Asserts )
368 BuildType="Release"
369 Assertions="ON"
371 Debug )
372 BuildType="Debug"
373 Assertions="ON"
376 echo "# Invalid flavor '$Flavor'"
377 echo ""
378 return
380 esac
382 project_list=${projects// /;}
383 echo "# Using C compiler: $c_compiler"
384 echo "# Using C++ compiler: $cxx_compiler"
386 cd $ObjDir
387 echo "# Configuring llvm $Release-$RC $Flavor"
389 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
390 cmake -G "$generator" \
391 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
392 -DLLVM_ENABLE_PROJECTS="$project_list" \
393 $ExtraConfigureFlags $BuildDir/llvm-project/llvm \
394 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
395 env CC="$c_compiler" CXX="$cxx_compiler" \
396 cmake -G "$generator" \
397 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
398 -DLLVM_ENABLE_PROJECTS="$project_list" \
399 $ExtraConfigureFlags $BuildDir/llvm-project/llvm \
400 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
402 cd $BuildDir
405 function build_llvmCore() {
406 Phase="$1"
407 Flavor="$2"
408 ObjDir="$3"
409 DestDir="$4"
411 Verbose="VERBOSE=1"
412 if [ ${MAKE} = 'ninja' ]; then
413 Verbose="-v"
416 cd $ObjDir
417 echo "# Compiling llvm $Release-$RC $Flavor"
418 echo "# ${MAKE} -j $NumJobs $Verbose"
419 ${MAKE} -j $NumJobs $Verbose \
420 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
422 echo "# Installing llvm $Release-$RC $Flavor"
423 echo "# ${MAKE} install"
424 DESTDIR="${DestDir}" ${MAKE} install \
425 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
426 cd $BuildDir
429 function test_llvmCore() {
430 Phase="$1"
431 Flavor="$2"
432 ObjDir="$3"
434 KeepGoing="-k"
435 if [ ${MAKE} = 'ninja' ]; then
436 # Ninja doesn't have a documented "keep-going-forever" mode, we need to
437 # set a limit on how many jobs can fail before we give up.
438 KeepGoing="-k 100"
441 cd $ObjDir
442 if ! ( ${MAKE} -j $NumJobs $KeepGoing check-all \
443 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
444 deferred_error $Phase $Flavor "check-all failed"
447 if [ $do_test_suite = 'yes' ]; then
448 cd $TestSuiteBuildDir
449 env CC="$c_compiler" CXX="$cxx_compiler" \
450 cmake $TestSuiteSrcDir -G "$generator" -DTEST_SUITE_LIT=$Lit
452 if ! ( ${MAKE} -j $NumJobs $KeepGoing check \
453 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
454 deferred_error $Phase $Flavor "test suite failed"
457 cd $BuildDir
460 # Clean RPATH. Libtool adds the build directory to the search path, which is
461 # not necessary --- and even harmful --- for the binary packages we release.
462 function clean_RPATH() {
463 if [ "$System" = "Darwin" -o "$System" = "SunOS" ]; then
464 return
466 local InstallPath="$1"
467 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
468 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
469 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
470 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
471 if [ -n "$rpath" ]; then
472 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
473 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
477 done
480 # Create a package of the release binaries.
481 function package_release() {
482 cwd=`pwd`
483 cd $BuildDir/Phase3/Release
484 mv llvmCore-$Release-$RC.install/usr/local $Package
485 if [ "$use_gzip" = "yes" ]; then
486 tar cf - $Package | gzip -9c > $BuildDir/$Package.tar.gz
487 else
488 tar cf - $Package | xz -9ce > $BuildDir/$Package.tar.xz
490 mv $Package llvmCore-$Release-$RC.install/usr/local
491 cd $cwd
494 # Exit if any command fails
495 # Note: pipefail is necessary for running build commands through
496 # a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
497 set -e
498 set -o pipefail
500 # Turn off core dumps, as some test cases can easily fill up even the largest
501 # file systems.
502 ulimit -c 0
504 if [ "$do_checkout" = "yes" ]; then
505 export_sources
508 # Setup the test-suite. Do this early so we can catch failures before
509 # we do the full 3 stage build.
510 if [ $do_test_suite = "yes" ]; then
511 check_program_exists 'python3'
512 venv="python3 -m venv"
514 SandboxDir="$BuildDir/sandbox"
515 Lit=$SandboxDir/bin/lit
516 TestSuiteBuildDir="$BuildDir/test-suite-build"
517 TestSuiteSrcDir="$BuildDir/llvm-test-suite"
519 ${venv} $SandboxDir
520 $SandboxDir/bin/python $BuildDir/llvm-project/llvm/utils/lit/setup.py install
521 mkdir -p $TestSuiteBuildDir
525 Flavors="Release"
526 if [ "$do_debug" = "yes" ]; then
527 Flavors="Debug $Flavors"
529 if [ "$do_asserts" = "yes" ]; then
530 Flavors="$Flavors Release+Asserts"
533 for Flavor in $Flavors ; do
534 echo ""
535 echo ""
536 echo "********************************************************************************"
537 echo " Release: $Release-$RC"
538 echo " Build: $Flavor"
539 echo " System Info: "
540 echo " `uname -a`"
541 echo "********************************************************************************"
542 echo ""
544 c_compiler="$CC"
545 cxx_compiler="$CXX"
546 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
547 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
549 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
550 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
552 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
553 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
555 rm -rf $llvmCore_phase1_objdir
556 rm -rf $llvmCore_phase1_destdir
558 rm -rf $llvmCore_phase2_objdir
559 rm -rf $llvmCore_phase2_destdir
561 rm -rf $llvmCore_phase3_objdir
562 rm -rf $llvmCore_phase3_destdir
564 mkdir -p $llvmCore_phase1_objdir
565 mkdir -p $llvmCore_phase1_destdir
567 mkdir -p $llvmCore_phase2_objdir
568 mkdir -p $llvmCore_phase2_destdir
570 mkdir -p $llvmCore_phase3_objdir
571 mkdir -p $llvmCore_phase3_destdir
573 ############################################################################
574 # Phase 1: Build llvmCore and clang
575 echo "# Phase 1: Building llvmCore"
576 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
577 build_llvmCore 1 $Flavor \
578 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
579 clean_RPATH $llvmCore_phase1_destdir/usr/local
581 ########################################################################
582 # Phase 2: Build llvmCore with newly built clang from phase 1.
583 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
584 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
585 echo "# Phase 2: Building llvmCore"
586 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
587 build_llvmCore 2 $Flavor \
588 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
589 clean_RPATH $llvmCore_phase2_destdir/usr/local
591 ########################################################################
592 # Phase 3: Build llvmCore with newly built clang from phase 2.
593 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
594 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
595 echo "# Phase 3: Building llvmCore"
596 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
597 build_llvmCore 3 $Flavor \
598 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
599 clean_RPATH $llvmCore_phase3_destdir/usr/local
601 ########################################################################
602 # Testing: Test phase 3
603 c_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang
604 cxx_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang++
605 echo "# Testing - built with clang"
606 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
608 ########################################################################
609 # Compare .o files between Phase2 and Phase3 and report which ones
610 # differ.
611 if [ "$do_compare" = "yes" ]; then
612 echo
613 echo "# Comparing Phase 2 and Phase 3 files"
614 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
615 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
616 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
617 # case there are build paths in the debug info. Do the same sub-
618 # stitution on both files in case the string occurrs naturally.
619 if ! cmp -s \
620 <(env LC_CTYPE=C sed -e 's,Phase1,Phase2,g' -e 's,Phase2,Phase3,g' $p2) \
621 <(env LC_CTYPE=C sed -e 's,Phase1,Phase2,g' -e 's,Phase2,Phase3,g' $p3) \
622 16 16; then
623 echo "file `basename $p2` differs between phase 2 and phase 3"
625 done
627 done
629 ) 2>&1 | tee $LogDir/testing.$Release-$RC.log
631 if [ "$use_gzip" = "yes" ]; then
632 echo "# Packaging the release as $Package.tar.gz"
633 else
634 echo "# Packaging the release as $Package.tar.xz"
636 package_release
638 set +e
640 # Woo hoo!
641 echo "### Testing Finished ###"
642 echo "### Logs: $LogDir"
644 echo "### Errors:"
645 if [ -s "$LogDir/deferred_errors.log" ]; then
646 cat "$LogDir/deferred_errors.log"
647 exit 1
648 else
649 echo "None."
652 exit 0