[PM] Add support to the analysis managers to query explicitly for cached
[oota-llvm.git] / utils / release / test-release.sh
index 6ec2861fb40de78afd692fc39a370a1ec514a5ad..cdb0b60904eee29b62feaf3d32449d5aa02daff2 100755 (executable)
@@ -18,7 +18,7 @@ else
     MAKE=make
 fi
 
-projects="llvm cfe dragonegg test-suite"
+projects="llvm cfe dragonegg compiler-rt libcxx test-suite clang-tools-extra"
 
 # Base SVN URL for the sources.
 Base_url="http://llvm.org/svn/llvm-project"
@@ -26,6 +26,7 @@ Base_url="http://llvm.org/svn/llvm-project"
 Release=""
 Release_no_dot=""
 RC=""
+Triple=""
 do_checkout="yes"
 do_ada="no"
 do_clang="yes"
@@ -35,6 +36,7 @@ do_objc="yes"
 do_64bit="yes"
 do_debug="no"
 do_asserts="no"
+do_compare="yes"
 BuildDir="`pwd`"
 
 function usage() {
@@ -43,6 +45,7 @@ function usage() {
     echo " -release X.Y      The release number to test."
     echo " -rc NUM           The pre-release candidate number."
     echo " -final            The final release candidate."
+    echo " -triple TRIPLE    The target triple for this machine."
     echo " -j NUM            Number of compile jobs to run. [default: 3]"
     echo " -build-dir DIR    Directory to perform testing in. [default: pwd]"
     echo " -no-checkout      Don't checkout the sources from SVN."
@@ -54,6 +57,7 @@ function usage() {
     echo " -disable-objc     Disable ObjC build. [default: enable]"
     echo " -test-debug       Test the debug build. [default: no]"
     echo " -test-asserts     Test with asserts on. [default: no]"
+    echo " -no-compare-files Don't test that phase 2 and 3 files are identical."
 }
 
 while [ $# -gt 0 ]; do
@@ -70,6 +74,10 @@ while [ $# -gt 0 ]; do
         -final | --final )
             RC=final
             ;;
+        -triple | --triple )
+            shift
+            Triple="$1"
+            ;;
         -j* )
             NumJobs="`echo $1 | sed -e 's,-j\([0-9]*\),\1,g'`"
             if [ -z "$NumJobs" ]; then
@@ -108,6 +116,9 @@ while [ $# -gt 0 ]; do
         -test-asserts | --test-asserts )
             do_asserts="yes"
             ;;
+        -no-compare-files | --no-compare-files )
+            do_compare="no"
+            ;;
         -help | --help | -h | --h | -\? )
             usage
             exit 0
@@ -130,6 +141,10 @@ if [ -z "$RC" ]; then
     echo "error: no release candidate number specified"
     exit 1
 fi
+if [ -z "$Triple" ]; then
+    echo "error: no target triple specified"
+    exit 1
+fi
 
 # Figure out how many make processes to run.
 if [ -z "$NumJobs" ]; then
@@ -154,6 +169,13 @@ cd $BuildDir
 LogDir=$BuildDir/logs
 mkdir -p $LogDir
 
+# Final package name.
+Package=clang+llvm-$Release
+if [ $RC != "final" ]; then
+  Package=$Package-$RC
+fi
+Package=$Package-$Triple
+
 # Find compilers.
 if [ "$do_dragonegg" = "yes" ]; then
     gcc_compiler="$GCC"
@@ -175,6 +197,20 @@ if [ "$do_dragonegg" = "yes" ]; then
     fi
 fi
 
