| #!/bin/sh |
| |
| # Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Script to build ThreadSanitizer binaries for use with chromium |
| source common.sh |
| |
| POST_BUILD_HOOK_DEFINED=yes |
| post_build_hook() { |
| PLATFORM=$1 |
| cd "$THISDIR/tsan/tsan" |
| |
| SPECIAL_TARGET= |
| SPECIAL_FLAGS= |
| # We can build two target architectures on a Linux x64 machine, so we should |
| # a) Use separate output directories, |
| # b) Explicitly specify 32-bit linux for x86 build. |
| case "$PLATFORM" in |
| "linux_x64") |
| SPECIAL_FLAGS="OUTDIR=out64" |
| ;; |
| "linux_x86") |
| SPECIAL_FLAGS="OUTDIR=out32" |
| SPECIAL_TARGET="l32" |
| ;; |
| esac |
| |
| make -j4 $SPECIAL_FLAGS OFFLINE= PIN_ROOT= \ |
| VALGRIND_INST_ROOT="$BINARIES_DIR/$PLATFORM" \ |
| VALGRIND_ROOT="$VG_TSAN_DIR" $SPECIAL_TARGET |
| |
| # See below for the definition of ORIG_BINARIES_DIR |
| $THISDIR/tsan/tsan/mk-self-contained-valgrind.sh \ |
| "$VG_TSAN_DIR/out/$PLATFORM" "tsan" \ |
| "$ORIG_BINARIES_DIR/$PLATFORM/bin/valgrind-tsan.sh" |
| } |
| |
| TSAN_REV=2088 |
| TSAN_DIR="$THISDIR/tsan" # Directory to checkout TSan sources |
| rm -rf $TSAN_DIR |
| svn co -r "$TSAN_REV" http://data-race-test.googlecode.com/svn/trunk $TSAN_DIR |
| |
| # The separate .sh file defines Valgrind/VEX revisions. |
| source "tsan/third_party/valgrind_rev.sh" |
| |
| VG_TSAN_DIR="$THISDIR/valgrind-tsan" # Directory to checkout Valgrind sources |
| checkout_and_patch_valgrind "$VALGRIND_REV" "$VEX_REV" "$VG_TSAN_DIR" |
| |
| cd "$VG_TSAN_DIR" |
| |
| # Apply TSan-specific patches except |
| # * limits |
| # * guest_amd64_toIR |
| # since they are already applied in common.sh. |
| rm "$THISDIR"/tsan/valgrind_patches/{limits,guest_amd64_toIR}.patch |
| for P in "$THISDIR"/tsan/valgrind_patches/*.patch |
| do |
| patch -p0 -i $P |
| done |
| |
| if [ `uname -s` == "Darwin" ] |
| then |
| if ls /opt/local/bin/ | grep "^gcc-mp-4\.4" >/dev/null |
| then |
| export GCC_BINARY_MASK="/opt/local/bin/XXX-mp-4.4" |
| export PATH="$THISDIR/macports-gcc-wrapper:$PATH" |
| echo "Using gcc-4.4 from MacPorts to build ThreadSanitizer." |
| elif gcc --version | grep " 4\.[0-3]\.[0-9]\| 3\.[0-9]\.[0-9]" >/dev/null |
| then |
| echo "Your gcc version is older than 4.4." |
| echo "It is recommended to use gcc-4.4 from MacPorts for building" |
| echo "ThreadSanitizer, especially if you plan to commit binaries into SVN." |
| echo "See http://gcc44.darwinports.com/ for getting gcc-4.4" |
| echo "" |
| echo -n "Do you want to continue using old gcc? (y/N)" |
| read CONFIRMATION |
| if [ "$CONFIRMATION" != "y" ] |
| then |
| exit 1 |
| fi |
| fi |
| fi |
| |
| # Ugly hack! |
| # We build Valrgind binaries in the $VG_TSAN_DIR/out and then pack |
| # them into self-contained .sh file into $ORIG_BINARIES_DIR/$PLATFORM |
| ORIG_BINARIES_DIR=$BINARIES_DIR |
| BINARIES_DIR="$VG_TSAN_DIR/out" |
| build_valgrind_for_available_platforms |