blob: b0c771579802fefccab709e7c0b1cc6b5f80d734 [file] [log] [blame]
Bill Wendlingf96a5bc2011-10-19 09:25:49 +00001#!/usr/bin/env bash
Bill Wendlingcedf3a22010-09-08 18:32:31 +00002#===-- test-release.sh - Test the LLVM release candidates ------------------===#
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is distributed under the University of Illinois Open Source
7# License.
8#
9#===------------------------------------------------------------------------===#
10#
11# Download, build, and test the release candidate for an LLVM release.
12#
13#===------------------------------------------------------------------------===#
14
Dimitry Andricca051602016-01-21 22:07:17 +000015System=`uname -s`
16if [ "$System" = "FreeBSD" ]; then
Bill Wendlingcfe82322011-10-19 08:42:07 +000017 MAKE=gmake
18else
19 MAKE=make
20fi
21
Bill Wendling9aa39432011-10-16 22:44:08 +000022# Base SVN URL for the sources.
23Base_url="http://llvm.org/svn/llvm-project"
24
Bill Wendlingcedf3a22010-09-08 18:32:31 +000025Release=""
26Release_no_dot=""
27RC=""
Bill Wendlingd6073842013-11-20 04:55:20 +000028Triple=""
Bill Wendling1585fea2013-11-24 05:29:35 +000029use_gzip="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000030do_checkout="yes"
Bill Wendling9aa39432011-10-16 22:44:08 +000031do_debug="no"
Bill Wendling7b7d0772011-10-17 04:46:54 +000032do_asserts="no"
Bill Wendlingd70cde12012-04-02 23:27:43 +000033do_compare="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000034do_rt="yes"
35do_libs="yes"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000036do_libunwind="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000037do_test_suite="yes"
Alexey Bataev860435c2015-12-10 05:45:58 +000038do_openmp="yes"
Dimitry Andric434fa952017-02-04 22:24:55 +000039do_lld="yes"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000040do_lldb="no"
Pengxuan Zhengac6595c2017-01-18 01:03:29 +000041do_polly="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000042BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000043ExtraConfigureFlags=""
Daniel Sandersc2672e52015-07-17 10:40:40 +000044ExportBranch=""
Bill Wendlingcedf3a22010-09-08 18:32:31 +000045
Bill Wendlingcedf3a22010-09-08 18:32:31 +000046function usage() {
Hans Wennborg6072d2b2015-06-22 21:13:30 +000047 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000048 echo ""
Hans Wennborg6072d2b2015-06-22 21:13:30 +000049 echo " -release X.Y.Z The release version to test."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000050 echo " -rc NUM The pre-release candidate number."
51 echo " -final The final release candidate."
52 echo " -triple TRIPLE The target triple for this machine."
53 echo " -j NUM Number of compile jobs to run. [default: 3]"
54 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
55 echo " -no-checkout Don't checkout the sources from SVN."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000056 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."
59 echo " -use-gzip Use gzip instead of xz."
Hans Wennborg0caeee02015-07-15 21:06:16 +000060 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
Daniel Sandersc2672e52015-07-17 10:40:40 +000061 echo " -svn-path DIR Use the specified DIR instead of a release."
62 echo " For example -svn-path trunk or -svn-path branches/release_37"
Renato Golin397b0da2015-07-22 18:21:39 +000063 echo " -no-rt Disable check-out & build Compiler-RT"
64 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000065 echo " -no-libunwind Disable check-out & build libunwind"
Renato Golin397b0da2015-07-22 18:21:39 +000066 echo " -no-test-suite Disable check-out & build test-suite"
Alexey Bataev860435c2015-12-10 05:45:58 +000067 echo " -no-openmp Disable check-out & build libomp"
Dimitry Andric434fa952017-02-04 22:24:55 +000068 echo " -no-lld Disable check-out & build lld"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000069 echo " -lldb Enable check-out & build lldb"
70 echo " -no-lldb Disable check-out & build lldb (default)"
Pengxuan Zhengac6595c2017-01-18 01:03:29 +000071 echo " -polly Enable check-out & build Polly"
72 echo " -no-polly Disable check-out & build Polly (default)"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000073}
74
75while [ $# -gt 0 ]; do
76 case $1 in
77 -release | --release )
78 shift
79 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000080 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000081 ;;
82 -rc | --rc | -RC | --RC )
83 shift
Bill Wendling957cc212011-11-28 11:45:10 +000084 RC="rc$1"
85 ;;
86 -final | --final )
87 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000088 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000089 -svn-path | --svn-path )
90 shift
91 Release="test"
92 Release_no_dot="test"
93 ExportBranch="$1"
94 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
95 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
96 echo " This is intended to aid new packagers in trialing "
97 echo " builds without requiring a tag to be created first"
98 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000099 -triple | --triple )
100 shift
101 Triple="$1"
102 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000103 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000104 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000105 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000106 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000107 -j* )
108 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
109 if [ -z "$NumJobs" ]; then
110 shift
111 NumJobs="$1"
112 fi
113 ;;
114 -build-dir | --build-dir | -builddir | --builddir )
115 shift
116 BuildDir="$1"
117 ;;
118 -no-checkout | --no-checkout )
119 do_checkout="no"
120 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000121 -test-debug | --test-debug )
122 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000123 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000124 -test-asserts | --test-asserts )
125 do_asserts="yes"
126 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000127 -no-compare-files | --no-compare-files )
128 do_compare="no"
129 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000130 -use-gzip | --use-gzip )
131 use_gzip="yes"
132 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000133 -no-rt )
134 do_rt="no"
135 ;;
136 -no-libs )
137 do_libs="no"
138 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000139 -no-libunwind )
140 do_libunwind="no"
141 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000142 -no-test-suite )
143 do_test_suite="no"
144 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000145 -no-openmp )
146 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000147 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000148 -no-lld )
149 do_lld="no"
150 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000151 -lldb )
152 do_lldb="yes"
153 ;;
154 -no-lldb )
155 do_lldb="no"
156 ;;
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000157 -polly )
158 do_polly="yes"
159 ;;
160 -no-polly )
161 do_polly="no"
162 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000163 -help | --help | -h | --h | -\? )
164 usage
165 exit 0
166 ;;
167 * )
168 echo "unknown option: $1"
169 usage
170 exit 1
171 ;;
172 esac
173 shift
174done
175
Hans Wennborg9012baa2016-08-09 16:46:02 +0000176if [ "$do_test_suite" = "yes" ]; then
177 # See llvm.org/PR26146.
178 echo Skipping test-suite build when using CMake.
179 echo It will still be exported.
180 do_test_suite="export-only"
Hans Wennborg813c0f72016-01-14 19:21:14 +0000181fi
182
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000183# Check required arguments.
184if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000185 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000186 exit 1
187fi
188if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000189 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000190 exit 1
191fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000192if [ -z "$ExportBranch" ]; then
193 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
194fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000195if [ -z "$Triple" ]; then
196 echo "error: no target triple specified"
197 exit 1
198fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000199
Duncan Sands274090a2010-09-08 19:50:25 +0000200# Figure out how many make processes to run.
201if [ -z "$NumJobs" ]; then
202 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
203fi
204if [ -z "$NumJobs" ]; then
205 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
206fi
207if [ -z "$NumJobs" ]; then
208 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
209fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000210if [ -z "$NumJobs" ]; then
211 NumJobs=3
212fi
213
Renato Golin397b0da2015-07-22 18:21:39 +0000214# Projects list
215projects="llvm cfe clang-tools-extra"
216if [ $do_rt = "yes" ]; then
217 projects="$projects compiler-rt"
218fi
219if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000220 projects="$projects libcxx libcxxabi"
221 if [ $do_libunwind = "yes" ]; then
222 projects="$projects libunwind"
223 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000224fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000225case $do_test_suite in
226 yes|export-only)
227 projects="$projects test-suite"
228 ;;
229esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000230if [ $do_openmp = "yes" ]; then
231 projects="$projects openmp"
232fi
Dimitry Andric434fa952017-02-04 22:24:55 +0000233if [ $do_lld = "yes" ]; then
234 projects="$projects lld"
235fi
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000236if [ $do_lldb = "yes" ]; then
237 projects="$projects lldb"
238fi
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000239if [ $do_polly = "yes" ]; then
240 projects="$projects polly"
241fi
Renato Golin397b0da2015-07-22 18:21:39 +0000242
Bill Wendling9aa39432011-10-16 22:44:08 +0000243# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000244BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000245mkdir -p $BuildDir
246cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000247
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000248# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000249LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000250mkdir -p $LogDir
251
Bill Wendlingd6073842013-11-20 04:55:20 +0000252# Final package name.
253Package=clang+llvm-$Release
254if [ $RC != "final" ]; then
255 Package=$Package-$RC
256fi
257Package=$Package-$Triple
258
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000259# Errors to be highlighted at the end are written to this file.
260echo -n > $LogDir/deferred_errors.log
261
262function deferred_error() {
263 Phase="$1"
264 Flavor="$2"
265 Msg="$3"
266 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
267}
268
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000269# Make sure that a required program is available
270function check_program_exists() {
271 local program="$1"
272 if ! type -P $program > /dev/null 2>&1 ; then
273 echo "program '$1' not found !"
274 exit 1
275 fi
276}
277
Dimitry Andricca051602016-01-21 22:07:17 +0000278if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000279 check_program_exists 'chrpath'
280 check_program_exists 'file'
281 check_program_exists 'objdump'
282fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000283
284# Make sure that the URLs are valid.
285function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000286 for proj in $projects ; do
287 echo "# Validating $proj SVN URL"
288
Daniel Sandersc2672e52015-07-17 10:40:40 +0000289 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
290 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000291 exit 1
292 fi
293 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000294}
295
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000296# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000297function export_sources() {
298 check_valid_urls
299
Bill Wendling9aa39432011-10-16 22:44:08 +0000300 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000301 case $proj in
302 llvm)
303 projsrc=$proj.src
304 ;;
305 cfe)
306 projsrc=llvm.src/tools/clang
307 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000308 lld|lldb|polly)
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000309 projsrc=llvm.src/tools/$proj
310 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000311 clang-tools-extra)
312 projsrc=llvm.src/tools/clang/tools/extra
313 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000314 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000315 projsrc=llvm.src/projects/$proj
316 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000317 test-suite)
318 if [ $do_test_suite = 'yes' ]; then
319 projsrc=llvm.src/projects/$proj
320 else
321 projsrc=$proj.src
322 fi
323 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000324 *)
325 echo "error: unknown project $proj"
326 exit 1
327 ;;
328 esac
329
330 if [ -d $projsrc ]; then
331 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000332 continue
333 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000334 echo "# Exporting $proj $Release-$RC sources to $projsrc"
335 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000336 echo "error: failed to export $proj project"
337 exit 1
338 fi
339 done
340
Bill Wendling9aa39432011-10-16 22:44:08 +0000341 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000342}
343
344function configure_llvmCore() {
345 Phase="$1"
346 Flavor="$2"
347 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000348
349 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000350 Release )
351 BuildType="Release"
352 Assertions="OFF"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000353 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000354 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000355 BuildType="Release"
356 Assertions="ON"
Duncan Sands17cd9072010-09-13 13:45:33 +0000357 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000358 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000359 BuildType="Debug"
360 Assertions="ON"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000361 ;;
362 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000363 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000364 echo ""
365 return
366 ;;
367 esac
368
Bill Wendling9aa39432011-10-16 22:44:08 +0000369 echo "# Using C compiler: $c_compiler"
370 echo "# Using C++ compiler: $cxx_compiler"
371
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000372 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000373 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000374
Hans Wennborg9012baa2016-08-09 16:46:02 +0000375 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
376 cmake -G "Unix Makefiles" \
377 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000378 $ExtraConfigureFlags $BuildDir/llvm.src \
379 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
380 env CC="$c_compiler" CXX="$cxx_compiler" \
381 cmake -G "Unix Makefiles" \
382 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000383 $ExtraConfigureFlags $BuildDir/llvm.src \
384 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000385
Bill Wendling9aa39432011-10-16 22:44:08 +0000386 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000387}
388
389function build_llvmCore() {
390 Phase="$1"
391 Flavor="$2"
392 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000393 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000394
395 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000396 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000397 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
398 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000399 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000400
Bill Wendling957cc212011-11-28 11:45:10 +0000401 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000402 echo "# ${MAKE} install"
403 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000404 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000405 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
406 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000407}
408
409function test_llvmCore() {
410 Phase="$1"
411 Flavor="$2"
412 ObjDir="$3"
413
414 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000415 if ! ( ${MAKE} -j $NumJobs -k check-all \
416 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
417 deferred_error $Phase $Flavor "check-all failed"
418 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000419
Bill Wendling9aa39432011-10-16 22:44:08 +0000420 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000421}
422
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000423# Clean RPATH. Libtool adds the build directory to the search path, which is
424# not necessary --- and even harmful --- for the binary packages we release.
425function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000426 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000427 return
428 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000429 local InstallPath="$1"
430 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
431 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000432 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
433 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
434 if [ -n "$rpath" ]; then
435 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
436 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
437 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000438 fi
439 fi
440 done
441}
442
Bill Wendlingd6073842013-11-20 04:55:20 +0000443# Create a package of the release binaries.
444function package_release() {
445 cwd=`pwd`
446 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000447 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000448 if [ "$use_gzip" = "yes" ]; then
449 tar cfz $BuildDir/$Package.tar.gz $Package
450 else
451 tar cfJ $BuildDir/$Package.tar.xz $Package
452 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000453 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000454 cd $cwd
455}
456
Dan Liewbbe97552015-07-07 15:50:33 +0000457# Exit if any command fails
458# Note: pipefail is necessary for running build commands through
459# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
460set -e
461set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000462
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000463if [ "$do_checkout" = "yes" ]; then
464 export_sources
465fi
466
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000467(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000468Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000469if [ "$do_debug" = "yes" ]; then
470 Flavors="Debug $Flavors"
471fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000472if [ "$do_asserts" = "yes" ]; then
473 Flavors="$Flavors Release+Asserts"
474fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000475
476for Flavor in $Flavors ; do
477 echo ""
478 echo ""
479 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000480 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000481 echo " Build: $Flavor"
482 echo " System Info: "
483 echo " `uname -a`"
484 echo "********************************************************************************"
485 echo ""
486
Duncan Sands9341b502011-10-20 20:10:58 +0000487 c_compiler="$CC"
488 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000489 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000490 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000491
Bill Wendling957cc212011-11-28 11:45:10 +0000492 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000493 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000494
Bill Wendling957cc212011-11-28 11:45:10 +0000495 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000496 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000497
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000498 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000499 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000500
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000501 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000502 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000503
Bill Wendling7b7d0772011-10-17 04:46:54 +0000504 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000505 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000506
507 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000508 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000509
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000510 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000511 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000512
Bill Wendling7b7d0772011-10-17 04:46:54 +0000513 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000514 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000515
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000516 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000517 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000518 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000519 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000520 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000521 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
522 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000523
Dan Liew7fa38a52015-07-14 19:46:19 +0000524 ########################################################################
525 # Phase 2: Build llvmCore with newly built clang from phase 1.
526 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
527 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
528 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000529 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000530 build_llvmCore 2 $Flavor \
531 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
532 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000533
Dan Liew7fa38a52015-07-14 19:46:19 +0000534 ########################################################################
535 # Phase 3: Build llvmCore with newly built clang from phase 2.
536 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
537 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
538 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000539 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000540 build_llvmCore 3 $Flavor \
541 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
542 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000543
Dan Liew7fa38a52015-07-14 19:46:19 +0000544 ########################################################################
545 # Testing: Test phase 3
546 echo "# Testing - built with clang"
547 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000548
Dan Liew7fa38a52015-07-14 19:46:19 +0000549 ########################################################################
550 # Compare .o files between Phase2 and Phase3 and report which ones
551 # differ.
552 if [ "$do_compare" = "yes" ]; then
553 echo
554 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000555 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
556 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
557 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000558 # case there are build paths in the debug info. On some systems,
559 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000560 if ! cmp -s \
561 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
562 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000563 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000564 fi
565 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000566 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000567done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000568
Bill Wendling957cc212011-11-28 11:45:10 +0000569) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000570
Bill Wendlingd6073842013-11-20 04:55:20 +0000571package_release
572
Bill Wendling06ac75c2011-10-18 17:27:12 +0000573set +e
574
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000575# Woo hoo!
576echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000577if [ "$use_gzip" = "yes" ]; then
578 echo "### Package: $Package.tar.gz"
579else
580 echo "### Package: $Package.tar.xz"
581fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000582echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000583
584echo "### Errors:"
585if [ -s "$LogDir/deferred_errors.log" ]; then
586 cat "$LogDir/deferred_errors.log"
587 exit 1
588else
589 echo "None."
590fi
591
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000592exit 0