Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 3 | set -e |
| 4 | |
| 5 | SRCS=" |
| 6 | tsan_go.cc |
| 7 | ../rtl/tsan_clock.cc |
| 8 | ../rtl/tsan_flags.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 9 | ../rtl/tsan_interface_atomic.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 10 | ../rtl/tsan_md5.cc |
| 11 | ../rtl/tsan_mutex.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 12 | ../rtl/tsan_report.cc |
| 13 | ../rtl/tsan_rtl.cc |
| 14 | ../rtl/tsan_rtl_mutex.cc |
| 15 | ../rtl/tsan_rtl_report.cc |
| 16 | ../rtl/tsan_rtl_thread.cc |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 17 | ../rtl/tsan_stack_trace.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 18 | ../rtl/tsan_stat.cc |
| 19 | ../rtl/tsan_suppressions.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 20 | ../rtl/tsan_sync.cc |
| 21 | ../../sanitizer_common/sanitizer_allocator.cc |
| 22 | ../../sanitizer_common/sanitizer_common.cc |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 23 | ../../sanitizer_common/sanitizer_common_libcdep.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 24 | ../../sanitizer_common/sanitizer_deadlock_detector2.cc |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 25 | ../../sanitizer_common/sanitizer_flag_parser.cc |
Dmitry Vyukov | 7ffba06 | 2012-07-16 10:36:39 +0000 | [diff] [blame] | 26 | ../../sanitizer_common/sanitizer_flags.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 27 | ../../sanitizer_common/sanitizer_libc.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 28 | ../../sanitizer_common/sanitizer_persistent_allocator.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 29 | ../../sanitizer_common/sanitizer_printf.cc |
Alexey Samsonov | c11d303 | 2013-06-27 07:57:53 +0000 | [diff] [blame] | 30 | ../../sanitizer_common/sanitizer_suppressions.cc |
Dmitry Vyukov | 491852e | 2013-03-18 08:52:46 +0000 | [diff] [blame] | 31 | ../../sanitizer_common/sanitizer_thread_registry.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 32 | ../../sanitizer_common/sanitizer_stackdepot.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 33 | ../../sanitizer_common/sanitizer_stacktrace.cc |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 34 | ../../sanitizer_common/sanitizer_symbolizer.cc |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 35 | " |
| 36 | |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 37 | if [ "`uname -a | grep Linux`" != "" ]; then |
| 38 | SUFFIX="linux_amd64" |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 39 | OSCFLAGS="-fPIC -ffreestanding -Wno-maybe-uninitialized -Wno-unused-const-variable -Werror -Wno-unknown-warning-option" |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 40 | OSLDFLAGS="-lpthread -fPIC -fpie" |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 41 | SRCS=" |
| 42 | $SRCS |
Dmitry Vyukov | 5b266cb | 2012-07-16 13:02:40 +0000 | [diff] [blame] | 43 | ../rtl/tsan_platform_linux.cc |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 44 | ../../sanitizer_common/sanitizer_posix.cc |
Peter Collingbourne | 04a2281 | 2013-05-21 10:27:07 +0000 | [diff] [blame] | 45 | ../../sanitizer_common/sanitizer_posix_libcdep.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 46 | ../../sanitizer_common/sanitizer_procmaps_common.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 47 | ../../sanitizer_common/sanitizer_procmaps_linux.cc |
Dmitry Vyukov | 5b266cb | 2012-07-16 13:02:40 +0000 | [diff] [blame] | 48 | ../../sanitizer_common/sanitizer_linux.cc |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 49 | ../../sanitizer_common/sanitizer_linux_libcdep.cc |
Dmitry Vyukov | 92b5479 | 2013-10-03 17:14:35 +0000 | [diff] [blame] | 50 | ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc |
Dmitry Vyukov | 5b266cb | 2012-07-16 13:02:40 +0000 | [diff] [blame] | 51 | " |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 52 | elif [ "`uname -a | grep FreeBSD`" != "" ]; then |
| 53 | SUFFIX="freebsd_amd64" |
| 54 | OSCFLAGS="-fno-strict-aliasing -fPIC -Werror" |
| 55 | OSLDFLAGS="-lpthread -fPIC -fpie" |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 56 | SRCS=" |
| 57 | $SRCS |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 58 | ../rtl/tsan_platform_linux.cc |
| 59 | ../../sanitizer_common/sanitizer_posix.cc |
| 60 | ../../sanitizer_common/sanitizer_posix_libcdep.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 61 | ../../sanitizer_common/sanitizer_procmaps_common.cc |
| 62 | ../../sanitizer_common/sanitizer_procmaps_freebsd.cc |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 63 | ../../sanitizer_common/sanitizer_linux.cc |
| 64 | ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc |
| 65 | " |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 66 | elif [ "`uname -a | grep Darwin`" != "" ]; then |
| 67 | SUFFIX="darwin_amd64" |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 68 | OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option" |
Dmitry Vyukov | a05fcc1 | 2012-11-06 16:00:16 +0000 | [diff] [blame] | 69 | OSLDFLAGS="-lpthread -fPIC -fpie" |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 70 | SRCS=" |
| 71 | $SRCS |
Dmitry Vyukov | 7d15f5d | 2012-08-13 18:44:44 +0000 | [diff] [blame] | 72 | ../rtl/tsan_platform_mac.cc |
| 73 | ../../sanitizer_common/sanitizer_mac.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 74 | ../../sanitizer_common/sanitizer_posix.cc |
Dmitry Vyukov | d4bb4a6 | 2013-06-06 13:00:32 +0000 | [diff] [blame] | 75 | ../../sanitizer_common/sanitizer_posix_libcdep.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 76 | ../../sanitizer_common/sanitizer_procmaps_mac.cc |
Dmitry Vyukov | 7d15f5d | 2012-08-13 18:44:44 +0000 | [diff] [blame] | 77 | " |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 78 | elif [ "`uname -a | grep MINGW`" != "" ]; then |
| 79 | SUFFIX="windows_amd64" |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 80 | OSCFLAGS="-Wno-error=attributes -Wno-attributes -Wno-unused-const-variable -Wno-unknown-warning-option" |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 81 | OSLDFLAGS="" |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 82 | SRCS=" |
| 83 | $SRCS |
Dmitry Vyukov | 65c445c | 2012-11-06 13:32:53 +0000 | [diff] [blame] | 84 | ../rtl/tsan_platform_windows.cc |
| 85 | ../../sanitizer_common/sanitizer_win.cc |
| 86 | " |
| 87 | else |
| 88 | echo Unknown platform |
| 89 | exit 1 |
Dmitry Vyukov | 5b266cb | 2012-07-16 13:02:40 +0000 | [diff] [blame] | 90 | fi |
| 91 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 92 | CC=${CC:-gcc} |
| 93 | IN_TMPDIR=${IN_TMPDIR:-0} |
| 94 | SILENT=${SILENT:-0} |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 95 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 96 | if [ $IN_TMPDIR != "0" ]; then |
| 97 | DIR=$(mktemp -qd /tmp/gotsan.XXXXXXXXXX) |
| 98 | cleanup() { |
| 99 | rm -rf $DIR |
| 100 | } |
| 101 | trap cleanup EXIT |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 102 | else |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 103 | DIR=. |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 104 | fi |
| 105 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 106 | SRCS="$SRCS $ADD_SRCS" |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 107 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 108 | rm -f $DIR/gotsan.cc |
| 109 | for F in $SRCS; do |
| 110 | cat $F >> $DIR/gotsan.cc |
| 111 | done |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 112 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 113 | FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS" |
| 114 | if [ "$DEBUG" = "" ]; then |
| 115 | FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer" |
| 116 | else |
| 117 | FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g" |
| 118 | fi |
| 119 | |
| 120 | if [ "$SILENT" != "1" ]; then |
| 121 | echo $CC gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS |
| 122 | fi |
| 123 | $CC $DIR/gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS |
| 124 | |
| 125 | $CC test.c $DIR/race_$SUFFIX.syso -m64 -o $DIR/test $OSLDFLAGS |
| 126 | |
| 127 | export GORACE="exitcode=0 atexit_sleep_ms=0" |
| 128 | if [ "$SILENT" != "1" ]; then |
| 129 | $DIR/test |
| 130 | else |
| 131 | $DIR/test 2>/dev/null |
| 132 | fi |