title: How to use thread-sanitizer of gcc v4.8.1?
body: <p>gcc v4.8.x add options for debugging your program:</p>
  <blockquote>
  <p>-fsanitize=thread</p>
  <p>Enable ThreadSanitizer, a fast data race detector. Memory access instructions will be instrumented to detect data race bugs. See <a href="http://code.google.com/p/data-race-test/wiki/ThreadSanitizer" rel="noreferrer">http://code.google.com/p/data-race-test/wiki/ThreadSanitizer</a> for more details.</p>
  </blockquote>
  <p>My gcc version on Fedora 19:</p>
  <pre><code>gcc version 4.8.1 20130603 (Red Hat 4.8.1-1) (GCC)
  </code></pre>
  <p>Link my program with below command (output of CMake):</p>
  <pre><code>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.c.o  -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
  </code></pre>
  <p>Gcc says &quot;cannot find -ltsan&quot;. Where is libtsan exist?</p>
  <p>I found something on <a href="http://gcc.gnu.org/gcc-4.8/changes.html" rel="noreferrer">http://gcc.gnu.org/gcc-4.8/changes.html</a>:</p>
  <blockquote>
  <p>ThreadSanitizer has been added and can be enabled via -fsanitize=thread. Instructions will be instrumented to detect data races. The ThreadSanitizer is available on x86-64 GNU/Linux.</p>
  </blockquote>
  <p>-fsanitize=thread is only support on 64bit CPU. My linux <code>uname -a</code> output is:</p>
  <blockquote>
  <p>Linux hl.zy 3.9.8-300.fc19.i686 #1 SMP Thu Jun 27 19:40:39 UTC 2013 i686 i686 i386 GNU/Linux</p>
  </blockquote>
  <p>My cpu is 32bit, It's not support! Am I right?</p>