From 6326786ce7273ee65b2cdcf8ec47752b77ede293 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 3 Nov 2015 07:14:22 -0800 Subject: [PATCH] misc/cgo/testsanitizers: fix test of whether compiler option works On older versions of GCC we need to pass a file name before GCC will report an unrecognized option. Fixes #13065. Change-Id: I7ed34c01a006966a446059025f7d10235c649072 Reviewed-on: https://go-review.googlesource.com/16589 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: David Crawshaw --- misc/cgo/testsanitizers/test.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/cgo/testsanitizers/test.bash b/misc/cgo/testsanitizers/test.bash index cc50d386e3..88c54e6173 100755 --- a/misc/cgo/testsanitizers/test.bash +++ b/misc/cgo/testsanitizers/test.bash @@ -15,10 +15,14 @@ if test "$(type -p clang)" != ""; then fi export CC -if $CC -fsanitize=memory 2>&1 | grep "unrecognized" >& /dev/null; then +TMPDIR=${TMPDIR:-/tmp} +echo > ${TMPDIR}/testsanitizers$$.c +if $CC -fsanitize=memory -c ${TMPDIR}/testsanitizers$$.c 2>&1 | grep "unrecognized" >& /dev/null; then echo "skipping msan test: -fsanitize=memory not supported" + rm -f ${TMPDIR}/testsanitizers$$.* exit 0 fi +rm -f ${TMPDIR}/testsanitizers$$.* # The memory sanitizer in versions of clang before 3.6 don't work with Go. if $CC --version | grep clang >& /dev/null; then -- 2.48.1