blob: 73e31d46d5197c113825329462057f314a2f9220 [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"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000039do_lldb="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000040BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000041ExtraConfigureFlags=""
Daniel Sandersc2672e52015-07-17 10:40:40 +000042ExportBranch=""
Bill Wendlingcedf3a22010-09-08 18:32:31 +000043
Bill Wendlingcedf3a22010-09-08 18:32:31 +000044function usage() {
Hans Wennborg6072d2b2015-06-22 21:13:30 +000045 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000046 echo ""
Hans Wennborg6072d2b2015-06-22 21:13:30 +000047 echo " -release X.Y.Z The release version to test."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000048 echo " -rc NUM The pre-release candidate number."
49 echo " -final The final release candidate."
50 echo " -triple TRIPLE The target triple for this machine."
51 echo " -j NUM Number of compile jobs to run. [default: 3]"
52 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
53 echo " -no-checkout Don't checkout the sources from SVN."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000054 echo " -test-debug Test the debug build. [default: no]"
55 echo " -test-asserts Test with asserts on. [default: no]"
56 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
57 echo " -use-gzip Use gzip instead of xz."
Hans Wennborg0caeee02015-07-15 21:06:16 +000058 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
Daniel Sandersc2672e52015-07-17 10:40:40 +000059 echo " -svn-path DIR Use the specified DIR instead of a release."
60 echo " For example -svn-path trunk or -svn-path branches/release_37"
Renato Golin397b0da2015-07-22 18:21:39 +000061 echo " -no-rt Disable check-out & build Compiler-RT"
62 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000063 echo " -no-libunwind Disable check-out & build libunwind"
Renato Golin397b0da2015-07-22 18:21:39 +000064 echo " -no-test-suite Disable check-out & build test-suite"
Alexey Bataev860435c2015-12-10 05:45:58 +000065 echo " -no-openmp Disable check-out & build libomp"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000066 echo " -lldb Enable check-out & build lldb"
67 echo " -no-lldb Disable check-out & build lldb (default)"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000068}
69
70while [ $# -gt 0 ]; do
71 case $1 in
72 -release | --release )
73 shift
74 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000075 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000076 ;;
77 -rc | --rc | -RC | --RC )
78 shift
Bill Wendling957cc212011-11-28 11:45:10 +000079 RC="rc$1"
80 ;;
81 -final | --final )
82 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000083 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000084 -svn-path | --svn-path )
85 shift
86 Release="test"
87 Release_no_dot="test"
88 ExportBranch="$1"
89 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
90 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
91 echo " This is intended to aid new packagers in trialing "
92 echo " builds without requiring a tag to be created first"
93 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000094 -triple | --triple )
95 shift
96 Triple="$1"
97 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +000098 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +000099 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000100 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000101 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000102 -j* )
103 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
104 if [ -z "$NumJobs" ]; then
105 shift
106 NumJobs="$1"
107 fi
108 ;;
109 -build-dir | --build-dir | -builddir | --builddir )
110 shift
111 BuildDir="$1"
112 ;;
113 -no-checkout | --no-checkout )
114 do_checkout="no"
115 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000116 -test-debug | --test-debug )
117 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000118 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000119 -test-asserts | --test-asserts )
120 do_asserts="yes"
121 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000122 -no-compare-files | --no-compare-files )
123 do_compare="no"
124 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000125 -use-gzip | --use-gzip )
126 use_gzip="yes"
127 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000128 -no-rt )
129 do_rt="no"
130 ;;
131 -no-libs )
132 do_libs="no"
133 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000134 -no-libunwind )
135 do_libunwind="no"
136 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000137 -no-test-suite )
138 do_test_suite="no"
139 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000140 -no-openmp )
141 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000142 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000143 -lldb )
144 do_lldb="yes"
145 ;;
146 -no-lldb )
147 do_lldb="no"
148 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000149 -help | --help | -h | --h | -\? )
150 usage
151 exit 0
152 ;;
153 * )
154 echo "unknown option: $1"
155 usage
156 exit 1
157 ;;
158 esac
159 shift
160done
161
Hans Wennborg9012baa2016-08-09 16:46:02 +0000162if [ "$do_test_suite" = "yes" ]; then
163 # See llvm.org/PR26146.
164 echo Skipping test-suite build when using CMake.
165 echo It will still be exported.
166 do_test_suite="export-only"
Hans Wennborg813c0f72016-01-14 19:21:14 +0000167fi
168
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000169# Check required arguments.
170if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000171 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000172 exit 1
173fi
174if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000175 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000176 exit 1
177fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000178if [ -z "$ExportBranch" ]; then
179 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
180fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000181if [ -z "$Triple" ]; then
182 echo "error: no target triple specified"
183 exit 1
184fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000185
Duncan Sands274090a2010-09-08 19:50:25 +0000186# Figure out how many make processes to run.
187if [ -z "$NumJobs" ]; then
188 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
189fi
190if [ -z "$NumJobs" ]; then
191 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
192fi
193if [ -z "$NumJobs" ]; then
194 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
195fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000196if [ -z "$NumJobs" ]; then
197 NumJobs=3
198fi
199
Renato Golin397b0da2015-07-22 18:21:39 +0000200# Projects list
201projects="llvm cfe clang-tools-extra"
202if [ $do_rt = "yes" ]; then
203 projects="$projects compiler-rt"
204fi
205if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000206 projects="$projects libcxx libcxxabi"
207 if [ $do_libunwind = "yes" ]; then
208 projects="$projects libunwind"
209 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000210fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000211case $do_test_suite in
212 yes|export-only)
213 projects="$projects test-suite"
214 ;;
215esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000216if [ $do_openmp = "yes" ]; then
217 projects="$projects openmp"
218fi
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000219if [ $do_lldb = "yes" ]; then
220 projects="$projects lldb"
221fi
Renato Golin397b0da2015-07-22 18:21:39 +0000222
Bill Wendling9aa39432011-10-16 22:44:08 +0000223# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000224BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000225mkdir -p $BuildDir
226cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000227
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000228# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000229LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000230mkdir -p $LogDir
231
Bill Wendlingd6073842013-11-20 04:55:20 +0000232# Final package name.
233Package=clang+llvm-$Release
234if [ $RC != "final" ]; then
235 Package=$Package-$RC
236fi
237Package=$Package-$Triple
238
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000239# Errors to be highlighted at the end are written to this file.
240echo -n > $LogDir/deferred_errors.log
241
242function deferred_error() {
243 Phase="$1"
244 Flavor="$2"
245 Msg="$3"
246 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
247}
248
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000249# Make sure that a required program is available
250function check_program_exists() {
251 local program="$1"
252 if ! type -P $program > /dev/null 2>&1 ; then
253 echo "program '$1' not found !"
254 exit 1
255 fi
256}
257
Dimitry Andricca051602016-01-21 22:07:17 +0000258if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000259 check_program_exists 'chrpath'
260 check_program_exists 'file'
261 check_program_exists 'objdump'
262fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000263
264# Make sure that the URLs are valid.
265function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000266 for proj in $projects ; do
267 echo "# Validating $proj SVN URL"
268
Daniel Sandersc2672e52015-07-17 10:40:40 +0000269 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
270 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000271 exit 1
272 fi
273 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000274}
275
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000276# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000277function export_sources() {
278 check_valid_urls
279
Bill Wendling9aa39432011-10-16 22:44:08 +0000280 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000281 case $proj in
282 llvm)
283 projsrc=$proj.src
284 ;;
285 cfe)
286 projsrc=llvm.src/tools/clang
287 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000288 lldb)
289 projsrc=llvm.src/tools/$proj
290 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000291 clang-tools-extra)
292 projsrc=llvm.src/tools/clang/tools/extra
293 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000294 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000295 projsrc=llvm.src/projects/$proj
296 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000297 test-suite)
298 if [ $do_test_suite = 'yes' ]; then
299 projsrc=llvm.src/projects/$proj
300 else
301 projsrc=$proj.src
302 fi
303 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000304 *)
305 echo "error: unknown project $proj"
306 exit 1
307 ;;
308 esac
309
310 if [ -d $projsrc ]; then
311 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000312 continue
313 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000314 echo "# Exporting $proj $Release-$RC sources to $projsrc"
315 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000316 echo "error: failed to export $proj project"
317 exit 1
318 fi
319 done
320
Bill Wendling9aa39432011-10-16 22:44:08 +0000321 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000322}
323
324function configure_llvmCore() {
325 Phase="$1"
326 Flavor="$2"
327 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000328
329 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000330 Release )
331 BuildType="Release"
332 Assertions="OFF"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000333 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000334 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000335 BuildType="Release"
336 Assertions="ON"
Duncan Sands17cd9072010-09-13 13:45:33 +0000337 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000338 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000339 BuildType="Debug"
340 Assertions="ON"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000341 ;;
342 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000343 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000344 echo ""
345 return
346 ;;
347 esac
348
Bill Wendling9aa39432011-10-16 22:44:08 +0000349 echo "# Using C compiler: $c_compiler"
350 echo "# Using C++ compiler: $cxx_compiler"
351
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000352 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000353 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000354
Hans Wennborg9012baa2016-08-09 16:46:02 +0000355 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
356 cmake -G "Unix Makefiles" \
357 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000358 $ExtraConfigureFlags $BuildDir/llvm.src \
359 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
360 env CC="$c_compiler" CXX="$cxx_compiler" \
361 cmake -G "Unix Makefiles" \
362 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000363 $ExtraConfigureFlags $BuildDir/llvm.src \
364 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000365
Bill Wendling9aa39432011-10-16 22:44:08 +0000366 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000367}
368
369function build_llvmCore() {
370 Phase="$1"
371 Flavor="$2"
372 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000373 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000374
375 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000376 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000377 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
378 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000379 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000380
Bill Wendling957cc212011-11-28 11:45:10 +0000381 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000382 echo "# ${MAKE} install"
383 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000384 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000385 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
386 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000387}
388
389function test_llvmCore() {
390 Phase="$1"
391 Flavor="$2"
392 ObjDir="$3"
393
394 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000395 if ! ( ${MAKE} -j $NumJobs -k check-all \
396 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
397 deferred_error $Phase $Flavor "check-all failed"
398 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000399
Bill Wendling9aa39432011-10-16 22:44:08 +0000400 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000401}
402
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000403# Clean RPATH. Libtool adds the build directory to the search path, which is
404# not necessary --- and even harmful --- for the binary packages we release.
405function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000406 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000407 return
408 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000409 local InstallPath="$1"
410 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
411 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000412 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
413 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
414 if [ -n "$rpath" ]; then
415 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
416 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
417 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000418 fi
419 fi
420 done
421}
422
Bill Wendlingd6073842013-11-20 04:55:20 +0000423# Create a package of the release binaries.
424function package_release() {
425 cwd=`pwd`
426 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000427 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000428 if [ "$use_gzip" = "yes" ]; then
429 tar cfz $BuildDir/$Package.tar.gz $Package
430 else
431 tar cfJ $BuildDir/$Package.tar.xz $Package
432 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000433 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000434 cd $cwd
435}
436
Dan Liewbbe97552015-07-07 15:50:33 +0000437# Exit if any command fails
438# Note: pipefail is necessary for running build commands through
439# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
440set -e
441set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000442
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000443if [ "$do_checkout" = "yes" ]; then
444 export_sources
445fi
446
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000447(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000448Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000449if [ "$do_debug" = "yes" ]; then
450 Flavors="Debug $Flavors"
451fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000452if [ "$do_asserts" = "yes" ]; then
453 Flavors="$Flavors Release+Asserts"
454fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000455
456for Flavor in $Flavors ; do
457 echo ""
458 echo ""
459 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000460 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000461 echo " Build: $Flavor"
462 echo " System Info: "
463 echo " `uname -a`"
464 echo "********************************************************************************"
465 echo ""
466
Duncan Sands9341b502011-10-20 20:10:58 +0000467 c_compiler="$CC"
468 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000469 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000470 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000471
Bill Wendling957cc212011-11-28 11:45:10 +0000472 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000473 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000474
Bill Wendling957cc212011-11-28 11:45:10 +0000475 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000476 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000477
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000478 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000479 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000480
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000481 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000482 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000483
Bill Wendling7b7d0772011-10-17 04:46:54 +0000484 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000485 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000486
487 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000488 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000489
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000490 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000491 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000492
Bill Wendling7b7d0772011-10-17 04:46:54 +0000493 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000494 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000495
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000496 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000497 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000498 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000499 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000500 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000501 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
502 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000503
Dan Liew7fa38a52015-07-14 19:46:19 +0000504 ########################################################################
505 # Phase 2: Build llvmCore with newly built clang from phase 1.
506 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
507 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
508 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000509 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000510 build_llvmCore 2 $Flavor \
511 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
512 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000513
Dan Liew7fa38a52015-07-14 19:46:19 +0000514 ########################################################################
515 # Phase 3: Build llvmCore with newly built clang from phase 2.
516 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
517 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
518 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000519 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000520 build_llvmCore 3 $Flavor \
521 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
522 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000523
Dan Liew7fa38a52015-07-14 19:46:19 +0000524 ########################################################################
525 # Testing: Test phase 3
526 echo "# Testing - built with clang"
527 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000528
Dan Liew7fa38a52015-07-14 19:46:19 +0000529 ########################################################################
530 # Compare .o files between Phase2 and Phase3 and report which ones
531 # differ.
532 if [ "$do_compare" = "yes" ]; then
533 echo
534 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000535 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
536 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
537 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000538 # case there are build paths in the debug info. On some systems,
539 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000540 if ! cmp -s \
541 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
542 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000543 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000544 fi
545 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000546 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000547done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000548
Bill Wendling957cc212011-11-28 11:45:10 +0000549) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000550
Bill Wendlingd6073842013-11-20 04:55:20 +0000551package_release
552
Bill Wendling06ac75c2011-10-18 17:27:12 +0000553set +e
554
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000555# Woo hoo!
556echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000557if [ "$use_gzip" = "yes" ]; then
558 echo "### Package: $Package.tar.gz"
559else
560 echo "### Package: $Package.tar.xz"
561fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000562echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000563
564echo "### Errors:"
565if [ -s "$LogDir/deferred_errors.log" ]; then
566 cat "$LogDir/deferred_errors.log"
567 exit 1
568else
569 echo "None."
570fi
571
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000572exit 0