blob: 04582a61ca1e76bd10de07a52f3586bb6782bd92 [file] [log] [blame]
Dmitry Vyukovb78caa62012-07-05 16:18:28 +00001#!/bin/bash
2set -e
3
4SRCS="
5 tsan_go.cc
6 ../rtl/tsan_clock.cc
7 ../rtl/tsan_flags.cc
8 ../rtl/tsan_md5.cc
9 ../rtl/tsan_mutex.cc
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000010 ../rtl/tsan_report.cc
11 ../rtl/tsan_rtl.cc
12 ../rtl/tsan_rtl_mutex.cc
13 ../rtl/tsan_rtl_report.cc
14 ../rtl/tsan_rtl_thread.cc
15 ../rtl/tsan_stat.cc
16 ../rtl/tsan_suppressions.cc
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000017 ../rtl/tsan_sync.cc
18 ../../sanitizer_common/sanitizer_allocator.cc
19 ../../sanitizer_common/sanitizer_common.cc
Dmitry Vyukov7ffba062012-07-16 10:36:39 +000020 ../../sanitizer_common/sanitizer_flags.cc
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000021 ../../sanitizer_common/sanitizer_libc.cc
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000022 ../../sanitizer_common/sanitizer_printf.cc
Dmitry Vyukov491852e2013-03-18 08:52:46 +000023 ../../sanitizer_common/sanitizer_thread_registry.cc
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000024"
25
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000026if [ "`uname -a | grep Linux`" != "" ]; then
27 SUFFIX="linux_amd64"
28 OSCFLAGS="-fPIC -ffreestanding"
Dmitry Vyukova05fcc12012-11-06 16:00:16 +000029 OSLDFLAGS="-lpthread -fPIC -fpie"
Dmitry Vyukov5b266cb2012-07-16 13:02:40 +000030 SRCS+="
31 ../rtl/tsan_platform_linux.cc
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000032 ../../sanitizer_common/sanitizer_posix.cc
Peter Collingbourne04a22812013-05-21 10:27:07 +000033 ../../sanitizer_common/sanitizer_posix_libcdep.cc
Dmitry Vyukov5b266cb2012-07-16 13:02:40 +000034 ../../sanitizer_common/sanitizer_linux.cc
Peter Collingbourne088ea2b2013-05-20 15:57:44 +000035 ../../sanitizer_common/sanitizer_linux_libcdep.cc
Dmitry Vyukov5b266cb2012-07-16 13:02:40 +000036 "
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000037elif [ "`uname -a | grep Darwin`" != "" ]; then
38 SUFFIX="darwin_amd64"
39 OSCFLAGS="-fPIC"
Dmitry Vyukova05fcc12012-11-06 16:00:16 +000040 OSLDFLAGS="-lpthread -fPIC -fpie"
Dmitry Vyukov7d15f5d2012-08-13 18:44:44 +000041 SRCS+="
42 ../rtl/tsan_platform_mac.cc
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000043 ../../sanitizer_common/sanitizer_posix.cc
Dmitry Vyukov7d15f5d2012-08-13 18:44:44 +000044 ../../sanitizer_common/sanitizer_mac.cc
Dmitry Vyukovd4bb4a62013-06-06 13:00:32 +000045 ../../sanitizer_common/sanitizer_posix_libcdep.cc
Dmitry Vyukov7d15f5d2012-08-13 18:44:44 +000046 "
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000047elif [ "`uname -a | grep MINGW`" != "" ]; then
48 SUFFIX="windows_amd64"
49 OSCFLAGS="-Wno-error=attributes -Wno-attributes"
50 OSLDFLAGS=""
51 SRCS+="
52 ../rtl/tsan_platform_windows.cc
53 ../../sanitizer_common/sanitizer_win.cc
54 "
55else
56 echo Unknown platform
57 exit 1
Dmitry Vyukov5b266cb2012-07-16 13:02:40 +000058fi
59
Dmitry Vyukov87dbdf52012-07-25 14:30:51 +000060SRCS+=$ADD_SRCS
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000061
62rm -f gotsan.cc
63for F in $SRCS; do
64 cat $F >> gotsan.cc
65done
66
Dmitry Vyukove0c45612013-06-11 11:44:43 +000067FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -m64 -Wall -Werror -Wno-maybe-uninitialized -fno-exceptions -fno-rtti -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 $OSCFLAGS"
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000068if [ "$DEBUG" == "" ]; then
Dmitry Vyukov7ffba062012-07-16 10:36:39 +000069 FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000070else
Dmitry Vyukov7ffba062012-07-16 10:36:39 +000071 FLAGS+=" -DTSAN_DEBUG=1 -g"
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000072fi
73
Dmitry Vyukov7ffba062012-07-16 10:36:39 +000074echo gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
75gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000076cat tmp.s $ASMS > gotsan.s
Dmitry Vyukov6b2804f2012-07-27 14:00:39 +000077echo as gotsan.s -o race_$SUFFIX.syso
78as gotsan.s -o race_$SUFFIX.syso
Dmitry Vyukovb78caa62012-07-05 16:18:28 +000079
Dmitry Vyukov65c445c2012-11-06 13:32:53 +000080gcc test.c race_$SUFFIX.syso -m64 -o test $OSLDFLAGS
Dmitry Vyukov6f121a12012-11-08 13:23:13 +000081GORACE="exitcode=0 atexit_sleep_ms=0" ./test