| Index: deps/third_party/valgrind/scripts/build-valgrind-for-chromium.sh
|
| ===================================================================
|
| --- deps/third_party/valgrind/scripts/build-valgrind-for-chromium.sh (revision 36232)
|
| +++ deps/third_party/valgrind/scripts/build-valgrind-for-chromium.sh (working copy)
|
| @@ -4,63 +4,35 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -# Script to build valgrind for use with chromium
|
| -#
|
| -# Can also be used to just prepare patched source tarball with MAKE_TARBALL=yes
|
| -# or to just build from a patched source tarball with USE_TARBALL=yes.
|
| -# These are useful when configuring jailed buildbots which are not allowed to
|
| -# fetch valgrind source via svn. Most users won't need those options.
|
| +# Script to build valgrind binaries for use with chromium
|
|
|
| -# Checkout by date doesn't work unless you specify the friggin' timezone
|
| -VALGRIND_SVN_REV=10880
|
| -# And svn isn't smart enough to figure out what rev of the linked tree to get
|
| -VEX_SVN_REV=1914
|
| -# and TSAN may be out of sync, so you have to check that out by rev anyway
|
| -TSAN_SVN_REV=1274
|
| -
|
| -# suffix for build and install dir to denote our set of patches (may be empty)
|
| -PATCHLEVEL=-redzone
|
| -
|
| -DIRNAME=valgrind-${VALGRIND_SVN_REV}${PATCHLEVEL}
|
| -
|
| THISDIR=$(dirname "${0}")
|
| THISDIR=$(cd "${THISDIR}" && /bin/pwd)
|
|
|
| -case "x${1}" in
|
| -x|x/*) ;;
|
| -*)
|
| - echo "Usage: sh build-valgrind-for-chromium.sh [prefix]"
|
| - echo "Prefix is optional, but if present, must be the absolute path to where"
|
| - echo "you want to install valgrind's bin, include, and lib directories."
|
| - echo "Prefix defaults to /usr/local/$DIRNAME."
|
| - echo "Will use sudo to do the install if you don't own the parent of prefix."
|
| - exit 1
|
| - ;;
|
| -esac
|
| +checkout_and_patch_valgrind() {
|
| + # {{{1
|
| + # Checkout Valgrind and ThreadSanitizer, apply our patches to Valgrind.
|
| + # The source will be put in $THISDIR/valgrind-source
|
| + cd $THISDIR
|
| + VALGRIND_SOURCE="$THISDIR/valgrind-source"
|
|
|
| -set -x
|
| -set -e
|
| + # Checkout by date doesn't work unless you specify the friggin' timezone
|
| + # and svn isn't smart enough to figure out what rev of VEX to get
|
| + # and TSAN may be out of sync, so you have to check that out by rev anyway.
|
| + VALGRIND_SVN_REV=10880
|
| + VEX_SVN_REV=1914
|
| + TSAN_SVN_REV=1274
|
|
|
| -if test "x${USE_TARBALL}" = "xyes" && test "x${MAKE_TARBALL}" = "xyes"
|
| -then
|
| - echo Set only one of MAKE_TARBALL or USE_TARBALL to yes
|
| - exit 1
|
| -fi
|
| + test -d "$VALGRIND_SOURCE" && rm -rf "$VALGRIND_SOURCE"
|
| + mkdir "$VALGRIND_SOURCE"
|
|
|
| -# Clean checkout our untar
|
| -test -d "$DIRNAME" && rm -rf ./"$DIRNAME"
|
| -mkdir -p "$DIRNAME"
|
| -
|
| -if test "x${USE_TARBALL}" != "xyes"
|
| -then
|
| # Check out latest version that following patches known to apply against
|
| - svn co -r "${VALGRIND_SVN_REV}" "svn://svn.valgrind.org/valgrind/trunk" "$DIRNAME"
|
| -
|
| - cd "$DIRNAME"
|
| -
|
| + svn co -r "${VALGRIND_SVN_REV}" "svn://svn.valgrind.org/valgrind/trunk" "$VALGRIND_SOURCE"
|
| + cd "$VALGRIND_SOURCE"
|
| # Make sure svn gets the right version of the external VEX repo, too
|
| svn update -r "${VEX_SVN_REV}" VEX/
|
|
|
| + # Apply patches to Valgrind {{{2
|
| # Work around bug https://bugs.kde.org/show_bug.cgi?id=162848
|
| # "fork() not handled properly"
|
| patch -p0 < "${THISDIR}/fork.patch"
|
| @@ -88,19 +60,32 @@
|
| # The corresponding feature request for Valgrind is at
|
| # https://bugs.kde.org/show_bug.cgi?id=219156.
|
| patch -p0 < "${THISDIR}/intercept_tcmalloc.patch"
|
| + # }}}
|
|
|
| + # Add ThreadSanitier to the installation.
|
| + # ThreadSanitizer is an experimental dynamic data race detector.
|
| + # See http://code.google.com/p/data-race-test/wiki/ThreadSanitizer
|
| + svn checkout -r "${TSAN_SVN_REV}" http://data-race-test.googlecode.com/svn/trunk/tsan tsan
|
| + mkdir tsan/tests
|
| + touch tsan/tests/Makefile.am
|
| + patch -p0 < tsan/valgrind.patch
|
| + # }}}
|
| +}
|
|
|
| - if [ "${INSTALL_TSAN}" = "yes" ]
|
| - then
|
| - # Add ThreadSanitier to the installation.
|
| - # ThreadSanitizer is an experimental dynamic data race detector.
|
| - # See http://code.google.com/p/data-race-test/wiki/ThreadSanitizer
|
| - svn checkout -r "${TSAN_SVN_REV}" http://data-race-test.googlecode.com/svn/trunk/tsan tsan
|
| - mkdir tsan/tests
|
| - touch tsan/tests/Makefile.am
|
| - patch -p 0 < tsan/valgrind.patch
|
| - fi
|
| +build_valgrind() {
|
| + # $1 = platform name to build; also, the name of the output subdirectory.
|
| + # $2 = flags to pass to configure
|
| + # {{{1
|
| + PLATFORM=$1
|
| + CONFIGURE_FLAGS=$2
|
|
|
| + # Output directory for valgrind's bin, include, etc.
|
| + OUTPUT_DIR="$BINARIES_DIR/$PLATFORM"
|
| +
|
| + cd "$VALGRIND_SOURCE"
|
| + # Wipe out all Makefiles which could be left by the previous installation.
|
| + make distclean || true
|
| +
|
| sh autogen.sh
|
| if test -L install-sh
|
| then
|
| @@ -110,30 +95,7 @@
|
| chmod +x install-sh
|
| fi
|
|
|
| - # MacOSX before Snow Leopoard needs newer gdb to be able to handle -O1 chrome
|
| - # Kludgily download and unpack the sources in a subdirectory.
|
| - if test `uname` = Darwin || test "x${MAKE_TARBALL}" = "xyes"
|
| - then
|
| - curl http://www.opensource.apple.com/tarballs/gdb/gdb-1344.tar.gz | tar -xzf -
|
| - fi
|
| - cd ..
|
| -
|
| -fi
|
| -
|
| -if test "x${MAKE_TARBALL}" = "xyes"
|
| -then
|
| - tar -czvf "$DIRNAME".tgz "$DIRNAME"
|
| -fi
|
| -
|
| -if test "x${USE_TARBALL}" = "xyes"
|
| -then
|
| - tar -xzvf "$DIRNAME".tgz
|
| -fi
|
| -
|
| -if test "x${MAKE_TARBALL}" != "xyes"
|
| -then
|
| - cd "$DIRNAME"
|
| -
|
| + # If gold is installed as a linker, use the old one
|
| OVERRIDE_LD_DIR="${THISDIR}/override_ld"
|
| if ld --version | grep gold
|
| then
|
| @@ -159,53 +121,100 @@
|
| fi
|
| fi
|
|
|
| - # Desired parent directory for valgrind's bin, include, etc.
|
| - PREFIX="${1:-/usr/local/$DIRNAME}"
|
| - parent_of_prefix=$(dirname "${PREFIX}")
|
| - if test ! -d "${parent_of_prefix}"
|
| + ./configure $CONFIGURE_FLAGS --prefix="${OUTPUT_DIR}"
|
| + make -j4
|
| +
|
| + # Test if Valgrind binary works on a simple program {{{2
|
| +cat > simpletest.c <<EOF
|
| +#include <stdio.h>
|
| +int main(void) {
|
| + printf("OK\n");
|
| + return 0;
|
| +}
|
| +EOF
|
| + if echo "$CONFIGURE_FLAGS" | grep "\-\-enable\-only32bit";
|
| then
|
| - echo "Directory ${parent_of_prefix} does not exist"
|
| - exit 1
|
| + gcc -m32 simpletest.c -o simpletest
|
| + else
|
| + gcc simpletest.c -o simpletest
|
| fi
|
|
|
| - ./configure --prefix="${PREFIX}"
|
| - make -j4
|
| -
|
| - if ./vg-in-place true
|
| + if ! ./vg-in-place ./simpletest
|
| then
|
| - echo built valgrind passes smoke test, good
|
| - else
|
| echo built valgrind fails smoke test
|
| exit 1
|
| fi
|
| + # }}}
|
|
|
| test -d "${OVERRIDE_LD_DIR}" && rm -rf "${OVERRIDE_LD_DIR}"
|
|
|
| - # Build and install gdb if needed
|
| - case `uname` in
|
| - Darwin)
|
| + # Finally install valgrind to $OUTPUT_DIR.
|
| + make install
|
| +
|
| + if [ "$CONFIGURE_FLAGS" == "" ] ; then
|
| + ln -s "$OUTPUT_DIR" "$BINARIES_DIR/local"
|
| + fi
|
| +
|
| + maybe_build_gdb_for_mac "$OUTPUT_DIR"
|
| +
|
| + # We're done
|
| + cd $THISDIR
|
| + # }}}
|
| +}
|
| +
|
| +maybe_build_gdb_for_mac() {
|
| + # MacOSX before Snow Leopoard needs newer gdb to be able to handle -O1 chrome
|
| + # Kludgily download and unpack the sources in a subdirectory,
|
| + # then install into $1.
|
| + # This is SLOW and we want it to run only once, so we execute it only
|
| + # if explicitly asked to do so.
|
| + if [ "${BUILD_GDB}" = "yes" ]
|
| + then
|
| + curl http://www.opensource.apple.com/tarballs/gdb/gdb-1344.tar.gz | tar -xzf -
|
| cd gdb-1344/src
|
| - ./configure --prefix="${PREFIX}"
|
| + ./configure --prefix="$1"
|
| # gdb makefile is not yet parallel-safe
|
| make
|
| - if test -w "${parent_of_prefix}"
|
| - then
|
| - make install
|
| - else
|
| - sudo make install
|
| - fi
|
| + make install
|
| cd ../..
|
| - ;;
|
| - esac
|
| -
|
| - # Finally install valgrind.
|
| - # Don't use sudo if we own the destination
|
| - if test -w "${parent_of_prefix}"
|
| - then
|
| - make install
|
| - else
|
| - sudo make install
|
| fi
|
| +}
|
|
|
| - cd ..
|
| +# Check that the binaries directory exists.
|
| +BINARIES_DIR="$THISDIR/../binaries"
|
| +if ! [ -a $BINARIES_DIR ]
|
| +then
|
| + echo "Error: $BINARIES_DIR doesn't exist!"
|
| + exit 1
|
| fi
|
| +
|
| +set -x
|
| +set -e
|
| +
|
| +checkout_and_patch_valgrind
|
| +
|
| +rm -rf $BINARIES_DIR/local
|
| +
|
| +# See "*" case for the description of the command-line argument.
|
| +case `uname -sm` in
|
| + "Linux x86_64")
|
| + # We can build both 64/32-bit and 32-bit Valgrinds
|
| + build_valgrind "linux_x64"
|
| + build_valgrind "linux_x86" "--enable-only32bit"
|
| + ;;
|
| + "Linux x86")
|
| + build_valgrind "linux_x86"
|
| + ;;
|
| + "Darwin i386")
|
| + if [ `uname -r` != "9.7.0" ]; then
|
| + echo "You have Darwin kernel different than 9.7.0"
|
| + echo "We've tested binaries built on 9.7.0 to work with 9.6.1, 9.7.0 and 9.8.0"
|
| + build_valgrind "local"
|
| + else
|
| + build_valgrind "mac"
|
| + fi
|
| + ;;
|
| + *)
|
| + build_valgrind "local"
|
| + ;;
|
| +esac
|
|
|