<div dir="ltr">OK. So if I am not wrong, I need to do a cmake on the llvm build directory, with the mentioned flags and then do make - which will basically build the whole llvm repo. <div><br><div><br><br>On Tuesday, July 11, 2017 at 4:00:26 PM UTC+2, Dmitry Vyukov wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Tue, Jul 11, 2017 at 3:26 PM, Nischai Vinesh
<br><<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DFa7DDOGBAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">nischai...@gmail.com</a>> wrote:
<br>> Hi Dmitry,
<br>>
<br>> I managed to get the program instrumented with tsan using 'opt -tsan ..',
<br>> but still it is not printing tsan warnings when I run the binary. When I
<br>> instrument the same program with tsan during compilation using 'clang
<br>> -fsanitize=thread ...', without instrumenting my IR pass, it does give out
<br>> tsan warnings!
<br>>
<br>>
<br>> On Monday, July 10, 2017 at 7:21:28 AM UTC+2, Dmitry Vyukov wrote:
<br>>>
<br>>> On Sun, Jul 9, 2017 at 3:50 PM, Nischai Vinesh <<a>nischai...@gmail.com</a>>
<br>>> wrote:
<br>>> > Hello,
<br>>> >
<br>>> > I tried that as well but there are no tsan warnings thrown at run time,
<br>>> > even
<br>>> > though there are data race error!
<br>>> >
<br>>> > The steps I followed:
<br>>> > 1. Generate bitcode using 'clang -emit-llvm' command
<br>>> > 2. Using the 'opt -load ..' command, I instrumented the bitcode file
<br>>> > with my
<br>>> > custom pass
<br>>> > 3. Using the command 'opt -tsan ..', instrumented the output bitcode
<br>>> > file
<br>>> > from step 2
<br>>> > 4. Using the llvm backend compiler, 'llc', compiled the program to
<br>>> > native
<br>>> > assembly
<br>>> > 5. The output from step 4 is compiled again with 'clang
<br>>> > -fsanitize=thread'
<br>>> > (linking tsan here) for the final object file.
<br>>> >
<br>>> > Executing this final output file works fine, except that it doesn't
<br>>> > throws
<br>>> > any TSAN warnings!
<br>>>
<br>>>
<br>>> Hi Nischai,
<br>>>
<br>>> I see 3 possibilities:
<br>>> 1. Either the code is somehow ends up being non-instrumented, or
<br>>> 2. tsan does not consider what it sees a data race, or
<br>>> 3. the data race is masked by unrelated synchronization.
<br>>>
<br>>> For 1 you can check that the resulting code in fact contains __tsan_*
<br>>> callbacks.
<br>>> For 2 and 3 you can rebuilt tsan runtime with TSAN_DEBUG_OUTPUT=2
<br>>> define, then it will print everything it sees (memory accesses and
<br>>> synchronization). This output will allow us to figure out why it does
<br>>> not report a race.
<br>>
<br>>
<br>> So I guess we can rule out the 1st possibility. Can you kindly tell me how
<br>> to rebuild tsan runtime? Sorry, I am new to LLVM and stuff.
<br>
<br>Here is the script we use on build bots:
<br><a href="https://github.com/llvm-mirror/zorg/blob/master/zorg/buildbot/builders/sanitizers/buildbot_standard.sh" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fllvm-mirror%2Fzorg%2Fblob%2Fmaster%2Fzorg%2Fbuildbot%2Fbuilders%2Fsanitizers%2Fbuildbot_standard.sh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEkzZDQC0G_mUACufLpVE_qN_RZQQ';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fllvm-mirror%2Fzorg%2Fblob%2Fmaster%2Fzorg%2Fbuildbot%2Fbuilders%2Fsanitizers%2Fbuildbot_standard.sh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEkzZDQC0G_mUACufLpVE_qN_RZQQ';return true;">https://github.com/llvm-<wbr>mirror/zorg/blob/master/zorg/<wbr>buildbot/builders/sanitizers/<wbr>buildbot_standard.sh</a>
<br>
<br>You need this option with -DCOMPILER_RT_DEBUG=ON
<br>-DCOMPILER_RT_TSAN_DEBUG_<wbr>OUTPUT=ON:
<br>
<br>echo @@@BUILD_STEP build tsan with stats and debug output@@@
<br>build_tsan "${TSAN_FULL_DEBUG_BUILD_DIR}" "-DCOMPILER_RT_DEBUG=ON
<br>-DCOMPILER_RT_TSAN_DEBUG_<wbr>OUTPUT=ON -DLLVM_INCLUDE_TESTS=OFF" gcc g++
<br></blockquote></div></div></div>