blob: 8d71bc7dcbe1d0d73e9de994ff8b9785c7df86ea [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"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000039BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000040use_autoconf="no"
41ExtraConfigureFlags=""
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."
59 echo " -use-autoconf Use autoconf instead of cmake"
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"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000067}
68
69while [ $# -gt 0 ]; do
70 case $1 in
71 -release | --release )
72 shift
73 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000074 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000075 ;;
76 -rc | --rc | -RC | --RC )
77 shift
Bill Wendling957cc212011-11-28 11:45:10 +000078 RC="rc$1"
79 ;;
80 -final | --final )
81 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000082 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000083 -svn-path | --svn-path )
84 shift
85 Release="test"
86 Release_no_dot="test"
87 ExportBranch="$1"
88 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
89 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
90 echo " This is intended to aid new packagers in trialing "
91 echo " builds without requiring a tag to be created first"
92 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000093 -triple | --triple )
94 shift
95 Triple="$1"
96 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +000097 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +000098 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +000099 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000100 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000101 -j* )
102 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
103 if [ -z "$NumJobs" ]; then
104 shift
105 NumJobs="$1"
106 fi
107 ;;
108 -build-dir | --build-dir | -builddir | --builddir )
109 shift
110 BuildDir="$1"
111 ;;
112 -no-checkout | --no-checkout )
113 do_checkout="no"
114 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000115 -test-debug | --test-debug )
116 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000117 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000118 -test-asserts | --test-asserts )
119 do_asserts="yes"
120 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000121 -no-compare-files | --no-compare-files )
122 do_compare="no"
123 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000124 -use-gzip | --use-gzip )
125 use_gzip="yes"
126 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000127 -use-autoconf | --use-autoconf )
128 use_autoconf="yes"
129 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000130 -no-rt )
131 do_rt="no"
132 ;;
133 -no-libs )
134 do_libs="no"
135 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000136 -no-libunwind )
137 do_libunwind="no"
138 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000139 -no-test-suite )
140 do_test_suite="no"
141 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000142 -no-openmp )
143 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000144 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000145 -help | --help | -h | --h | -\? )
146 usage
147 exit 0
148 ;;
149 * )
150 echo "unknown option: $1"
151 usage
152 exit 1
153 ;;
154 esac
155 shift
156done
157
Hans Wennborg813c0f72016-01-14 19:21:14 +0000158if [ "$use_autoconf" = "no" ]; then
Daniel Sanders20de54b2016-01-28 21:09:50 +0000159 if [ "$do_test_suite" = "yes" ]; then
160 # See llvm.org/PR26146.
161 echo Skipping test-suite build when using CMake.
162 echo It will still be exported.
163 do_test_suite="export-only"
164 fi
Hans Wennborg813c0f72016-01-14 19:21:14 +0000165fi
166
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000167# Check required arguments.
168if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000169 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000170 exit 1
171fi
172if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000173 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000174 exit 1
175fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000176if [ -z "$ExportBranch" ]; then
177 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
178fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000179if [ -z "$Triple" ]; then
180 echo "error: no target triple specified"
181 exit 1
182fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000183
Duncan Sands274090a2010-09-08 19:50:25 +0000184# Figure out how many make processes to run.
185if [ -z "$NumJobs" ]; then
186 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
187fi
188if [ -z "$NumJobs" ]; then
189 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
190fi
191if [ -z "$NumJobs" ]; then
192 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
193fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000194if [ -z "$NumJobs" ]; then
195 NumJobs=3
196fi
197
Renato Golin397b0da2015-07-22 18:21:39 +0000198# Projects list
199projects="llvm cfe clang-tools-extra"
200if [ $do_rt = "yes" ]; then
201 projects="$projects compiler-rt"
202fi
203if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000204 projects="$projects libcxx libcxxabi"
205 if [ $do_libunwind = "yes" ]; then
206 projects="$projects libunwind"
207 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000208fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000209case $do_test_suite in
210 yes|export-only)
211 projects="$projects test-suite"
212 ;;
213esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000214if [ $do_openmp = "yes" ]; then
215 projects="$projects openmp"
216fi
Renato Golin397b0da2015-07-22 18:21:39 +0000217
Bill Wendling9aa39432011-10-16 22:44:08 +0000218# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000219BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000220mkdir -p $BuildDir
221cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000222
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000223# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000224LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000225mkdir -p $LogDir
226
Bill Wendlingd6073842013-11-20 04:55:20 +0000227# Final package name.
228Package=clang+llvm-$Release
229if [ $RC != "final" ]; then
230 Package=$Package-$RC
231fi
232Package=$Package-$Triple
233
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000234# Errors to be highlighted at the end are written to this file.
235echo -n > $LogDir/deferred_errors.log
236
237function deferred_error() {
238 Phase="$1"
239 Flavor="$2"
240 Msg="$3"
241 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
242}
243
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000244# Make sure that a required program is available
245function check_program_exists() {
246 local program="$1"
247 if ! type -P $program > /dev/null 2>&1 ; then
248 echo "program '$1' not found !"
249 exit 1
250 fi
251}
252
Dimitry Andricca051602016-01-21 22:07:17 +0000253if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000254 check_program_exists 'chrpath'
255 check_program_exists 'file'
256 check_program_exists 'objdump'
257fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000258
259# Make sure that the URLs are valid.
260function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000261 for proj in $projects ; do
262 echo "# Validating $proj SVN URL"
263
Daniel Sandersc2672e52015-07-17 10:40:40 +0000264 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
265 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000266 exit 1
267 fi
268 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000269}
270
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000271# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000272function export_sources() {
273 check_valid_urls
274
Bill Wendling9aa39432011-10-16 22:44:08 +0000275 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000276 case $proj in
277 llvm)
278 projsrc=$proj.src
279 ;;
280 cfe)
281 projsrc=llvm.src/tools/clang
282 ;;
283 clang-tools-extra)
284 projsrc=llvm.src/tools/clang/tools/extra
285 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000286 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000287 projsrc=llvm.src/projects/$proj
288 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000289 test-suite)
290 if [ $do_test_suite = 'yes' ]; then
291 projsrc=llvm.src/projects/$proj
292 else
293 projsrc=$proj.src
294 fi
295 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000296 *)
297 echo "error: unknown project $proj"
298 exit 1
299 ;;
300 esac
301
302 if [ -d $projsrc ]; then
303 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000304 continue
305 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000306 echo "# Exporting $proj $Release-$RC sources to $projsrc"
307 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000308 echo "error: failed to export $proj project"
309 exit 1
310 fi
311 done
312
Bill Wendling9aa39432011-10-16 22:44:08 +0000313 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000314}
315
316function configure_llvmCore() {
317 Phase="$1"
318 Flavor="$2"
319 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000320
321 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000322 Release )
323 BuildType="Release"
324 Assertions="OFF"
325 ConfigureFlags="--enable-optimized --disable-assertions"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000326 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000327 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000328 BuildType="Release"
329 Assertions="ON"
330 ConfigureFlags="--enable-optimized --enable-assertions"
Duncan Sands17cd9072010-09-13 13:45:33 +0000331 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000332 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000333 BuildType="Debug"
334 Assertions="ON"
335 ConfigureFlags="--disable-optimized --enable-assertions"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000336 ;;
337 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000338 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000339 echo ""
340 return
341 ;;
342 esac
343
Bill Wendling9aa39432011-10-16 22:44:08 +0000344 echo "# Using C compiler: $c_compiler"
345 echo "# Using C++ compiler: $cxx_compiler"
346
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000347 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000348 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000349
350 if [ "$use_autoconf" = "yes" ]; then
351 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
352 $BuildDir/llvm.src/configure \
353 $ConfigureFlags --disable-timestamps $ExtraConfigureFlags \
354 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
355 env CC="$c_compiler" CXX="$cxx_compiler" \
356 $BuildDir/llvm.src/configure \
357 $ConfigureFlags --disable-timestamps $ExtraConfigureFlags \
358 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
359 else
360 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
361 cmake -G "Unix Makefiles" \
362 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
363 -DLLVM_ENABLE_TIMESTAMPS=OFF -DLLVM_CONFIGTIME="(timestamp not enabled)" \
364 $ExtraConfigureFlags $BuildDir/llvm.src \
365 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
366 env CC="$c_compiler" CXX="$cxx_compiler" \
367 cmake -G "Unix Makefiles" \
368 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
369 -DLLVM_ENABLE_TIMESTAMPS=OFF -DLLVM_CONFIGTIME="(timestamp not enabled)" \
370 $ExtraConfigureFlags $BuildDir/llvm.src \
371 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
372 fi
373
Bill Wendling9aa39432011-10-16 22:44:08 +0000374 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000375}
376
377function build_llvmCore() {
378 Phase="$1"
379 Flavor="$2"
380 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000381 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000382
383 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000384 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000385 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
386 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000387 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000388
Bill Wendling957cc212011-11-28 11:45:10 +0000389 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000390 echo "# ${MAKE} install"
391 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000392 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000393 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
394 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000395}
396
397function test_llvmCore() {
398 Phase="$1"
399 Flavor="$2"
400 ObjDir="$3"
401
402 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000403 if ! ( ${MAKE} -j $NumJobs -k check-all \
404 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
405 deferred_error $Phase $Flavor "check-all failed"
406 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000407
408 if [ "$use_autoconf" = "yes" ]; then
409 # In the cmake build, unit tests are run as part of check-all.
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000410 if ! ( ${MAKE} -k unittests 2>&1 | \
411 tee $LogDir/llvm.unittests-Phase$Phase-$Flavor.log ) ; then
412 deferred_error $Phase $Flavor "unittests failed"
413 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000414 fi
415
Bill Wendling9aa39432011-10-16 22:44:08 +0000416 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000417}
418
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000419# Clean RPATH. Libtool adds the build directory to the search path, which is
420# not necessary --- and even harmful --- for the binary packages we release.
421function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000422 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000423 return
424 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000425 local InstallPath="$1"
426 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
427 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000428 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
429 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
430 if [ -n "$rpath" ]; then
431 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
432 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
433 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000434 fi
435 fi
436 done
437}
438
Bill Wendlingd6073842013-11-20 04:55:20 +0000439# Create a package of the release binaries.
440function package_release() {
441 cwd=`pwd`
442 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000443 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000444 if [ "$use_gzip" = "yes" ]; then
445 tar cfz $BuildDir/$Package.tar.gz $Package
446 else
447 tar cfJ $BuildDir/$Package.tar.xz $Package
448 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000449 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000450 cd $cwd
451}
452
Dan Liewbbe97552015-07-07 15:50:33 +0000453# Exit if any command fails
454# Note: pipefail is necessary for running build commands through
455# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
456set -e
457set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000458
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000459if [ "$do_checkout" = "yes" ]; then
460 export_sources
461fi
462
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000463(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000464Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000465if [ "$do_debug" = "yes" ]; then
466 Flavors="Debug $Flavors"
467fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000468if [ "$do_asserts" = "yes" ]; then
469 Flavors="$Flavors Release+Asserts"
470fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000471
472for Flavor in $Flavors ; do
473 echo ""
474 echo ""
475 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000476 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000477 echo " Build: $Flavor"
478 echo " System Info: "
479 echo " `uname -a`"
480 echo "********************************************************************************"
481 echo ""
482
Duncan Sands9341b502011-10-20 20:10:58 +0000483 c_compiler="$CC"
484 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000485 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000486 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000487
Bill Wendling957cc212011-11-28 11:45:10 +0000488 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000489 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000490
Bill Wendling957cc212011-11-28 11:45:10 +0000491 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000492 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000493
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000494 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000495 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000496
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000497 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000498 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000499
Bill Wendling7b7d0772011-10-17 04:46:54 +0000500 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000501 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000502
503 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000504 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000505
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000506 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000507 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000508
Bill Wendling7b7d0772011-10-17 04:46:54 +0000509 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000510 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000511
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000512 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000513 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000514 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000515 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000516 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000517 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
518 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000519
Dan Liew7fa38a52015-07-14 19:46:19 +0000520 ########################################################################
521 # Phase 2: Build llvmCore with newly built clang from phase 1.
522 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
523 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
524 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000525 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000526 build_llvmCore 2 $Flavor \
527 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
528 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000529
Dan Liew7fa38a52015-07-14 19:46:19 +0000530 ########################################################################
531 # Phase 3: Build llvmCore with newly built clang from phase 2.
532 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
533 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
534 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000535 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000536 build_llvmCore 3 $Flavor \
537 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
538 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000539
Dan Liew7fa38a52015-07-14 19:46:19 +0000540 ########################################################################
541 # Testing: Test phase 3
542 echo "# Testing - built with clang"
543 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000544
Dan Liew7fa38a52015-07-14 19:46:19 +0000545 ########################################################################
546 # Compare .o files between Phase2 and Phase3 and report which ones
547 # differ.
548 if [ "$do_compare" = "yes" ]; then
549 echo
550 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000551 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
552 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
553 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000554 # case there are build paths in the debug info. On some systems,
555 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000556 if ! cmp -s \
557 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
558 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000559 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000560 fi
561 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000562 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000563done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000564
Bill Wendling957cc212011-11-28 11:45:10 +0000565) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000566
Bill Wendlingd6073842013-11-20 04:55:20 +0000567package_release
568
Bill Wendling06ac75c2011-10-18 17:27:12 +0000569set +e
570
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000571# Woo hoo!
572echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000573if [ "$use_gzip" = "yes" ]; then
574 echo "### Package: $Package.tar.gz"
575else
576 echo "### Package: $Package.tar.xz"
577fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000578echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000579
580echo "### Errors:"
581if [ -s "$LogDir/deferred_errors.log" ]; then
582 cat "$LogDir/deferred_errors.log"
583 exit 1
584else
585 echo "None."
586fi
587
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000588exit 0