blob: 642bb670e7e2164b7f97e292f73e4fcce00e86a5 [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"
Pengxuan Zhengac6595c2017-01-18 01:03:29 +000040do_polly="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000041BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000042ExtraConfigureFlags=""
Daniel Sandersc2672e52015-07-17 10:40:40 +000043ExportBranch=""
Bill Wendlingcedf3a22010-09-08 18:32:31 +000044
Bill Wendlingcedf3a22010-09-08 18:32:31 +000045function usage() {
Hans Wennborg6072d2b2015-06-22 21:13:30 +000046 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000047 echo ""
Hans Wennborg6072d2b2015-06-22 21:13:30 +000048 echo " -release X.Y.Z The release version to test."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000049 echo " -rc NUM The pre-release candidate number."
50 echo " -final The final release candidate."
51 echo " -triple TRIPLE The target triple for this machine."
52 echo " -j NUM Number of compile jobs to run. [default: 3]"
53 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
54 echo " -no-checkout Don't checkout the sources from SVN."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000055 echo " -test-debug Test the debug build. [default: no]"
56 echo " -test-asserts Test with asserts on. [default: no]"
57 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
58 echo " -use-gzip Use gzip instead of xz."
Hans Wennborg0caeee02015-07-15 21:06:16 +000059 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
Daniel Sandersc2672e52015-07-17 10:40:40 +000060 echo " -svn-path DIR Use the specified DIR instead of a release."
61 echo " For example -svn-path trunk or -svn-path branches/release_37"
Renato Golin397b0da2015-07-22 18:21:39 +000062 echo " -no-rt Disable check-out & build Compiler-RT"
63 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000064 echo " -no-libunwind Disable check-out & build libunwind"
Renato Golin397b0da2015-07-22 18:21:39 +000065 echo " -no-test-suite Disable check-out & build test-suite"
Alexey Bataev860435c2015-12-10 05:45:58 +000066 echo " -no-openmp Disable check-out & build libomp"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000067 echo " -lldb Enable check-out & build lldb"
68 echo " -no-lldb Disable check-out & build lldb (default)"
Pengxuan Zhengac6595c2017-01-18 01:03:29 +000069 echo " -polly Enable check-out & build Polly"
70 echo " -no-polly Disable check-out & build Polly (default)"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000071}
72
73while [ $# -gt 0 ]; do
74 case $1 in
75 -release | --release )
76 shift
77 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000078 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000079 ;;
80 -rc | --rc | -RC | --RC )
81 shift
Bill Wendling957cc212011-11-28 11:45:10 +000082 RC="rc$1"
83 ;;
84 -final | --final )
85 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000086 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000087 -svn-path | --svn-path )
88 shift
89 Release="test"
90 Release_no_dot="test"
91 ExportBranch="$1"
92 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
93 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
94 echo " This is intended to aid new packagers in trialing "
95 echo " builds without requiring a tag to be created first"
96 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000097 -triple | --triple )
98 shift
99 Triple="$1"
100 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000101 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000102 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000103 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000104 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000105 -j* )
106 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
107 if [ -z "$NumJobs" ]; then
108 shift
109 NumJobs="$1"
110 fi
111 ;;
112 -build-dir | --build-dir | -builddir | --builddir )
113 shift
114 BuildDir="$1"
115 ;;
116 -no-checkout | --no-checkout )
117 do_checkout="no"
118 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000119 -test-debug | --test-debug )
120 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000121 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000122 -test-asserts | --test-asserts )
123 do_asserts="yes"
124 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000125 -no-compare-files | --no-compare-files )
126 do_compare="no"
127 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000128 -use-gzip | --use-gzip )
129 use_gzip="yes"
130 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000131 -no-rt )
132 do_rt="no"
133 ;;
134 -no-libs )
135 do_libs="no"
136 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000137 -no-libunwind )
138 do_libunwind="no"
139 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000140 -no-test-suite )
141 do_test_suite="no"
142 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000143 -no-openmp )
144 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000145 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000146 -lldb )
147 do_lldb="yes"
148 ;;
149 -no-lldb )
150 do_lldb="no"
151 ;;
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000152 -polly )
153 do_polly="yes"
154 ;;
155 -no-polly )
156 do_polly="no"
157 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000158 -help | --help | -h | --h | -\? )
159 usage
160 exit 0
161 ;;
162 * )
163 echo "unknown option: $1"
164 usage
165 exit 1
166 ;;
167 esac
168 shift
169done
170
Hans Wennborg9012baa2016-08-09 16:46:02 +0000171if [ "$do_test_suite" = "yes" ]; then
172 # See llvm.org/PR26146.
173 echo Skipping test-suite build when using CMake.
174 echo It will still be exported.
175 do_test_suite="export-only"
Hans Wennborg813c0f72016-01-14 19:21:14 +0000176fi
177
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000178# Check required arguments.
179if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000180 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000181 exit 1
182fi
183if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000184 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000185 exit 1
186fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000187if [ -z "$ExportBranch" ]; then
188 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
189fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000190if [ -z "$Triple" ]; then
191 echo "error: no target triple specified"
192 exit 1
193fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000194
Duncan Sands274090a2010-09-08 19:50:25 +0000195# Figure out how many make processes to run.
196if [ -z "$NumJobs" ]; then
197 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
198fi
199if [ -z "$NumJobs" ]; then
200 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
201fi
202if [ -z "$NumJobs" ]; then
203 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
204fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000205if [ -z "$NumJobs" ]; then
206 NumJobs=3
207fi
208
Renato Golin397b0da2015-07-22 18:21:39 +0000209# Projects list
210projects="llvm cfe clang-tools-extra"
211if [ $do_rt = "yes" ]; then
212 projects="$projects compiler-rt"
213fi
214if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000215 projects="$projects libcxx libcxxabi"
216 if [ $do_libunwind = "yes" ]; then
217 projects="$projects libunwind"
218 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000219fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000220case $do_test_suite in
221 yes|export-only)
222 projects="$projects test-suite"
223 ;;
224esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000225if [ $do_openmp = "yes" ]; then
226 projects="$projects openmp"
227fi
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000228if [ $do_lldb = "yes" ]; then
229 projects="$projects lldb"
230fi
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000231if [ $do_polly = "yes" ]; then
232 projects="$projects polly"
233fi
Renato Golin397b0da2015-07-22 18:21:39 +0000234
Bill Wendling9aa39432011-10-16 22:44:08 +0000235# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000236BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000237mkdir -p $BuildDir
238cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000239
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000240# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000241LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000242mkdir -p $LogDir
243
Bill Wendlingd6073842013-11-20 04:55:20 +0000244# Final package name.
245Package=clang+llvm-$Release
246if [ $RC != "final" ]; then
247 Package=$Package-$RC
248fi
249Package=$Package-$Triple
250
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000251# Errors to be highlighted at the end are written to this file.
252echo -n > $LogDir/deferred_errors.log
253
254function deferred_error() {
255 Phase="$1"
256 Flavor="$2"
257 Msg="$3"
258 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
259}
260
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000261# Make sure that a required program is available
262function check_program_exists() {
263 local program="$1"
264 if ! type -P $program > /dev/null 2>&1 ; then
265 echo "program '$1' not found !"
266 exit 1
267 fi
268}
269
Dimitry Andricca051602016-01-21 22:07:17 +0000270if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000271 check_program_exists 'chrpath'
272 check_program_exists 'file'
273 check_program_exists 'objdump'
274fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000275
276# Make sure that the URLs are valid.
277function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000278 for proj in $projects ; do
279 echo "# Validating $proj SVN URL"
280
Daniel Sandersc2672e52015-07-17 10:40:40 +0000281 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
282 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000283 exit 1
284 fi
285 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000286}
287
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000288# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000289function export_sources() {
290 check_valid_urls
291
Bill Wendling9aa39432011-10-16 22:44:08 +0000292 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000293 case $proj in
294 llvm)
295 projsrc=$proj.src
296 ;;
297 cfe)
298 projsrc=llvm.src/tools/clang
299 ;;
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000300 lldb|polly)
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000301 projsrc=llvm.src/tools/$proj
302 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000303 clang-tools-extra)
304 projsrc=llvm.src/tools/clang/tools/extra
305 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000306 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000307 projsrc=llvm.src/projects/$proj
308 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000309 test-suite)
310 if [ $do_test_suite = 'yes' ]; then
311 projsrc=llvm.src/projects/$proj
312 else
313 projsrc=$proj.src
314 fi
315 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000316 *)
317 echo "error: unknown project $proj"
318 exit 1
319 ;;
320 esac
321
322 if [ -d $projsrc ]; then
323 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000324 continue
325 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000326 echo "# Exporting $proj $Release-$RC sources to $projsrc"
327 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000328 echo "error: failed to export $proj project"
329 exit 1
330 fi
331 done
332
Bill Wendling9aa39432011-10-16 22:44:08 +0000333 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000334}
335
336function configure_llvmCore() {
337 Phase="$1"
338 Flavor="$2"
339 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000340
341 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000342 Release )
343 BuildType="Release"
344 Assertions="OFF"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000345 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000346 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000347 BuildType="Release"
348 Assertions="ON"
Duncan Sands17cd9072010-09-13 13:45:33 +0000349 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000350 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000351 BuildType="Debug"
352 Assertions="ON"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000353 ;;
354 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000355 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000356 echo ""
357 return
358 ;;
359 esac
360
Bill Wendling9aa39432011-10-16 22:44:08 +0000361 echo "# Using C compiler: $c_compiler"
362 echo "# Using C++ compiler: $cxx_compiler"
363
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000364 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000365 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000366
Hans Wennborg9012baa2016-08-09 16:46:02 +0000367 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
368 cmake -G "Unix Makefiles" \
369 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000370 $ExtraConfigureFlags $BuildDir/llvm.src \
371 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
372 env CC="$c_compiler" CXX="$cxx_compiler" \
373 cmake -G "Unix Makefiles" \
374 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000375 $ExtraConfigureFlags $BuildDir/llvm.src \
376 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000377
Bill Wendling9aa39432011-10-16 22:44:08 +0000378 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000379}
380
381function build_llvmCore() {
382 Phase="$1"
383 Flavor="$2"
384 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000385 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000386
387 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000388 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000389 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
390 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000391 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000392
Bill Wendling957cc212011-11-28 11:45:10 +0000393 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000394 echo "# ${MAKE} install"
395 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000396 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000397 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
398 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000399}
400
401function test_llvmCore() {
402 Phase="$1"
403 Flavor="$2"
404 ObjDir="$3"
405
406 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000407 if ! ( ${MAKE} -j $NumJobs -k check-all \
408 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
409 deferred_error $Phase $Flavor "check-all failed"
410 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000411
Bill Wendling9aa39432011-10-16 22:44:08 +0000412 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000413}
414
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000415# Clean RPATH. Libtool adds the build directory to the search path, which is
416# not necessary --- and even harmful --- for the binary packages we release.
417function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000418 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000419 return
420 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000421 local InstallPath="$1"
422 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
423 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000424 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
425 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
426 if [ -n "$rpath" ]; then
427 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
428 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
429 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000430 fi
431 fi
432 done
433}
434
Bill Wendlingd6073842013-11-20 04:55:20 +0000435# Create a package of the release binaries.
436function package_release() {
437 cwd=`pwd`
438 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000439 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000440 if [ "$use_gzip" = "yes" ]; then
441 tar cfz $BuildDir/$Package.tar.gz $Package
442 else
443 tar cfJ $BuildDir/$Package.tar.xz $Package
444 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000445 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000446 cd $cwd
447}
448
Dan Liewbbe97552015-07-07 15:50:33 +0000449# Exit if any command fails
450# Note: pipefail is necessary for running build commands through
451# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
452set -e
453set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000454
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000455if [ "$do_checkout" = "yes" ]; then
456 export_sources
457fi
458
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000459(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000460Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000461if [ "$do_debug" = "yes" ]; then
462 Flavors="Debug $Flavors"
463fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000464if [ "$do_asserts" = "yes" ]; then
465 Flavors="$Flavors Release+Asserts"
466fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000467
468for Flavor in $Flavors ; do
469 echo ""
470 echo ""
471 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000472 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000473 echo " Build: $Flavor"
474 echo " System Info: "
475 echo " `uname -a`"
476 echo "********************************************************************************"
477 echo ""
478
Duncan Sands9341b502011-10-20 20:10:58 +0000479 c_compiler="$CC"
480 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000481 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000482 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000483
Bill Wendling957cc212011-11-28 11:45:10 +0000484 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000485 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000486
Bill Wendling957cc212011-11-28 11:45:10 +0000487 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000488 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000489
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000490 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000491 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000492
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000493 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000494 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000495
Bill Wendling7b7d0772011-10-17 04:46:54 +0000496 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000497 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000498
499 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000500 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000501
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000502 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000503 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000504
Bill Wendling7b7d0772011-10-17 04:46:54 +0000505 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000506 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000507
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000508 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000509 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000510 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000511 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000512 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000513 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
514 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000515
Dan Liew7fa38a52015-07-14 19:46:19 +0000516 ########################################################################
517 # Phase 2: Build llvmCore with newly built clang from phase 1.
518 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
519 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
520 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000521 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000522 build_llvmCore 2 $Flavor \
523 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
524 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000525
Dan Liew7fa38a52015-07-14 19:46:19 +0000526 ########################################################################
527 # Phase 3: Build llvmCore with newly built clang from phase 2.
528 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
529 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
530 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000531 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000532 build_llvmCore 3 $Flavor \
533 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
534 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000535
Dan Liew7fa38a52015-07-14 19:46:19 +0000536 ########################################################################
537 # Testing: Test phase 3
538 echo "# Testing - built with clang"
539 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000540
Dan Liew7fa38a52015-07-14 19:46:19 +0000541 ########################################################################
542 # Compare .o files between Phase2 and Phase3 and report which ones
543 # differ.
544 if [ "$do_compare" = "yes" ]; then
545 echo
546 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000547 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
548 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
549 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000550 # case there are build paths in the debug info. On some systems,
551 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000552 if ! cmp -s \
553 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
554 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000555 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000556 fi
557 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000558 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000559done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000560
Bill Wendling957cc212011-11-28 11:45:10 +0000561) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000562
Bill Wendlingd6073842013-11-20 04:55:20 +0000563package_release
564
Bill Wendling06ac75c2011-10-18 17:27:12 +0000565set +e
566
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000567# Woo hoo!
568echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000569if [ "$use_gzip" = "yes" ]; then
570 echo "### Package: $Package.tar.gz"
571else
572 echo "### Package: $Package.tar.xz"
573fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000574echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000575
576echo "### Errors:"
577if [ -s "$LogDir/deferred_errors.log" ]; then
578 cat "$LogDir/deferred_errors.log"
579 exit 1
580else
581 echo "None."
582fi
583
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000584exit 0