tsan: port Go runtime to Darwin
llvm-svn: 160266
diff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 5382af2..0741790 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -1,13 +1,21 @@
#!/bin/bash
set -e
+if [ "`uname -a | grep Linux`" != "" ]; then
+ LINUX=1
+elif [ "`uname -a | grep Darwin`" != "" ]; then
+ MAC=1
+else
+ echo Unknown platform
+ exit 1
+fi
+
SRCS="
tsan_go.cc
../rtl/tsan_clock.cc
../rtl/tsan_flags.cc
../rtl/tsan_md5.cc
../rtl/tsan_mutex.cc
- ../rtl/tsan_platform_linux.cc
../rtl/tsan_printf.cc
../rtl/tsan_report.cc
../rtl/tsan_rtl.cc
@@ -21,12 +29,23 @@
../../sanitizer_common/sanitizer_common.cc
../../sanitizer_common/sanitizer_flags.cc
../../sanitizer_common/sanitizer_libc.cc
- ../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_printf.cc
../../sanitizer_common/sanitizer_symbolizer.cc
"
+if [ "$LINUX" != "" ]; then
+ SRCS+="
+ ../rtl/tsan_platform_linux.cc
+ ../../sanitizer_common/sanitizer_linux.cc
+ "
+elif [ "$MAC" != "" ]; then
+ SRCS+="
+ ../rtl/tsan_platform_mac.cc
+ ../../sanitizer_common/sanitizer_mac.cc
+ "
+fi
+
#ASMS="../rtl/tsan_rtl_amd64.S"
rm -f gotsan.cc
@@ -34,13 +53,17 @@
cat $F >> gotsan.cc
done
-FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -ffreestanding -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4"
+FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4"
if [ "$DEBUG" == "" ]; then
FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
else
FLAGS+=" -DTSAN_DEBUG=1 -g"
fi
+if [ "$LINUX" != "" ]; then
+ FLAGS+=" -ffreestanding"
+fi
+
echo gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
gcc gotsan.cc -S -o tmp.s $FLAGS $CFLAGS
cat tmp.s $ASMS > gotsan.s
diff --git a/compiler-rt/lib/tsan/go/tsan_go.cc b/compiler-rt/lib/tsan/go/tsan_go.cc
index 11f14da..13cc569 100644
--- a/compiler-rt/lib/tsan/go/tsan_go.cc
+++ b/compiler-rt/lib/tsan/go/tsan_go.cc
@@ -39,7 +39,7 @@
extern "C" int goCallbackCommentPc(uptr pc, char **img, char **rtn,
char **filename, int *lineno);
-extern "C" void __libc_free(void *p);
+extern "C" void free(void *p);
ReportStack *SymbolizeCode(uptr addr) {
ReportStack *s = NewReportStackEntry(addr);
@@ -52,9 +52,9 @@
s->file = internal_strdup(filename);
s->line = lineno;
s->col = 0;
- __libc_free(img);
- __libc_free(rtn);
- __libc_free(filename);
+ free(img);
+ free(rtn);
+ free(filename);
}
return s;
}