blob: 37af976ec0c50b494bbb96e310f51857963c9662 [file] [log] [blame]
Bill Wendlingf96a5bc2011-10-19 09:25:49 +00001#!/usr/bin/env bash
Bill Wendlingcedf3a22010-09-08 18:32:31 +00002#===-- test-release.sh - Test the LLVM release candidates ------------------===#
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is distributed under the University of Illinois Open Source
7# License.
8#
9#===------------------------------------------------------------------------===#
10#
11# Download, build, and test the release candidate for an LLVM release.
12#
13#===------------------------------------------------------------------------===#
14
Dimitry Andricca051602016-01-21 22:07:17 +000015System=`uname -s`
16if [ "$System" = "FreeBSD" ]; then
Bill Wendlingcfe82322011-10-19 08:42:07 +000017 MAKE=gmake
18else
19 MAKE=make
20fi
21
Bill Wendling9aa39432011-10-16 22:44:08 +000022# Base SVN URL for the sources.
23Base_url="http://llvm.org/svn/llvm-project"
24
Bill Wendlingcedf3a22010-09-08 18:32:31 +000025Release=""
26Release_no_dot=""
27RC=""
Bill Wendlingd6073842013-11-20 04:55:20 +000028Triple=""
Bill Wendling1585fea2013-11-24 05:29:35 +000029use_gzip="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000030do_checkout="yes"
Bill Wendling9aa39432011-10-16 22:44:08 +000031do_debug="no"
Bill Wendling7b7d0772011-10-17 04:46:54 +000032do_asserts="no"
Bill Wendlingd70cde12012-04-02 23:27:43 +000033do_compare="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000034do_rt="yes"
35do_libs="yes"
Daniel Sanders3cc4a252015-07-30 10:14:57 +000036do_libunwind="yes"
Renato Golin397b0da2015-07-22 18:21:39 +000037do_test_suite="yes"
Alexey Bataev860435c2015-12-10 05:45:58 +000038do_openmp="yes"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000039do_lldb="no"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000040BuildDir="`pwd`"
Hans Wennborg0caeee02015-07-15 21:06:16 +000041use_autoconf="no"
42ExtraConfigureFlags=""
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."
60 echo " -use-autoconf Use autoconf instead of cmake"
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"
Daniel Sanders27ba83f2016-02-29 11:04:39 +000068 echo " -lldb Enable check-out & build lldb"
69 echo " -no-lldb Disable check-out & build lldb (default)"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000070}
71
72while [ $# -gt 0 ]; do
73 case $1 in
74 -release | --release )
75 shift
76 Release="$1"
Tom Stellard9c4c3c52014-07-21 20:20:08 +000077 Release_no_dot="`echo $1 | sed -e 's,\.,,g'`"
Bill Wendlingcedf3a22010-09-08 18:32:31 +000078 ;;
79 -rc | --rc | -RC | --RC )
80 shift
Bill Wendling957cc212011-11-28 11:45:10 +000081 RC="rc$1"
82 ;;
83 -final | --final )
84 RC=final
Bill Wendlingcedf3a22010-09-08 18:32:31 +000085 ;;
Daniel Sandersc2672e52015-07-17 10:40:40 +000086 -svn-path | --svn-path )
87 shift
88 Release="test"
89 Release_no_dot="test"
90 ExportBranch="$1"
91 RC="`echo $ExportBranch | sed -e 's,/,_,g'`"
92 echo "WARNING: Using the branch $ExportBranch instead of a release tag"
93 echo " This is intended to aid new packagers in trialing "
94 echo " builds without requiring a tag to be created first"
95 ;;
Bill Wendlingd6073842013-11-20 04:55:20 +000096 -triple | --triple )
97 shift
98 Triple="$1"
99 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000100 -configure-flags | --configure-flags )
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000101 shift
Hans Wennborg0caeee02015-07-15 21:06:16 +0000102 ExtraConfigureFlags="$1"
Daniel Sandersf226aaf2014-12-04 17:15:35 +0000103 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000104 -j* )
105 NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
106 if [ -z "$NumJobs" ]; then
107 shift
108 NumJobs="$1"
109 fi
110 ;;
111 -build-dir | --build-dir | -builddir | --builddir )
112 shift
113 BuildDir="$1"
114 ;;
115 -no-checkout | --no-checkout )
116 do_checkout="no"
117 ;;
Bill Wendling9aa39432011-10-16 22:44:08 +0000118 -test-debug | --test-debug )
119 do_debug="yes"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000120 ;;
Bill Wendling7b7d0772011-10-17 04:46:54 +0000121 -test-asserts | --test-asserts )
122 do_asserts="yes"
123 ;;
Bill Wendlingd70cde12012-04-02 23:27:43 +0000124 -no-compare-files | --no-compare-files )
125 do_compare="no"
126 ;;
Bill Wendling1585fea2013-11-24 05:29:35 +0000127 -use-gzip | --use-gzip )
128 use_gzip="yes"
129 ;;
Hans Wennborg0caeee02015-07-15 21:06:16 +0000130 -use-autoconf | --use-autoconf )
131 use_autoconf="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 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000148 -lldb )
149 do_lldb="yes"
150 ;;
151 -no-lldb )
152 do_lldb="no"
153 ;;
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000154 -help | --help | -h | --h | -\? )
155 usage
156 exit 0
157 ;;
158 * )
159 echo "unknown option: $1"
160 usage
161 exit 1
162 ;;
163 esac
164 shift
165done
166
Hans Wennborg813c0f72016-01-14 19:21:14 +0000167if [ "$use_autoconf" = "no" ]; then
Daniel Sanders20de54b2016-01-28 21:09:50 +0000168 if [ "$do_test_suite" = "yes" ]; then
169 # See llvm.org/PR26146.
170 echo Skipping test-suite build when using CMake.
171 echo It will still be exported.
172 do_test_suite="export-only"
173 fi
Hans Wennborg813c0f72016-01-14 19:21:14 +0000174fi
175
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000176# 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
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000226if [ $do_lldb = "yes" ]; then
227 projects="$projects lldb"
228fi
Renato Golin397b0da2015-07-22 18:21:39 +0000229
Bill Wendling9aa39432011-10-16 22:44:08 +0000230# Go to the build directory (may be different from CWD)
Bill Wendling957cc212011-11-28 11:45:10 +0000231BuildDir=$BuildDir/$RC
Bill Wendling9aa39432011-10-16 22:44:08 +0000232mkdir -p $BuildDir
233cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000234
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000235# Location of log files.
Bill Wendling9aa39432011-10-16 22:44:08 +0000236LogDir=$BuildDir/logs
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000237mkdir -p $LogDir
238
Bill Wendlingd6073842013-11-20 04:55:20 +0000239# Final package name.
240Package=clang+llvm-$Release
241if [ $RC != "final" ]; then
242 Package=$Package-$RC
243fi
244Package=$Package-$Triple
245
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000246# Errors to be highlighted at the end are written to this file.
247echo -n > $LogDir/deferred_errors.log
248
249function deferred_error() {
250 Phase="$1"
251 Flavor="$2"
252 Msg="$3"
253 echo "[${Flavor} Phase${Phase}] ${Msg}" | tee -a $LogDir/deferred_errors.log
254}
255
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000256# Make sure that a required program is available
257function check_program_exists() {
258 local program="$1"
259 if ! type -P $program > /dev/null 2>&1 ; then
260 echo "program '$1' not found !"
261 exit 1
262 fi
263}
264
Dimitry Andricca051602016-01-21 22:07:17 +0000265if [ "$System" != "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000266 check_program_exists 'chrpath'
267 check_program_exists 'file'
268 check_program_exists 'objdump'
269fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000270
271# Make sure that the URLs are valid.
272function check_valid_urls() {
Bill Wendling9aa39432011-10-16 22:44:08 +0000273 for proj in $projects ; do
274 echo "# Validating $proj SVN URL"
275
Daniel Sandersc2672e52015-07-17 10:40:40 +0000276 if ! svn ls $Base_url/$proj/$ExportBranch > /dev/null 2>&1 ; then
277 echo "$proj does not have a $ExportBranch branch/tag!"
Bill Wendling9aa39432011-10-16 22:44:08 +0000278 exit 1
279 fi
280 done
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000281}
282
Sylvestre Ledru35521e22012-07-23 08:51:15 +0000283# Export sources to the build directory.
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000284function export_sources() {
285 check_valid_urls
286
Bill Wendling9aa39432011-10-16 22:44:08 +0000287 for proj in $projects ; do
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000288 case $proj in
289 llvm)
290 projsrc=$proj.src
291 ;;
292 cfe)
293 projsrc=llvm.src/tools/clang
294 ;;
Daniel Sanders27ba83f2016-02-29 11:04:39 +0000295 lldb)
296 projsrc=llvm.src/tools/$proj
297 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000298 clang-tools-extra)
299 projsrc=llvm.src/tools/clang/tools/extra
300 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000301 compiler-rt|libcxx|libcxxabi|libunwind|openmp)
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000302 projsrc=llvm.src/projects/$proj
303 ;;
Daniel Sanders20de54b2016-01-28 21:09:50 +0000304 test-suite)
305 if [ $do_test_suite = 'yes' ]; then
306 projsrc=llvm.src/projects/$proj
307 else
308 projsrc=$proj.src
309 fi
310 ;;
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000311 *)
312 echo "error: unknown project $proj"
313 exit 1
314 ;;
315 esac
316
317 if [ -d $projsrc ]; then
318 echo "# Reusing $proj $Release-$RC sources in $projsrc"
Renato Golin397b0da2015-07-22 18:21:39 +0000319 continue
320 fi
Dimitry Andric4a5f8a12016-01-21 21:57:49 +0000321 echo "# Exporting $proj $Release-$RC sources to $projsrc"
322 if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
Bill Wendling9aa39432011-10-16 22:44:08 +0000323 echo "error: failed to export $proj project"
324 exit 1
325 fi
326 done
327
Bill Wendling9aa39432011-10-16 22:44:08 +0000328 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000329}
330
331function configure_llvmCore() {
332 Phase="$1"
333 Flavor="$2"
334 ObjDir="$3"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000335
336 case $Flavor in
Hans Wennborg0caeee02015-07-15 21:06:16 +0000337 Release )
338 BuildType="Release"
339 Assertions="OFF"
340 ConfigureFlags="--enable-optimized --disable-assertions"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000341 ;;
Duncan Sands17cd9072010-09-13 13:45:33 +0000342 Release+Asserts )
Hans Wennborg0caeee02015-07-15 21:06:16 +0000343 BuildType="Release"
344 Assertions="ON"
345 ConfigureFlags="--enable-optimized --enable-assertions"
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"
350 ConfigureFlags="--disable-optimized --enable-assertions"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000351 ;;
352 * )
Bill Wendling9aa39432011-10-16 22:44:08 +0000353 echo "# Invalid flavor '$Flavor'"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000354 echo ""
355 return
356 ;;
357 esac
358
Bill Wendling9aa39432011-10-16 22:44:08 +0000359 echo "# Using C compiler: $c_compiler"
360 echo "# Using C++ compiler: $cxx_compiler"
361
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000362 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000363 echo "# Configuring llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000364
365 if [ "$use_autoconf" = "yes" ]; then
366 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
367 $BuildDir/llvm.src/configure \
368 $ConfigureFlags --disable-timestamps $ExtraConfigureFlags \
369 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
370 env CC="$c_compiler" CXX="$cxx_compiler" \
371 $BuildDir/llvm.src/configure \
372 $ConfigureFlags --disable-timestamps $ExtraConfigureFlags \
373 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
374 else
375 echo "#" env CC="$c_compiler" CXX="$cxx_compiler" \
376 cmake -G "Unix Makefiles" \
377 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Chris Bieneman62de33c2016-05-05 19:57:03 +0000378 -DLLVM_CONFIGTIME="(timestamp not enabled)" \
Hans Wennborg0caeee02015-07-15 21:06:16 +0000379 $ExtraConfigureFlags $BuildDir/llvm.src \
380 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
381 env CC="$c_compiler" CXX="$cxx_compiler" \
382 cmake -G "Unix Makefiles" \
383 -DCMAKE_BUILD_TYPE=$BuildType -DLLVM_ENABLE_ASSERTIONS=$Assertions \
Chris Bieneman62de33c2016-05-05 19:57:03 +0000384 -DLLVM_CONFIGTIME="(timestamp not enabled)" \
Hans Wennborg0caeee02015-07-15 21:06:16 +0000385 $ExtraConfigureFlags $BuildDir/llvm.src \
386 2>&1 | tee $LogDir/llvm.configure-Phase$Phase-$Flavor.log
387 fi
388
Bill Wendling9aa39432011-10-16 22:44:08 +0000389 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000390}
391
392function build_llvmCore() {
393 Phase="$1"
394 Flavor="$2"
395 ObjDir="$3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000396 DestDir="$4"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000397
398 cd $ObjDir
Bill Wendling957cc212011-11-28 11:45:10 +0000399 echo "# Compiling llvm $Release-$RC $Flavor"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000400 echo "# ${MAKE} -j $NumJobs VERBOSE=1"
401 ${MAKE} -j $NumJobs VERBOSE=1 \
Bill Wendling9aa39432011-10-16 22:44:08 +0000402 2>&1 | tee $LogDir/llvm.make-Phase$Phase-$Flavor.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000403
Bill Wendling957cc212011-11-28 11:45:10 +0000404 echo "# Installing llvm $Release-$RC $Flavor"
Bill Wendlingcfe82322011-10-19 08:42:07 +0000405 echo "# ${MAKE} install"
406 ${MAKE} install \
Dan Liew7fa38a52015-07-14 19:46:19 +0000407 DESTDIR="${DestDir}" \
Bill Wendling9aa39432011-10-16 22:44:08 +0000408 2>&1 | tee $LogDir/llvm.install-Phase$Phase-$Flavor.log
409 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000410}
411
412function test_llvmCore() {
413 Phase="$1"
414 Flavor="$2"
415 ObjDir="$3"
416
417 cd $ObjDir
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000418 if ! ( ${MAKE} -j $NumJobs -k check-all \
419 2>&1 | tee $LogDir/llvm.check-Phase$Phase-$Flavor.log ) ; then
420 deferred_error $Phase $Flavor "check-all failed"
421 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000422
423 if [ "$use_autoconf" = "yes" ]; then
424 # In the cmake build, unit tests are run as part of check-all.
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000425 if ! ( ${MAKE} -k unittests 2>&1 | \
426 tee $LogDir/llvm.unittests-Phase$Phase-$Flavor.log ) ; then
427 deferred_error $Phase $Flavor "unittests failed"
428 fi
Hans Wennborg0caeee02015-07-15 21:06:16 +0000429 fi
430
Bill Wendling9aa39432011-10-16 22:44:08 +0000431 cd $BuildDir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000432}
433
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000434# Clean RPATH. Libtool adds the build directory to the search path, which is
435# not necessary --- and even harmful --- for the binary packages we release.
436function clean_RPATH() {
Dimitry Andricca051602016-01-21 22:07:17 +0000437 if [ "$System" = "Darwin" ]; then
Bill Wendlingd6073842013-11-20 04:55:20 +0000438 return
439 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000440 local InstallPath="$1"
441 for Candidate in `find $InstallPath/{bin,lib} -type f`; do
442 if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
Dimitry Andric52a143a2015-07-20 22:24:40 +0000443 if rpath=`objdump -x $Candidate | grep 'RPATH'` ; then
444 rpath=`echo $rpath | sed -e's/^ *RPATH *//'`
445 if [ -n "$rpath" ]; then
446 newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
447 chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
448 fi
Arnaud A. de Grandmaison69690e42013-11-18 10:34:59 +0000449 fi
450 fi
451 done
452}
453
Bill Wendlingd6073842013-11-20 04:55:20 +0000454# Create a package of the release binaries.
455function package_release() {
456 cwd=`pwd`
457 cd $BuildDir/Phase3/Release
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000458 mv llvmCore-$Release-$RC.install/usr/local $Package
Bill Wendling1585fea2013-11-24 05:29:35 +0000459 if [ "$use_gzip" = "yes" ]; then
460 tar cfz $BuildDir/$Package.tar.gz $Package
461 else
462 tar cfJ $BuildDir/$Package.tar.xz $Package
463 fi
Hans Wennborge38cc0b2015-07-20 20:36:21 +0000464 mv $Package llvmCore-$Release-$RC.install/usr/local
Bill Wendlingd6073842013-11-20 04:55:20 +0000465 cd $cwd
466}
467
Dan Liewbbe97552015-07-07 15:50:33 +0000468# Exit if any command fails
469# Note: pipefail is necessary for running build commands through
470# a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
471set -e
472set -o pipefail
Bill Wendling06ac75c2011-10-18 17:27:12 +0000473
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000474if [ "$do_checkout" = "yes" ]; then
475 export_sources
476fi
477
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000478(
Bill Wendling7b7d0772011-10-17 04:46:54 +0000479Flavors="Release"
Bill Wendling9aa39432011-10-16 22:44:08 +0000480if [ "$do_debug" = "yes" ]; then
481 Flavors="Debug $Flavors"
482fi
Bill Wendling7b7d0772011-10-17 04:46:54 +0000483if [ "$do_asserts" = "yes" ]; then
484 Flavors="$Flavors Release+Asserts"
485fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000486
487for Flavor in $Flavors ; do
488 echo ""
489 echo ""
490 echo "********************************************************************************"
Bill Wendling957cc212011-11-28 11:45:10 +0000491 echo " Release: $Release-$RC"
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000492 echo " Build: $Flavor"
493 echo " System Info: "
494 echo " `uname -a`"
495 echo "********************************************************************************"
496 echo ""
497
Duncan Sands9341b502011-10-20 20:10:58 +0000498 c_compiler="$CC"
499 cxx_compiler="$CXX"
Bill Wendling957cc212011-11-28 11:45:10 +0000500 llvmCore_phase1_objdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000501 llvmCore_phase1_destdir=$BuildDir/Phase1/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000502
Bill Wendling957cc212011-11-28 11:45:10 +0000503 llvmCore_phase2_objdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000504 llvmCore_phase2_destdir=$BuildDir/Phase2/$Flavor/llvmCore-$Release-$RC.install
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000505
Bill Wendling957cc212011-11-28 11:45:10 +0000506 llvmCore_phase3_objdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.obj
Dan Liew7fa38a52015-07-14 19:46:19 +0000507 llvmCore_phase3_destdir=$BuildDir/Phase3/$Flavor/llvmCore-$Release-$RC.install
Bill Wendling7b7d0772011-10-17 04:46:54 +0000508
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000509 rm -rf $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000510 rm -rf $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000511
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000512 rm -rf $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000513 rm -rf $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000514
Bill Wendling7b7d0772011-10-17 04:46:54 +0000515 rm -rf $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000516 rm -rf $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000517
518 mkdir -p $llvmCore_phase1_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000519 mkdir -p $llvmCore_phase1_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000520
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000521 mkdir -p $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000522 mkdir -p $llvmCore_phase2_destdir
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000523
Bill Wendling7b7d0772011-10-17 04:46:54 +0000524 mkdir -p $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000525 mkdir -p $llvmCore_phase3_destdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000526
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000527 ############################################################################
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000528 # Phase 1: Build llvmCore and clang
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000529 echo "# Phase 1: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000530 configure_llvmCore 1 $Flavor $llvmCore_phase1_objdir
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000531 build_llvmCore 1 $Flavor \
Dan Liew7fa38a52015-07-14 19:46:19 +0000532 $llvmCore_phase1_objdir $llvmCore_phase1_destdir
533 clean_RPATH $llvmCore_phase1_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000534
Dan Liew7fa38a52015-07-14 19:46:19 +0000535 ########################################################################
536 # Phase 2: Build llvmCore with newly built clang from phase 1.
537 c_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang
538 cxx_compiler=$llvmCore_phase1_destdir/usr/local/bin/clang++
539 echo "# Phase 2: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000540 configure_llvmCore 2 $Flavor $llvmCore_phase2_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000541 build_llvmCore 2 $Flavor \
542 $llvmCore_phase2_objdir $llvmCore_phase2_destdir
543 clean_RPATH $llvmCore_phase2_destdir/usr/local
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000544
Dan Liew7fa38a52015-07-14 19:46:19 +0000545 ########################################################################
546 # Phase 3: Build llvmCore with newly built clang from phase 2.
547 c_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang
548 cxx_compiler=$llvmCore_phase2_destdir/usr/local/bin/clang++
549 echo "# Phase 3: Building llvmCore"
Hans Wennborg923860d2015-07-14 20:15:15 +0000550 configure_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Dan Liew7fa38a52015-07-14 19:46:19 +0000551 build_llvmCore 3 $Flavor \
552 $llvmCore_phase3_objdir $llvmCore_phase3_destdir
553 clean_RPATH $llvmCore_phase3_destdir/usr/local
Bill Wendling7b7d0772011-10-17 04:46:54 +0000554
Dan Liew7fa38a52015-07-14 19:46:19 +0000555 ########################################################################
556 # Testing: Test phase 3
557 echo "# Testing - built with clang"
558 test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
Bill Wendling7b7d0772011-10-17 04:46:54 +0000559
Dan Liew7fa38a52015-07-14 19:46:19 +0000560 ########################################################################
561 # Compare .o files between Phase2 and Phase3 and report which ones
562 # differ.
563 if [ "$do_compare" = "yes" ]; then
564 echo
565 echo "# Comparing Phase 2 and Phase 3 files"
Hans Wennborg0caeee02015-07-15 21:06:16 +0000566 for p2 in `find $llvmCore_phase2_objdir -name '*.o'` ; do
567 p3=`echo $p2 | sed -e 's,Phase2,Phase3,'`
568 # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
Hans Wennborgaaacf482015-07-15 22:18:25 +0000569 # case there are build paths in the debug info. On some systems,
570 # sed adds a newline to the output, so pass $p3 through sed too.
Hans Wennborg6c52b022016-01-27 00:19:05 +0000571 if ! cmp -s \
572 <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
573 <(env LC_CTYPE=C sed -e '' $p3) 16 16; then
Hans Wennborg0caeee02015-07-15 21:06:16 +0000574 echo "file `basename $p2` differs between phase 2 and phase 3"
Dan Liew7fa38a52015-07-14 19:46:19 +0000575 fi
576 done
Duncan Sands2efb4dd2011-10-20 11:13:04 +0000577 fi
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000578done
Hans Wennborg0742a3e2015-07-29 16:29:06 +0000579
Bill Wendling957cc212011-11-28 11:45:10 +0000580) 2>&1 | tee $LogDir/testing.$Release-$RC.log
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000581
Bill Wendlingd6073842013-11-20 04:55:20 +0000582package_release
583
Bill Wendling06ac75c2011-10-18 17:27:12 +0000584set +e
585
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000586# Woo hoo!
587echo "### Testing Finished ###"
Bill Wendling1585fea2013-11-24 05:29:35 +0000588if [ "$use_gzip" = "yes" ]; then
589 echo "### Package: $Package.tar.gz"
590else
591 echo "### Package: $Package.tar.xz"
592fi
Duncan Sandsd5f631c2011-03-27 13:52:32 +0000593echo "### Logs: $LogDir"
Hans Wennborgfa8e3a52015-07-24 16:16:09 +0000594
595echo "### Errors:"
596if [ -s "$LogDir/deferred_errors.log" ]; then
597 cat "$LogDir/deferred_errors.log"
598 exit 1
599else
600 echo "None."
601fi
602
Bill Wendlingcedf3a22010-09-08 18:32:31 +0000603exit 0