2012-07-06 00:18:28 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2012-07-16 21:02:40 +08:00
|
|
|
if [ "`uname -a | grep Linux`" != "" ]; then
|
|
|
|
LINUX=1
|
2012-07-17 02:25:43 +08:00
|
|
|
SUFFIX="linux_amd64"
|
2012-07-16 21:02:40 +08:00
|
|
|
elif [ "`uname -a | grep Darwin`" != "" ]; then
|
|
|
|
MAC=1
|
2012-07-17 02:25:43 +08:00
|
|
|
SUFFIX="darwin_amd64"
|
2012-07-16 21:02:40 +08:00
|
|
|
else
|
|
|
|
echo Unknown platform
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-07-06 00:18:28 +08:00
|
|
|
SRCS="
|
|
|
|
tsan_go.cc
|
|
|
|
../rtl/tsan_clock.cc
|
|
|
|
../rtl/tsan_flags.cc
|
|
|
|
../rtl/tsan_md5.cc
|
|
|
|
../rtl/tsan_mutex.cc
|
|
|
|
../rtl/tsan_report.cc
|
|
|
|
../rtl/tsan_rtl.cc
|
|
|
|
../rtl/tsan_rtl_mutex.cc
|
|
|
|
../rtl/tsan_rtl_report.cc
|
|
|
|
../rtl/tsan_rtl_thread.cc
|
|
|
|
../rtl/tsan_stat.cc
|
|
|
|
../rtl/tsan_suppressions.cc
|
|
|
|
../rtl/tsan_sync.cc
|
|
|
|
../../sanitizer_common/sanitizer_allocator.cc
|
|
|
|
../../sanitizer_common/sanitizer_common.cc
|
2012-07-16 18:36:39 +08:00
|
|
|
../../sanitizer_common/sanitizer_flags.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
../../sanitizer_common/sanitizer_libc.cc
|
|
|
|
../../sanitizer_common/sanitizer_posix.cc
|
|
|
|
../../sanitizer_common/sanitizer_printf.cc
|
|
|
|
"
|
|
|
|
|
2012-07-16 21:02:40 +08:00
|
|
|
if [ "$LINUX" != "" ]; then
|
|
|
|
SRCS+="
|
|
|
|
../rtl/tsan_platform_linux.cc
|
|
|
|
../../sanitizer_common/sanitizer_linux.cc
|
|
|
|
"
|
|
|
|
elif [ "$MAC" != "" ]; then
|
2012-08-14 02:44:44 +08:00
|
|
|
SRCS+="
|
|
|
|
../rtl/tsan_platform_mac.cc
|
|
|
|
../../sanitizer_common/sanitizer_mac.cc
|
|
|
|
"
|
2012-07-16 21:02:40 +08:00
|
|
|
fi
|
|
|
|
|
2012-07-25 22:30:51 +08:00
|
|
|
SRCS+=$ADD_SRCS
|
2012-07-06 00:18:28 +08:00
|
|
|
#ASMS="../rtl/tsan_rtl_amd64.S"
|
|
|
|
|
|
|
|
rm -f gotsan.cc
|
|
|
|
for F in $SRCS; do
|
|
|
|
cat $F >> gotsan.cc
|
|
|
|
done
|
|
|
|
|
2012-09-19 12:39:36 +08:00
|
|
|
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -fPIC -Wall -Werror -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4"
|
2012-07-06 00:18:28 +08:00
|
|
|
if [ "$DEBUG" == "" ]; then
|
2012-07-16 18:36:39 +08:00
|
|
|
FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
|
2012-07-06 00:18:28 +08:00
|
|
|
else
|
2012-07-16 18:36:39 +08:00
|
|
|
FLAGS+=" -DTSAN_DEBUG=1 -g"
|
2012-07-06 00:18:28 +08:00
|
|
|
fi
|
|
|
|
|
2012-07-16 21:02:40 +08:00
|
|
|
if [ "$LINUX" != "" ]; then
|
|
|
|
FLAGS+=" -ffreestanding"
|
|
|
|
fi
|
|
|
|
|
2012-07-16 18:36:39 +08:00
|
|
|
echo gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
|
|
|
|
gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
|
2012-07-06 00:18:28 +08:00
|
|
|
cat tmp.s $ASMS > gotsan.s
|
2012-07-27 22:00:39 +08:00
|
|
|
echo as gotsan.s -o race_$SUFFIX.syso
|
|
|
|
as gotsan.s -o race_$SUFFIX.syso
|
2012-07-06 00:18:28 +08:00
|
|
|
|
2012-07-27 02:42:51 +08:00
|
|
|
gcc test.c race_$SUFFIX.syso -lpthread -o test
|
2012-07-28 23:27:41 +08:00
|
|
|
TSAN_OPTIONS="exitcode=0" ./test
|
2012-07-06 22:54:25 +08:00
|
|
|
|