How to use a disinfectant for gcc v4.8.1?

gcc v4.8.x add options for debugging your program:

-fsanitize = thread

Enable ThreadSanitizer, a fast data race detector. The instructions for accessing the memory will be used to detect errors in the calculation of data. See http://code.google.com/p/data-race-test/wiki/ThreadSanitizer for details.

My gcc version on Fedora 19:

gcc version 4.8.1 20130603 (Red Hat 4.8.1-1) (GCC) 

Associate my program with the command below (CMake output):

 Linking C executable bin/ftu /usr/bin/cmake -E cmake_link_script CMakeFiles/ftu.dir/link.txt --verbose=1 /usr/bin/cc -g -g -O0 -Wall -D_REENTRANT -rdynamic -fsanitize=thread -fPIE -pie CMakeFiles/ftu.dir/src/main/main.co -o bin/ftu -L/home/hl/ftu/arm/src/libapp/pc -rdynamic ../libapp/pc/libbase.a ../libapp/pc/libstbl.a ../libapp/pc/libstbl_utest.a ../libapp/pc/libbase_utest.a ../libapp/pc/libmem_utest.a ../libapp/pc/libmemspy_utest.a ../libapp/pc/libos_utest.a ../libapp/pc/libmain_utest.a ../libapp/pc/liblog_utest.a ../libapp/pc/libini_utest.a ../libapp/pc/libdsp_utest.a ../libapp/pc/libmstation_utest.a ../libapp/pc/libflist_utest.a ../libapp/pc/libdc_utest.a ../libapp/pc/libflist.a ../libapp/pc/libdsp.a ../libapp/pc/liblog.a ../libapp/pc/libini.a ../libapp/pc/libmstation.a ../libapp/pc/libdc.a ../libapp/pc/libmemspy.a ../libapp/pc/libmem.a ../libapp/pc/libos.a ../libapp/pc/libbase.a -lrt -lpopt -lpthread -Wl,-rpath,/home/hl/ftu/arm/src/libapp/pc /usr/bin/ld: cannot find -ltsan collect2: error: ld returned 1 exit status 

Gcc says, "Can't find -ltsan." Where is the liban?

I found something at http://gcc.gnu.org/gcc-4.8/changes.html :

ThreadSanitizer is added and can be enabled via -fsanitize = thread. The instructions will be designed to detect racing data. ThreadSanitizer is available on x86-64 GNU / Linux.

-fsanitize = thread is supported only on a 64-bit processor. My output is linux uname -a :

Linux hl.zy 3.9.8-300.fc19.i686 # 1 SMP Thu Jun 27 19:40:39 UTC 2013 i686 i686 i386 GNU / Linux

My processor is 32bit, it does not support! I'm right?

+7
c gcc pthreads thread-sanitizer
source share
1 answer

I have done some research:

ThreadSanitizer is added and can be enabled via -fsanitize = thread. The instructions will be designed to detect racing data. ThreadSanitizer is available on x86-64 GNU / Linux.

-fsanitize = thread is supported only on a 64-bit processor. My output is linux uname -a :

Linux hl.zy 3.9.8-300.fc19.i686 # 1 SMP Thu Jun 27 19:40:39 UTC 2013 i686 i686 i386 GNU / Linux

My processor is 32 bit, it is not supported!

  1. I checked the compiler configuration as Jonathan Leffler said.

the following displays "gcc -dumpspecs | grep tsan":

 %{fsanitize=thread:%{static-libtsan:%{!shared:-Bstatic --whole-archive \ -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}}}} %o 

But I do not understand the way out.

  1. I installed Fedora 19 64 bit, you can install libtsan :

     sudo yum install libtsan.x86_64 

Concusion:

-fsanitize = stream is supported only on 64-bit gcc.

+11
source share

All Articles