diff --git a/compiler-rt/lib/tsan/Makefile.old b/compiler-rt/lib/tsan/Makefile.old index 79f5d8a53101..d91a3dfab683 100644 --- a/compiler-rt/lib/tsan/Makefile.old +++ b/compiler-rt/lib/tsan/Makefile.old @@ -71,14 +71,12 @@ presubmit: # Release build with clang. $(MAKE) -f Makefile.old clean $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=$(CLANG) CXX=$(CLANG)++ - ./check_memcpy.sh # Debug build with gcc $(MAKE) -f Makefile.old clean $(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=gcc CXX=g++ # Release build with gcc $(MAKE) -f Makefile.old clean $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++ - ./check_memcpy.sh # Sanity check for Go runtime (cd go && ./buildgo.sh) # Check cmake build diff --git a/compiler-rt/lib/tsan/check_memcpy.sh b/compiler-rt/lib/tsan/check_memcpy.sh deleted file mode 100755 index 101df1166b7c..000000000000 --- a/compiler-rt/lib/tsan/check_memcpy.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Ensure that tsan runtime does not contain compiler-emitted memcpy and memset calls. - -set -eu - -ROOTDIR=$(dirname $0) -TEST_DIR=$ROOTDIR/../../test/tsan - -: ${CXX:=clang++} -CFLAGS="-fsanitize=thread -fPIE -O1 -g" -LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive" - -SRC=$TEST_DIR/simple_race.cc -OBJ=$SRC.o -EXE=$SRC.exe -$CXX $SRC $CFLAGS -c -o $OBJ -$CXX $OBJ $LDFLAGS -o $EXE - -NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l) -if [ "$NCALL" != "0" ]; then - echo FAIL: found $NCALL memcpy/memset calls - exit 1 -fi - -# tail calls -NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l) -if [ "$NCALL" != "0" ]; then - echo FAIL: found $NCALL memcpy/memset calls - exit 1 -fi diff --git a/compiler-rt/test/tsan/Linux/check_memcpy.cc b/compiler-rt/test/tsan/Linux/check_memcpy.cc new file mode 100644 index 000000000000..86f2455fc3dc --- /dev/null +++ b/compiler-rt/test/tsan/Linux/check_memcpy.cc @@ -0,0 +1,11 @@ +// Test that verifies TSan runtime doesn't contain compiler-emitted +// memcpy/memmove calls. It builds the binary with TSan and passes it to +// check_memcpy.sh script. + +// RUN: %clangxx_tsan -O1 %s -o %t +// RUN: %S/check_memcpy.sh %t + +int main() { + return 0; +} + diff --git a/compiler-rt/test/tsan/Linux/check_memcpy.sh b/compiler-rt/test/tsan/Linux/check_memcpy.sh new file mode 100755 index 000000000000..2b5f21fa882c --- /dev/null +++ b/compiler-rt/test/tsan/Linux/check_memcpy.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Script that ensures that TSan runtime does not contain compiler-emitted +# memcpy and memset calls. + +set -eu + +if [[ "$#" != 1 ]]; then + echo "Usage: $0 /path/to/binary/built/with/tsan" + exit 1 +fi + +EXE=$1 + +NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l) +if [ "$NCALL" != "0" ]; then + echo FAIL: found $NCALL memcpy/memset calls + exit 1 +fi + +# tail calls +NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l) +if [ "$NCALL" != "0" ]; then + echo FAIL: found $NCALL memcpy/memset calls + exit 1 +fi