Skip to content

Commit eaf5235

Browse files
misc/cgo/testsanitizers: don't run tsan tests on old clang
Fixes #14570. Change-Id: Ief84a14585bfc209e38cdf15702c2f54ba759714 Reviewed-on: https://go-review.googlesource.com/20057 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
1 parent d3b00a8 commit eaf5235

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

misc/cgo/testsanitizers/test.bash

+23-11
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ if $CC -fsanitize=memory -c ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsaniti
2525
fi
2626
rm -f ${TMPDIR}/testsanitizers$$.*
2727

28-
# The memory sanitizer in versions of clang before 3.6 don't work with Go.
28+
tsan=yes
29+
30+
# The memory and thread sanitizers in versions of clang before 3.6
31+
# don't work with Go.
2932
if test "$msan" = "yes" && $CC --version | grep clang >& /dev/null; then
3033
ver=$($CC --version | sed -e 's/.* version \([0-9.-]*\).*/\1/')
3134
major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/')
3235
minor=$(echo $ver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/')
3336
if test "$major" -lt 3 || test "$major" -eq 3 -a "$minor" -lt 6; then
34-
echo "skipping msan tests: clang version $major.$minor (older than 3.6)"
37+
echo "skipping msan/tsan tests: clang version $major.$minor (older than 3.6)"
3538
msan=no
39+
tsan=no
3640
fi
3741

3842
# Clang before 3.8 does not work with Linux at or after 4.1.
@@ -43,8 +47,9 @@ if test "$msan" = "yes" && $CC --version | grep clang >& /dev/null; then
4347
linuxmajor=$(echo $linuxver | sed -e 's/\([0-9]*\).*/\1/')
4448
linuxminor=$(echo $linuxver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/')
4549
if test "$linuxmajor" -gt 4 || test "$linuxmajor" -eq 4 -a "$linuxminor" -ge 1; then
46-
echo "skipping msan tests: clang version $major.$minor (older than 3.8) incompatible with linux version $linuxmajor.$linuxminor (4.1 or newer)"
50+
echo "skipping msan/tsan tests: clang version $major.$minor (older than 3.8) incompatible with linux version $linuxmajor.$linuxminor (4.1 or newer)"
4751
msan=no
52+
tsan=no
4853
fi
4954
fi
5055
fi
@@ -89,15 +94,22 @@ if test "$msan" = "yes"; then
8994
fi
9095
fi
9196

92-
tsan=yes
93-
94-
TMPDIR=${TMPDIR:-/tmp}
95-
echo > ${TMPDIR}/testsanitizers$$.c
96-
if $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ 2>&1 | grep "unrecognized" >& /dev/null; then
97-
echo "skipping tsan tests: -fsanitize=thread not supported"
98-
tsan=no
97+
if test "$tsan" = "yes"; then
98+
echo 'int main() { return 0; }' > ${TMPDIR}/testsanitizers$$.c
99+
ok=yes
100+
if ! $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ &> ${TMPDIR}/testsanitizers$$.err; then
101+
ok=no
102+
fi
103+
if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then
104+
echo "skipping tsan tests: -fsanitize=thread not supported"
105+
tsan=no
106+
elif test "$ok" != "yes"; then
107+
cat ${TMPDIR}/testsanitizers$$.err
108+
echo "skipping tsan tests: -fsanitizer=thread build failed"
109+
tsan=no
110+
fi
111+
rm -f ${TMPDIR}/testsanitizers$$*
99112
fi
100-
rm -f ${TMPDIR}/testsanitizers$$.*
101113

102114
if test "$tsan" = "yes"; then
103115
err=${TMPDIR}/tsanerr$$.out

0 commit comments

Comments
 (0)