blob: 560220cd53f48fcdcacca628875374407ba551ef [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 Zhengac6595c2017-01-18 01:03:29 +000041do_polly="no"
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 Zhengac6595c2017-01-18 01:03:29 +000071 echo " -polly Enable check-out & build Polly"
72 echo " -no-polly Disable check-out & build Polly (default)"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000073}
74
75while [ $# -gt 0 ]; do
76 case $1 in
77 -release | --release )
78 shift
79 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000080 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000081 ;;
82 -rc | --rc | -RC | --RC )
83 shift
Bill Wendling957cc212011-11-28 11:45:10 +000084 RC="rc$1"
85 ;;
86 -final | --final )
87 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000088 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000089 -svn-path | --svn-path )
90 shift
91 Release="test"
92 Release_no_dot="test"
93 ExportBranch="$1"
94 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
95 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
96 echo " This is intended to aid new packagers in trialing "
97 echo " builds without requiring a tag to be created first"
98 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000099 -triple | --triple )
100 shift
101 Triple="$1"
102 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000103 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000104 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000105 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000106 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000107 -j* )
108 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
109 if [ -z "$NumJobs" ]; then
110 shift
111 NumJobs="$1"
112 fi
113 ;;
114 -build-dir | --build-dir | -builddir | --builddir )
115 shift
116 BuildDir="$1"
117 ;;
118 -no-checkout | --no-checkout )
119 do_checkout="no"
120 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000121 -test-debug | --test-debug )
122 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000123 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000124 -test-asserts | --test-asserts )
125 do_asserts="yes"
126 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000127 -no-compare-files | --no-compare-files )
128 do_compare="no"
129 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000130 -use-gzip | --use-gzip )
131 use_gzip="yes"
132 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000133 -no-rt )
134 do_rt="no"
135 ;;
136 -no-libs )
137 do_libs="no"
138 ;;
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000139 -no-libunwind )
140 do_libunwind="no"
141 ;;
Renato Golin397b0da2015-07-22 18:21:39 +0000142 -no-test-suite )
143 do_test_suite="no"
144 ;;
Alexey Bataev860435c2015-12-10 05:45:58 +0000145 -no-openmp )
146 do_openmp="no"
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000147 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000148 -no-lld )
149 do_lld="no"
150 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000151 -lldb )
152 do_lldb="yes"
153 ;;
154 -no-lldb )
155 do_lldb="no"
156 ;;
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000157 -polly )
158 do_polly="yes"
159 ;;
160 -no-polly )
161 do_polly="no"
162 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000163 -help | --help | -h | --h | -\? )
164 usage
165 exit 0
166 ;;
167 * )
168 echo "unknown option: $1"
169 usage
170 exit 1
171 ;;
172 esac
173 shift
174done
175
176# Check required arguments.
177if [ -z "$Release" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000178 echo "error: no release number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000179 exit 1
180fi
181if [ -z "$RC" ]; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000182 echo "error: no release candidate number specified"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000183 exit 1
184fi
Daniel Sandersc2672e52015-07-17 10:40:40 +0000185if [ -z "$ExportBranch" ]; then
186 ExportBranch="tags/RELEASE_$Release_no_dot/$RC"
187fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000188if [ -z "$Triple" ]; then
189 echo "error: no target triple specified"
190 exit 1
191fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000192
Duncan Sands274090a2010-09-08 19:50:25 +0000193# Figure out how many make processes to run.
194if [ -z "$NumJobs" ]; then
195 NumJobs=`sysctl -n hw.activecpu 2> /dev/null || true`
196fi
197if [ -z "$NumJobs" ]; then
198 NumJobs=`sysctl -n hw.ncpu 2> /dev/null || true`
199fi
200if [ -z "$NumJobs" ]; then
201 NumJobs=`grep -c processor /proc/cpuinfo 2> /dev/null || true`
202fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000203if [ -z "$NumJobs" ]; then
204 NumJobs=3
205fi
206
Renato Golin397b0da2015-07-22 18:21:39 +0000207# Projects list
208projects="llvm cfe clang-tools-extra"
209if [ $do_rt = "yes" ]; then
210 projects="$projects compiler-rt"
211fi
212if [ $do_libs = "yes" ]; then
Daniel Sanders3cc4a252015-07-30 10:14:57 +0000213 projects="$projects libcxx libcxxabi"
214 if [ $do_libunwind = "yes" ]; then
215 projects="$projects libunwind"
216 fi
Renato Golin397b0da2015-07-22 18:21:39 +0000217fi
Daniel Sanders20de54b2016-01-28 21:09:50 +0000218case $do_test_suite in
219 yes|export-only)
220 projects="$projects test-suite"
221 ;;
222esac
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000223if [ $do_openmp = "yes" ]; then
224 projects="$projects openmp"
225fi
Dimitry Andric434fa952017-02-04 22:24:55 +0000226if [ $do_lld = "yes" ]; then
227 projects="$projects lld"
228fi
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000229if [ $do_lldb = "yes" ]; then
230 projects="$projects lldb"
231fi
Pengxuan Zhengac6595c2017-01-18 01:03:29 +0000232if [ $do_polly = "yes" ]; then
233 projects="$projects polly"
234fi
Renato Golin397b0da2015-07-22 18:21:39 +0000235
Bill Wendling9aa39432011-10-16 22:44:08 +0000236# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000237BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000238mkdir -p $BuildDir
239cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000240
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000241# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000242LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000243mkdir -p $LogDir
244
Bill Wendlingd6073842013-11-20 04:55:20 +0000245# Final package name.
246Package=clang+llvm-$Release
247if [ $RC != "final" ]; then
248 Package=$Package-$RC
249fi
250Package=$Package-$Triple
251
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000252# Errors to be highlighted at the end are written to this file.
253echo -n > $LogDir/deferred_errors.log
254
255function deferred_error() {
256 Phase="$1"
257 Flavor="$2"
258 Msg="$3"
259 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
260}
261
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000262# Make sure that a required program is available
263function check_program_exists() {
264 local program="$1"
265 if ! type -P $program > /dev/null 2>&1 ; then
266 echo "program '$1' not found !"
267 exit 1
268 fi
269}
270
Dimitry Andricca051602016-01-21 22:07:17 +0000271if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000272 check_program_exists 'chrpath'
273 check_program_exists 'file'
274 check_program_exists 'objdump'
275fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000276
277# Make sure that the URLs are valid.
278function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000279 for proj in $projects ; do
280 echo "# Validating $proj SVN URL"
281
Daniel Sandersc2672e52015-07-17 10:40:40 +0000282 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
283 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000284 exit 1
285 fi
286 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000287}
288
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000289# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000290function export_sources() {
291 check_valid_urls
292
Bill Wendling9aa39432011-10-16 22:44:08 +0000293 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000294 case $proj in
295 llvm)
296 projsrc=$proj.src
297 ;;
298 cfe)
299 projsrc=llvm.src/tools/clang
300 ;;
Dimitry Andric434fa952017-02-04 22:24:55 +0000301 lld|lldb|polly)
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000302 projsrc=llvm.src/tools/$proj
303 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000304 clang-tools-extra)
305 projsrc=llvm.src/tools/clang/tools/extra
306 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000307 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000308 projsrc=llvm.src/projects/$proj
309 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000310 test-suite)
Tom Stellardeb6fd412017-06-08 21:31:59 +0000311 projsrc=$proj.src
Daniel Sanders20de54b2016-01-28 21:09:50 +0000312 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000313 *)
314 echo "error: unknown project $proj"
315 exit 1
316 ;;
317 esac
318
319 if [ -d $projsrc ]; then
320 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000321 continue
322 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000323 echo "# Exporting $proj $Release-$RC sources to $projsrc"
324 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000325 echo "error: failed to export $proj project"
326 exit 1
327 fi
328 done
329
Bill Wendling9aa39432011-10-16 22:44:08 +0000330 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000331}
332
333function configure_llvmCore() {
334 Phase="$1"
335 Flavor="$2"
336 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000337
338 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000339 Release )
340 BuildType="Release"
341 Assertions="OFF"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000342 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000343 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000344 BuildType="Release"
345 Assertions="ON"
Duncan Sands17cd9072010-09-13 13:45:33 +0000346 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000347 Debug )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000348 BuildType="Debug"
349 Assertions="ON"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000350 ;;
351 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000352 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000353 echo ""
354 return
355 ;;
356 esac
357
Bill Wendling9aa39432011-10-16 22:44:08 +0000358 echo "# Using C compiler: $c_compiler"
359 echo "# Using C++ compiler: $cxx_compiler"
360
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000361 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000362 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000363
Hans Wennborg9012baa2016-08-09 16:46:02 +0000364 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
365 cmake -G "Unix Makefiles" \
366 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000367 $ExtraConfigureFlags $BuildDir/llvm.src \
368 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
369 env CC="$c_compiler" CXX="$cxx_compiler" \
370 cmake -G "Unix Makefiles" \
371 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Hans Wennborg9012baa2016-08-09 16:46:02 +0000372 $ExtraConfigureFlags $BuildDir/llvm.src \
373 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
Hans Wennborg0caeee02015-07-15 21:06:16 +0000374
Bill Wendling9aa39432011-10-16 22:44:08 +0000375 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000376}
377
378function build_llvmCore() {
379 Phase="$1"
380 Flavor="$2"
381 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000382 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000383
384 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000385 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000386 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
387 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000388 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000389
Bill Wendling957cc212011-11-28 11:45:10 +0000390 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000391 echo "# ${MAKE} install"
392 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000393 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000394 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
395 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000396}
397
398function test_llvmCore() {
399 Phase="$1"
400 Flavor="$2"
401 ObjDir="$3"
402
403 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000404 if ! ( ${MAKE} -j $NumJobs -k check-all \
405 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
406 deferred_error $Phase $Flavor "check-all failed"
407 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000408
Tom Stellardeb6fd412017-06-08 21:31:59 +0000409 if [ $do_test_suite = 'yes' ]; then
410 SandboxDir="$BuildDir/sandbox"
411 Lit=$SandboxDir/bin/lit
412 TestSuiteBuildDir="$BuildDir/test-suite-build"
413 TestSuiteSrcDir="$BuildDir/test-suite.src"
414
415 virtualenv $SandboxDir
416 $SandboxDir/bin/python $BuildDir/llvm.src/utils/lit/setup.py install
417 mkdir -p $TestSuiteBuildDir
418 cd $TestSuiteBuildDir
Tom Stellard2e173662017-06-15 23:05:21 +0000419 env CC="$c_compiler" CXX="$cxx_compiler" \
420 cmake $TestSuiteSrcDir -DTEST_SUITE_LIT=$Lit
Tom Stellardeb6fd412017-06-08 21:31:59 +0000421 if ! ( ${MAKE} -j $NumJobs -k check \
422 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
423 deferred_error $Phase $Flavor "test suite failed"
424 fi
425 fi
Bill Wendling9aa39432011-10-16 22:44:08 +0000426 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000427}
428
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000429# Clean RPATH. Libtool adds the build directory to the search path, which is
430# not necessary --- and even harmful --- for the binary packages we release.
431function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000432 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000433 return
434 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000435 local InstallPath="$1"
436 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
437 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000438 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
439 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
440 if [ -n "$rpath" ]; then
441 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
442 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
443 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000444 fi
445 fi
446 done
447}
448
Bill Wendlingd6073842013-11-20 04:55:20 +0000449# Create a package of the release binaries.
450function package_release() {
451 cwd=`pwd`
452 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000453 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000454 if [ "$use_gzip" = "yes" ]; then
455 tar cfz $BuildDir/$Package.tar.gz $Package
456 else
457 tar cfJ $BuildDir/$Package.tar.xz $Package
458 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000459 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000460 cd $cwd
461}
462
Dan Liewbbe97552015-07-07 15:50:33 +0000463# Exit if any command fails
464# Note: pipefail is necessary for running build commands through
465# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
466set -e
467set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000468
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000469if [ "$do_checkout" = "yes" ]; then
470 export_sources
471fi
472
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000473(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000474Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000475if [ "$do_debug" = "yes" ]; then
476 Flavors="Debug $Flavors"
477fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000478if [ "$do_asserts" = "yes" ]; then
479 Flavors="$Flavors Release+Asserts"
480fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000481
482for Flavor in $Flavors ; do
483 echo ""
484 echo ""
485 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000486 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000487 echo " Build: $Flavor"
488 echo " System Info: "
489 echo " `uname -a`"
490 echo "********************************************************************************"
491 echo ""
492
Duncan Sands9341b502011-10-20 20:10:58 +0000493 c_compiler="$CC"
494 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000495 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000496 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000497
Bill Wendling957cc212011-11-28 11:45:10 +0000498 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000499 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000500
Bill Wendling957cc212011-11-28 11:45:10 +0000501 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000502 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000503
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000504 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000505 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000506
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000507 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000508 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000509
Bill Wendling7b7d0772011-10-17 04:46:54 +0000510 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000511 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000512
513 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000514 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000515
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000516 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000517 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000518
Bill Wendling7b7d0772011-10-17 04:46:54 +0000519 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000520 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000521
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000522 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000523 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000524 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000525 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000526 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000527 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
528 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000529
Dan Liew7fa38a52015-07-14 19:46:19 +0000530 ########################################################################
531 # Phase 2: Build llvmCore with newly built clang from phase 1.
532 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
533 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
534 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000535 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000536 build_llvmCore 2 $Flavor \
537 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
538 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000539
Dan Liew7fa38a52015-07-14 19:46:19 +0000540 ########################################################################
541 # Phase 3: Build llvmCore with newly built clang from phase 2.
542 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
543 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
544 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000545 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000546 build_llvmCore 3 $Flavor \
547 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
548 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000549
Dan Liew7fa38a52015-07-14 19:46:19 +0000550 ########################################################################
551 # Testing: Test phase 3
Tom Stellard2e173662017-06-15 23:05:21 +0000552 c_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang
553 cxx_compiler=$llvmCore_phase3_destdir/usr/local/bin/clang++
Dan Liew7fa38a52015-07-14 19:46:19 +0000554 echo "# Testing - built with clang"
555 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000556
Dan Liew7fa38a52015-07-14 19:46:19 +0000557 ########################################################################
558 # Compare .o files between Phase2 and Phase3 and report which ones
559 # differ.
560 if [ "$do_compare" = "yes" ]; then
561 echo
562 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000563 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
564 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
565 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000566 # case there are build paths in the debug info. On some systems,
567 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000568 if ! cmp -s \
569 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
570 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000571 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000572 fi
573 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000574 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000575done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000576
Bill Wendling957cc212011-11-28 11:45:10 +0000577) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000578
Renato Golinc6bf7972017-05-04 16:21:30 +0000579if [ "$use_gzip" = "yes" ]; then
580 echo "# Packaging the release as $Package.tar.gz"
581else
582 echo "# Packaging the release as $Package.tar.xz"
583fi
Bill Wendlingd6073842013-11-20 04:55:20 +0000584package_release
585
Bill Wendling06ac75c2011-10-18 17:27:12 +0000586set +e
587
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000588# Woo hoo!
589echo "### Testing Finished ###"
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000590echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000591
592echo "### Errors:"
593if [ -s "$LogDir/deferred_errors.log" ]; then
594 cat "$LogDir/deferred_errors.log"
595 exit 1
596else
597 echo "None."
598fi
599
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000600exit 0