Home | History | Annotate | Download | only in go
      1 #!/bin/bash
      2 set -e
      3 
      4 if [ "`uname -a | grep Linux`" != "" ]; then
      5 	LINUX=1
      6 	SUFFIX="linux_amd64"
      7 elif [ "`uname -a | grep Darwin`" != "" ]; then
      8 	MAC=1
      9 	SUFFIX="darwin_amd64"
     10 else
     11 	echo Unknown platform
     12 	exit 1
     13 fi
     14 
     15 SRCS="
     16 	tsan_go.cc
     17 	../rtl/tsan_clock.cc
     18 	../rtl/tsan_flags.cc
     19 	../rtl/tsan_md5.cc
     20 	../rtl/tsan_mutex.cc
     21 	../rtl/tsan_printf.cc
     22 	../rtl/tsan_report.cc
     23 	../rtl/tsan_rtl.cc
     24 	../rtl/tsan_rtl_mutex.cc
     25 	../rtl/tsan_rtl_report.cc
     26 	../rtl/tsan_rtl_thread.cc
     27 	../rtl/tsan_stat.cc
     28 	../rtl/tsan_suppressions.cc
     29 	../rtl/tsan_sync.cc
     30 	../../sanitizer_common/sanitizer_allocator.cc
     31 	../../sanitizer_common/sanitizer_common.cc
     32 	../../sanitizer_common/sanitizer_flags.cc
     33 	../../sanitizer_common/sanitizer_libc.cc
     34 	../../sanitizer_common/sanitizer_posix.cc
     35 	../../sanitizer_common/sanitizer_printf.cc
     36 "
     37 
     38 if [ "$LINUX" != "" ]; then
     39 	SRCS+="
     40 		../rtl/tsan_platform_linux.cc
     41 		../../sanitizer_common/sanitizer_linux.cc
     42 	"
     43 elif [ "$MAC" != "" ]; then
     44 	SRCS+="
     45 		../rtl/tsan_platform_mac.cc
     46 		../../sanitizer_common/sanitizer_mac.cc
     47 	"
     48 fi
     49 
     50 SRCS+=$ADD_SRCS
     51 #ASMS="../rtl/tsan_rtl_amd64.S"
     52 
     53 rm -f gotsan.cc
     54 for F in $SRCS; do
     55 	cat $F >> gotsan.cc
     56 done
     57 
     58 FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -fPIC -g -Wall -Werror -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4"
     59 if [ "$DEBUG" == "" ]; then
     60 	FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
     61 else
     62 	FLAGS+=" -DTSAN_DEBUG=1 -g"
     63 fi
     64 
     65 if [ "$LINUX" != "" ]; then
     66 	FLAGS+=" -ffreestanding"
     67 fi
     68 
     69 echo gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
     70 gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
     71 cat tmp.s $ASMS > gotsan.s
     72 echo as gotsan.s -o race_$SUFFIX.syso
     73 as gotsan.s -o race_$SUFFIX.syso
     74 
     75 gcc test.c race_$SUFFIX.syso -lpthread -o test
     76 TSAN_OPTIONS="exitcode=0" ./test
     77 
     78