+# Make sure that a required program is available
+function check_program_exists() {
+  local program="$1"
+  if ! type -P $program > /dev/null 2>&1 ; then
+    echo "program '$1' not found !"
+    exit 1
+  fi
+}
+
+if [ `uname -s` != "Darwin" ]; then
+  check_program_exists 'chrpath'
+  check_program_exists 'file'
+  check_program_exists 'objdump'
+fi
 
 # Make sure that the URLs are valid.
 function check_valid_urls() {
@@ -188,7 +224,7 @@ function check_valid_urls() {
     done
 }
 
-# Export sources to the the build directory.
+# Export sources to the build directory.
 function export_sources() {
     check_valid_urls
 
@@ -205,9 +241,19 @@ function export_sources() {
     if [ ! -h clang ]; then
         ln -s ../../cfe.src clang
     fi
+    cd $BuildDir/llvm.src/tools/clang/tools
+    if [ ! -h clang-tools-extra ]; then
+        ln -s ../../../../clang-tools-extra.src extra
+    fi
     cd $BuildDir/llvm.src/projects
-    if [ ! -h llvm-test ]; then
-        ln -s ../../test-suite.src llvm-test
+    if [ ! -h test-suite ]; then
+        ln -s ../../test-suite.src test-suite
+    fi
+    if [ ! -h compiler-rt ]; then
+        ln -s ../../compiler-rt.src compiler-rt
+    fi
+    if [ ! -h libcxx ]; then
+        ln -s ../../libcxx.src libcxx
     fi
     cd $BuildDir
 }
@@ -313,6 +359,34 @@ function test_llvmCore() {
     cd $BuildDir
 }
 
+# Clean RPATH. Libtool adds the build directory to the search path, which is
+# not necessary --- and even harmful --- for the binary packages we release.
+function clean_RPATH() {
+  if [ `uname -s` = "Darwin" ]; then
+    return
+  fi
+  local InstallPath="$1"
+  for Candidate in `find $InstallPath/{bin,lib} -type f`; do
+    if file $Candidate | grep ELF | egrep 'executable|shared object' > /dev/null 2>&1 ; then
+      rpath=`objdump -x $Candidate | grep 'RPATH' | sed -e's/^ *RPATH *//'`
+      if [ -n "$rpath" ]; then
+        newrpath=`echo $rpath | sed -e's/.*\(\$ORIGIN[^:]*\).*/\1/'`
+        chrpath -r $newrpath $Candidate 2>&1 > /dev/null 2>&1
+      fi
+    fi
+  done
+}
+
+# Create a package of the release binaries.
+function package_release() {
+    cwd=`pwd`
+    cd $BuildDir/Phase3/Release
+    mv llvmCore-$Release-$RC.install $Package
+    tar cfz $BuildDir/$Package.tar.gz $Package
+    mv $Package llvmCore-$Release-$RC.install
+    cd $cwd
+}
+
 set -e                          # Exit if any command fails
 
 if [ "$do_checkout" = "yes" ]; then
@@ -400,10 +474,11 @@ for Flavor in $Flavors ; do
         $llvmCore_phase1_objdir $llvmCore_phase1_installdir
     build_llvmCore 1 $Flavor \
         $llvmCore_phase1_objdir
+    clean_RPATH $llvmCore_phase1_installdir
 
     # Test clang
     if [ "$do_clang" = "yes" ]; then
-        ############################################################################
+        ########################################################################
         # Phase 2: Build llvmCore with newly built clang from phase 1.
         c_compiler=$llvmCore_phase1_installdir/bin/clang
         cxx_compiler=$llvmCore_phase1_installdir/bin/clang++
@@ -412,8 +487,9 @@ for Flavor in $Flavors ; do
             $llvmCore_phase2_objdir $llvmCore_phase2_installdir
         build_llvmCore 2 $Flavor \
             $llvmCore_phase2_objdir
+        clean_RPATH $llvmCore_phase2_installdir
 
-        ############################################################################
+        ########################################################################
         # Phase 3: Build llvmCore with newly built clang from phase 2.
         c_compiler=$llvmCore_phase2_installdir/bin/clang
         cxx_compiler=$llvmCore_phase2_installdir/bin/clang++
@@ -422,22 +498,26 @@ for Flavor in $Flavors ; do
             $llvmCore_phase3_objdir $llvmCore_phase3_installdir
         build_llvmCore 3 $Flavor \
             $llvmCore_phase3_objdir
+        clean_RPATH $llvmCore_phase3_installdir
 
-        ############################################################################
+        ########################################################################
         # Testing: Test phase 3
         echo "# Testing - built with clang"
         test_llvmCore 3 $Flavor $llvmCore_phase3_objdir
 
-        ############################################################################
-        # Compare .o files between Phase2 and Phase3 and report which ones differ.
-        echo
-        echo "# Comparing Phase 2 and Phase 3 files"
-        for o in `find $llvmCore_phase2_objdir -name '*.o'` ; do
-            p3=`echo $o | sed -e 's,Phase2,Phase3,'`
-            if ! cmp --ignore-initial=16 $o $p3 > /dev/null 2>&1 ; then
-                echo "file `basename $o` differs between phase 2 and phase 3"
-            fi
-        done
+        ########################################################################
+        # Compare .o files between Phase2 and Phase3 and report which ones
+        # differ.
+        if [ "$do_compare" = "yes" ]; then
+            echo
+            echo "# Comparing Phase 2 and Phase 3 files"
+            for o in `find $llvmCore_phase2_objdir -name '*.o'` ; do
+                p3=`echo $o | sed -e 's,Phase2,Phase3,'`
+                if ! cmp --ignore-initial=16 $o $p3 > /dev/null 2>&1 ; then
+                    echo "file `basename $o` differs between phase 2 and phase 3"
+                fi
+            done
+        fi
     fi
 
     # Test dragonegg
@@ -450,7 +530,7 @@ for Flavor in $Flavors ; do
         cxx_compiler="$gxx_compiler"
         build_dragonegg 1 $Flavor $llvmCore_phase1_installdir $dragonegg_phase1_objdir
 
-        ############################################################################
+        ########################################################################
         # Phase 2: Build llvmCore with newly built dragonegg from phase 1.
         c_compiler="$gcc_compiler -fplugin=$dragonegg_phase1_objdir/dragonegg.so"
         cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase1_objdir/dragonegg.so"
@@ -460,9 +540,10 @@ for Flavor in $Flavors ; do
         build_llvmCore 2 $Flavor \
             $llvmCore_de_phase2_objdir
         build_dragonegg 2 $Flavor $llvmCore_de_phase2_installdir $dragonegg_phase2_objdir
+        clean_RPATH $llvmCore_de_phase2_installdir
 
-        ############################################################################
-        # Phase 3: Build llvmCore with newly built clang from phase 2.
+        ########################################################################
+        # Phase 3: Build llvmCore with newly built dragonegg from phase 2.
         c_compiler="$gcc_compiler -fplugin=$dragonegg_phase2_objdir/dragonegg.so"
         cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase2_objdir/dragonegg.so"
         echo "# Phase 3: Building llvmCore with dragonegg"
@@ -471,15 +552,16 @@ for Flavor in $Flavors ; do
         build_llvmCore 3 $Flavor \
             $llvmCore_de_phase3_objdir
         build_dragonegg 3 $Flavor $llvmCore_de_phase3_installdir $dragonegg_phase3_objdir
+        clean_RPATH $llvmCore_de_phase3_installdir
 
-        ############################################################################
+        ########################################################################
         # Testing: Test phase 3
         c_compiler="$gcc_compiler -fplugin=$dragonegg_phase3_objdir/dragonegg.so"
         cxx_compiler="$gxx_compiler -fplugin=$dragonegg_phase3_objdir/dragonegg.so"
         echo "# Testing - built with dragonegg"
         test_llvmCore 3 $Flavor $llvmCore_de_phase3_objdir
 
-        ############################################################################
+        ########################################################################
         # Compare .o files between Phase2 and Phase3 and report which ones differ.
         echo
         echo "# Comparing Phase 2 and Phase 3 files"
@@ -500,9 +582,12 @@ for Flavor in $Flavors ; do
 done
 ) 2>&1 | tee $LogDir/testing.$Release-$RC.log
 
+package_release
+
 set +e
 
 # Woo hoo!
 echo "### Testing Finished ###"
+echo "### Package: $Package.tar.gz"
 echo "### Logs: $LogDir"
 exit 0