blob: 66a2c578083ea9d24058600a9ab126755f32c0fd [file] [log] [blame]
Bill Wendlingf96a5bc2011-10-19 09:25:49 +00001#!/usr/bin/env bash
Bill Wendlingcedf3a22010-09-08 18:32:31 +00002#===-- test-release.sh - Test the LLVM release candidates ------------------===#
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is distributed under the University of Illinois Open Source
7# License.
8#
9#===------------------------------------------------------------------------===#
10#
11# Download, build, and test the release candidate for an LLVM release.
12#
13#===------------------------------------------------------------------------===#
14
Dimitry Andricca051602016-01-21 22:07:17 +000015System=`uname -s`
16if [ "$System" = "FreeBSD" ]; then
Bill Wendlingcfe82322011-10-19 08:42:07 +000017 MAKE=gmake
18else
19 MAKE=make
20fi
21
Bill Wendling9aa39432011-10-16 22:44:08 +000022# Base SVN URL for the sources.
23Base_url="http://llvm.org/svn/llvm-project"
24
Bill Wendlingcedf3a22010-09-08 18:32:31 +000025Release=""
26Release_no_dot=""
27RC=""
Bill Wendlingd6073842013-11-20 04:55:20 +000028Triple=""
Bill Wendling1585fea2013-11-24 05:29:35 +000029use_gzip="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000030do_checkout="yes"
Bill Wendling9aa39432011-10-16 22:44:08 +000031do_debug="no"
Bill Wendling7b7d0772011-10-17 04:46:54 +000032do_asserts="no"
Bill Wendlingd70cde12012-04-02 23:27:43 +000033do_compare="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000034do_rt="yes"
35do_libs="yes"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000036do_libunwind="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000037do_test_suite="yes"
Alexey Bataev860435c2015-12-10 05:45:58 +000038do_openmp="yes"
Dimitry Andric434fa952017-02-04 22:24:55 +000039do_lld="yes"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000040do_lldb="no"
Pengxuan Zheng4a99e372017-06-20 01:04:25 +000041do_polly="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000042BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000043ExtraConfigureFlags=""
Daniel Sandersc2672e52015-07-17 10:40:40 +000044ExportBranch=""
Bill Wendlingcedf3a22010-09-08 18:32:31 +000045
Bill Wendlingcedf3a22010-09-08 18:32:31 +000046function usage() {
Hans Wennborg6072d2b2015-06-22 21:13:30 +000047 echo "usage: `basename $0` -release X.Y.Z -rc NUM [OPTIONS]"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000048 echo ""
Hans Wennborg6072d2b2015-06-22 21:13:30 +000049 echo " -release X.Y.Z The release version to test."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000050 echo " -rc NUM The pre-release candidate number."
51 echo " -final The final release candidate."
52 echo " -triple TRIPLE The target triple for this machine."
53 echo " -j NUM Number of compile jobs to run. [default: 3]"
54 echo " -build-dir DIR Directory to perform testing in. [default: pwd]"
55 echo " -no-checkout Don't checkout the sources from SVN."
Daniel Sandersf226aaf2014-12-04 17:15:35 +000056 echo " -test-debug Test the debug build. [default: no]"
57 echo " -test-asserts Test with asserts on. [default: no]"
58 echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
59 echo " -use-gzip Use gzip instead of xz."
Hans Wennborg0caeee02015-07-15 21:06:16 +000060 echo " -configure-flags FLAGS Extra flags to pass to the configure step."
Daniel Sandersc2672e52015-07-17 10:40:40 +000061 echo " -svn-path DIR Use the specified DIR instead of a release."
62 echo " For example -svn-path trunk or -svn-path branches/release_37"
Renato Golin397b0da2015-07-22 18:21:39 +000063 echo " -no-rt Disable check-out & build Compiler-RT"
64 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000065 echo " -no-libunwind Disable check-out & build libunwind"
Renato Golin397b0da2015-07-22 18:21:39 +000066 echo " -no-test-suite Disable check-out & build test-suite"
Alexey Bataev860435c2015-12-10 05:45:58 +000067 echo " -no-openmp Disable check-out & build libomp"
Dimitry Andric434fa952017-02-04 22:24:55 +000068 echo " -no-lld Disable check-out & build lld"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000069 echo " -lldb Enable check-out & build lldb"
70 echo " -no-lldb Disable check-out & build lldb (default)"
Pengxuan Zheng4a99e372017-06-20 01:04:25 +000071 echo " -no-polly Disable check-out & build Polly"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000072}
73
74while [ $# -gt 0 ]; do
75 case $1 in
76 -release | --release )
77 shift
78 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000079 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000080 ;;
81 -rc | --rc | -RC | --RC )
82 shift
Bill Wendling957cc212011-11-28 11:45:10 +000083 RC="rc$1"
84 ;;
85 -final | --final )
86 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000087 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000088 -svn-path | --svn-path )
89 shift
90 Release="test"
91 Release_no_dot="test"
92 ExportBranch="$1"
93 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
94 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
95 echo " This is intended to aid new packagers in trialing "
96 echo " builds without requiring a tag to be created first"
97 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000098 -triple | --triple )
99 shift
100 Triple="$1"
101 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000102 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000103 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000104 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000105 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000106 -j* )
107 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
108 if [ -z "$NumJobs" ]; then
109 shift
110 NumJobs="$1"
111 fi
112 ;;
113 -build-dir | --build-dir | -builddir | --builddir )
114 shift
115 BuildDir="$1"
116 ;;
117 -no-checkout | --no-checkout )
118 do_checkout="no"
119 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000120 -test-debug | --test-debug )
121 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000122 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000123 -test-asserts | --test-asserts )
124 do_asserts="yes"
125 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000126 -no-compare-files | --no-compare-files )
127 do_compare="no"
128 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000129 -use-gzip | --use-gzip )
130 use_gzip="yes"
131 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000132 -no-rt )
133 do_rt="no"
134 ;;
135 -no-libs )
136 do_libs="no"
137 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000138 -no-libunwind )
139 do_libunwind="no"
140 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000141 -no-test-suite )
142 do_test_suite="no"
143 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000144 -no-openmp )
145 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000146 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000147 -no-lld )
148 do_lld="no"
149 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000150 -lldb )
151 do_lldb="yes"
152 ;;
153 -no-lldb )
154 do_lldb="no"
155 ;;
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000156 -no-polly )
157 do_polly="no"
158 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000159 -help | --help | -h | --h | -\? )
160 usage
161 exit 0
162 ;;
163 * )
164 echo "unknown option: $1"
165 usage
166 exit 1
167 ;;
168 esac
169 shift
170done
171
172# Check required arguments.
173if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000174 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000175 exit 1
176fi
177if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000178 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000179 exit 1
180fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000181if [ -z "$ExportBranch" ]; then
182 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
183fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000184if [ -z "$Triple" ]; then
185 echo "error: no target triple specified"
186 exit 1
187fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000188
Duncan Sands274090a2010-09-08 19:50:25 +0000189# Figure out how many make processes to run.
190if [ -z "$NumJobs" ]; then
191 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
192fi
193if [ -z "$NumJobs" ]; then
194 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
195fi
196if [ -z "$NumJobs" ]; then
197 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
198fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000199if [ -z "$NumJobs" ]; then
200 NumJobs=3
201fi
202
Renato Golin397b0da2015-07-22 18:21:39 +0000203# Projects list
204projects="llvm cfe clang-tools-extra"
205if [ $do_rt = "yes" ]; then
206 projects="$projects compiler-rt"
207fi
208if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000209 projects="$projects libcxx libcxxabi"
210 if [ $do_libunwind = "yes" ]; then
211 projects="$projects libunwind"
212 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000213fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000214case $do_test_suite in
215 yes|export-only)
216 projects="$projects test-suite"
217 ;;
218esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000219if [ $do_openmp = "yes" ]; then
220 projects="$projects openmp"
221fi
Dimitry Andric434fa952017-02-04 22:24:55 +0000222if [ $do_lld = "yes" ]; then
223 projects="$projects lld"
224fi
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000225if [ $do_lldb = "yes" ]; then
226 projects="$projects lldb"
227fi
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000228if [ $do_polly = "yes" ]; then
229 projects="$projects polly"
230fi
Renato Golin397b0da2015-07-22 18:21:39 +0000231
Bill Wendling9aa39432011-10-16 22:44:08 +0000232# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000233BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000234mkdir -p $BuildDir
235cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000236
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000237# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000238LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000239mkdir -p $LogDir
240
Bill Wendlingd6073842013-11-20 04:55:20 +0000241# Final package name.
242Package=clang+llvm-$Release
243if [ $RC != "final" ]; then
244 Package=$Package-$RC
245fi
246Package=$Package-$Triple
247
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000248# Errors to be highlighted at the end are written to this file.
249echo -n > $LogDir/deferred_errors.log
250
251function deferred_error() {
252 Phase="$1"
253 Flavor="$2"
254 Msg="$3"
255 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
256}
257
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000258# Make sure that a required program is available
259function check_program_exists() {
260 local program="$1"
261 if ! type -P $program > /dev/null 2>&1 ; then
262 echo "program '$1' not found !"
263 exit 1
264 fi
265}
266
Dimitry Andricca051602016-01-21 22:07:17 +0000267if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000268 check_program_exists 'chrpath'
269 check_program_exists 'file'
270 check_program_exists 'objdump'
271fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000272
273# Make sure that the URLs are valid.
274function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000275 for proj in $projects ; do
276 echo "# Validating $proj SVN URL"
277
Daniel Sandersc2672e52015-07-17 10:40:40 +0000278 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
279 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000280 exit 1
281 fi
282 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000283}
284
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000285# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000286function export_sources() {
287 check_valid_urls
288
Bill Wendling9aa39432011-10-16 22:44:08 +0000289 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000290 case $proj in
291 llvm)
292 projsrc=$proj.src
293 ;;
294 cfe)
295 projsrc=llvm.src/tools/clang
296 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000297 lld|lldb|polly)
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000298 projsrc=llvm.src/tools/$proj
299 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000300 clang-tools-extra)
301 projsrc=llvm.src/tools/clang/tools/extra
302 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000303 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000304 projsrc=llvm.src/projects/$proj
305 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000306 test-suite)
Tom Stellardeb6fd412017-06-08 21:31:59 +0000307 projsrc=$proj.src
Daniel Sanders20de54b2016-01-28 21:09:50 +0000308 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000309 *)
310 echo "error: unknown project $proj"
311 exit 1
312 ;;
313 esac
314
315 if [ -d $projsrc ]; then
316 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000317 continue
318 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000319 echo "# Exporting $proj $Release-$RC sources to $projsrc"
320 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000321 echo "error: failed to export $proj project"
322 exit 1
323 fi
324 done
325
Bill Wendling9aa39432011-10-16 22:44:08 +0000326 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000327}
328
329function configure_llvmCore() {
330 Phase="$1"
331 Flavor="$2"
332 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000333
334 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000335 Release )
336 BuildType="Release"
337 Assertions="OFF"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000338 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000339 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000340 BuildType="Release"
341 Assertions="ON"
Duncan Sands17cd9072010-09-13 13:45:33 +0000342 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000343 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000344 BuildType="Debug"
345 Assertions="ON"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000346 ;;
347 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000348 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000349 echo ""
350 return
351 ;;
352 esac
353
Bill Wendling9aa39432011-10-16 22:44:08 +0000354 echo "# Using C compiler: $c_compiler"
355 echo "# Using C++ compiler: $cxx_compiler"
356
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000357 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000358 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000359
Hans Wennborg9012baa2016-08-09 16:46:02 +0000360 echo "#" 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
365 env CC="$c_compiler" CXX="$cxx_compiler" \
366 cmake -G "Unix Makefiles" \
367 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000368 $ExtraConfigureFlags $BuildDir/llvm.src \
369 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000370
Bill Wendling9aa39432011-10-16 22:44:08 +0000371 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000372}
373
374function build_llvmCore() {
375 Phase="$1"
376 Flavor="$2"
377 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000378 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000379
380 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000381 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000382 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
383 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000384 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000385
Bill Wendling957cc212011-11-28 11:45:10 +0000386 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000387 echo "# ${MAKE} install"
388 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000389 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000390 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
391 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000392}
393
394function test_llvmCore() {
395 Phase="$1"
396 Flavor="$2"
397 ObjDir="$3"
398
399 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000400 if ! ( ${MAKE} -j $NumJobs -k check-all \
401 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
402 deferred_error $Phase $Flavor "check-all failed"
403 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000404
Tom Stellardeb6fd412017-06-08 21:31:59 +0000405 if [ $do_test_suite = 'yes' ]; then
Tom Stellardeb6fd412017-06-08 21:31:59 +0000406 cd $TestSuiteBuildDir
Tom Stellard2e173662017-06-15 23:05:21 +0000407 env CC="$c_compiler" CXX="$cxx_compiler" \
408 cmake $TestSuiteSrcDir -DTEST_SUITE_LIT=$Lit
Tom Stellardeb6fd412017-06-08 21:31:59 +0000409 if ! ( ${MAKE} -j $NumJobs -k check \
410 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
411 deferred_error $Phase $Flavor "test suite failed"
412 fi
413 fi
Bill Wendling9aa39432011-10-16 22:44:08 +0000414 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000415}
416
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000417# Clean RPATH. Libtool adds the build directory to the search path, which is
418# not necessary --- and even harmful --- for the binary packages we release.
419function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000420 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000421 return
422 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000423 local InstallPath="$1"
424 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
425 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000426 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
427 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
428 if [ -n "$rpath" ]; then
429 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
430 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
431 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000432 fi
433 fi
434 done
435}
436
Bill Wendlingd6073842013-11-20 04:55:20 +0000437# Create a package of the release binaries.
438function package_release() {
439 cwd=`pwd`
440 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000441 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000442 if [ "$use_gzip" = "yes" ]; then
443 tar cfz $BuildDir/$Package.tar.gz $Package
444 else
445 tar cfJ $BuildDir/$Package.tar.xz $Package
446 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000447 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000448 cd $cwd
449}
450
Dan Liewbbe97552015-07-07 15:50:33 +0000451# Exit if any command fails
452# Note: pipefail is necessary for running build commands through
453# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
454set -e
455set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000456
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000457if [ "$do_checkout" = "yes" ]; then
458 export_sources
459fi
460
Tom Stellard590a9742017-08-15 18:11:56 +0000461# Setup the test-suite. Do this early so we can catch failures before
462# we do the full 3 stage build.
463if [ $do_test_suite = "yes" ]; then
464 SandboxDir="$BuildDir/sandbox"
465 Lit=$SandboxDir/bin/lit
466 TestSuiteBuildDir="$BuildDir/test-suite-build"
467 TestSuiteSrcDir="$BuildDir/test-suite.src"
468
469 virtualenv $SandboxDir
470 $SandboxDir/bin/python $BuildDir/llvm.src/utils/lit/setup.py install
471 mkdir -p $TestSuiteBuildDir
472fi
473
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000474(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000475Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000476if [ "$do_debug" = "yes" ]; then
477 Flavors="Debug $Flavors"
478fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000479if [ "$do_asserts" = "yes" ]; then
480 Flavors="$Flavors Release+Asserts"
481fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000482
483for Flavor in $Flavors ; do
484 echo ""
485 echo ""
486 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000487 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000488 echo " Build: $Flavor"
489 echo " System Info: "
490 echo " `uname -a`"
491 echo "********************************************************************************"
492 echo ""
493
Duncan Sands9341b502011-10-20 20:10:58 +0000494 c_compiler="$CC"
495 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000496 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000497 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000498
Bill Wendling957cc212011-11-28 11:45:10 +0000499 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000500 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000501
Bill Wendling957cc212011-11-28 11:45:10 +0000502 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000503 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000504
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000505 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000506 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000507
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000508 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000509 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000510
Bill Wendling7b7d0772011-10-17 04:46:54 +0000511 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000512 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000513
514 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000515 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000516
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000517 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000518 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000519
Bill Wendling7b7d0772011-10-17 04:46:54 +0000520 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000521 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000522
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000523 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000524 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000525 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000526 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000527 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000528 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
529 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000530
Dan Liew7fa38a52015-07-14 19:46:19 +0000531 ########################################################################
532 # Phase 2: Build llvmCore with newly built clang from phase 1.
533 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
534 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
535 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000536 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000537 build_llvmCore 2 $Flavor \
538 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
539 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000540
Dan Liew7fa38a52015-07-14 19:46:19 +0000541 ########################################################################
542 # Phase 3: Build llvmCore with newly built clang from phase 2.
543 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
544 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
545 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000546 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000547 build_llvmCore 3 $Flavor \
548 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
549 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000550
Dan Liew7fa38a52015-07-14 19:46:19 +0000551 ########################################################################
552 # Testing: Test phase 3
Tom Stellard2e173662017-06-15 23:05:21 +0000553 c_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang
554 cxx_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang++
Dan Liew7fa38a52015-07-14 19:46:19 +0000555 echo "# Testing - built with clang"
556 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000557
Dan Liew7fa38a52015-07-14 19:46:19 +0000558 ########################################################################
559 # Compare .o files between Phase2 and Phase3 and report which ones
560 # differ.
561 if [ "$do_compare" = "yes" ]; then
562 echo
563 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000564 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
565 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
566 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000567 # case there are build paths in the debug info. On some systems,
568 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000569 if ! cmp -s \
Tom Stellardaaa40cc2017-07-24 19:28:30 +0000570 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' -e 's,Phase1,Phase2,g' $p2) \
Hans Wennborg6c52b022016-01-27 00:19:05 +0000571 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000572 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000573 fi
574 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000575 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000576done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000577
Bill Wendling957cc212011-11-28 11:45:10 +0000578) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000579
Renato Golinc6bf7972017-05-04 16:21:30 +0000580if [ "$use_gzip" = "yes" ]; then
581 echo "# Packaging the release as $Package.tar.gz"
582else
583 echo "# Packaging the release as $Package.tar.xz"
584fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000585package_release
586
Bill Wendling06ac75c2011-10-18 17:27:12 +0000587set +e
588
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000589# Woo hoo!
590echo "### Testing Finished ###"
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000591echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000592
593echo "### Errors:"
594if [ -s "$LogDir/deferred_errors.log" ]; then
595 cat "$LogDir/deferred_errors.log"
596 exit 1
597else
598 echo "None."
599fi
600
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000601exit 0