blob: b9cc38d35e287a6f1e734b557b2361f87f42602a [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 \
358 -DLLVM_CONFIGTIME="(timestamp not enabled)" \
359 $ExtraConfigureFlags $BuildDir/llvm.src \
360 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
361 env CC="$c_compiler" CXX="$cxx_compiler" \
362 cmake -G "Unix Makefiles" \
363 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
364 -DLLVM_CONFIGTIME="(timestamp not enabled)" \
365 $ExtraConfigureFlags $BuildDir/llvm.src \
366 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000367
Bill Wendling9aa39432011-10-16 22:44:08 +0000368 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000369}
370
371function build_llvmCore() {
372 Phase="$1"
373 Flavor="$2"
374 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000375 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000376
377 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000378 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000379 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
380 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000381 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000382
Bill Wendling957cc212011-11-28 11:45:10 +0000383 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000384 echo "# ${MAKE} install"
385 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000386 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000387 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
388 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000389}
390
391function test_llvmCore() {
392 Phase="$1"
393 Flavor="$2"
394 ObjDir="$3"
395
396 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000397 if ! ( ${MAKE} -j $NumJobs -k check-all \
398 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
399 deferred_error $Phase $Flavor "check-all failed"
400 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000401
Bill Wendling9aa39432011-10-16 22:44:08 +0000402 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000403}
404
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000405# Clean RPATH. Libtool adds the build directory to the search path, which is
406# not necessary --- and even harmful --- for the binary packages we release.
407function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000408 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000409 return
410 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000411 local InstallPath="$1"
412 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
413 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000414 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
415 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
416 if [ -n "$rpath" ]; then
417 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
418 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
419 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000420 fi
421 fi
422 done
423}
424
Bill Wendlingd6073842013-11-20 04:55:20 +0000425# Create a package of the release binaries.
426function package_release() {
427 cwd=`pwd`
428 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000429 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000430 if [ "$use_gzip" = "yes" ]; then
431 tar cfz $BuildDir/$Package.tar.gz $Package
432 else
433 tar cfJ $BuildDir/$Package.tar.xz $Package
434 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000435 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000436 cd $cwd
437}
438
Dan Liewbbe97552015-07-07 15:50:33 +0000439# Exit if any command fails
440# Note: pipefail is necessary for running build commands through
441# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
442set -e
443set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000444
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000445if [ "$do_checkout" = "yes" ]; then
446 export_sources
447fi
448
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000449(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000450Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000451if [ "$do_debug" = "yes" ]; then
452 Flavors="Debug $Flavors"
453fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000454if [ "$do_asserts" = "yes" ]; then
455 Flavors="$Flavors Release+Asserts"
456fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000457
458for Flavor in $Flavors ; do
459 echo ""
460 echo ""
461 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000462 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000463 echo " Build: $Flavor"
464 echo " System Info: "
465 echo " `uname -a`"
466 echo "********************************************************************************"
467 echo ""
468
Duncan Sands9341b502011-10-20 20:10:58 +0000469 c_compiler="$CC"
470 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000471 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000472 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000473
Bill Wendling957cc212011-11-28 11:45:10 +0000474 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000475 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000476
Bill Wendling957cc212011-11-28 11:45:10 +0000477 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000478 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000479
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000480 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000481 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000482
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000483 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000484 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000485
Bill Wendling7b7d0772011-10-17 04:46:54 +0000486 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000487 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000488
489 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000490 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000491
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000492 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000493 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000494
Bill Wendling7b7d0772011-10-17 04:46:54 +0000495 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000496 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000497
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000498 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000499 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000500 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000501 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000502 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000503 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
504 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000505
Dan Liew7fa38a52015-07-14 19:46:19 +0000506 ########################################################################
507 # Phase 2: Build llvmCore with newly built clang from phase 1.
508 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
509 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
510 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000511 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000512 build_llvmCore 2 $Flavor \
513 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
514 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000515
Dan Liew7fa38a52015-07-14 19:46:19 +0000516 ########################################################################
517 # Phase 3: Build llvmCore with newly built clang from phase 2.
518 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
519 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
520 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000521 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000522 build_llvmCore 3 $Flavor \
523 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
524 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000525
Dan Liew7fa38a52015-07-14 19:46:19 +0000526 ########################################################################
527 # Testing: Test phase 3
528 echo "# Testing - built with clang"
529 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000530
Dan Liew7fa38a52015-07-14 19:46:19 +0000531 ########################################################################
532 # Compare .o files between Phase2 and Phase3 and report which ones
533 # differ.
534 if [ "$do_compare" = "yes" ]; then
535 echo
536 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000537 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
538 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
539 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000540 # case there are build paths in the debug info. On some systems,
541 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000542 if ! cmp -s \
543 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
544 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000545 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000546 fi
547 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000548 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000549done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000550
Bill Wendling957cc212011-11-28 11:45:10 +0000551) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000552
Bill Wendlingd6073842013-11-20 04:55:20 +0000553package_release
554
Bill Wendling06ac75c2011-10-18 17:27:12 +0000555set +e
556
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000557# Woo hoo!
558echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000559if [ "$use_gzip" = "yes" ]; then
560 echo "### Package: $Package.tar.gz"
561else
562 echo "### Package: $Package.tar.xz"
563fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000564echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000565
566echo "### Errors:"
567if [ -s "$LogDir/deferred_errors.log" ]; then
568 cat "$LogDir/deferred_errors.log"
569 exit 1
570else
571 echo "None."
572fi
573
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000574exit 0