1

I'd like to test data races in C++ on windows 10(64 bit), but it seems that Visual C++ doesn't support it yet. So, I installed Cygwin and got g++ 11.2.0, tried compiling my C++ code with -fsanitize=thread -fPIE -pie -g, but it failed with -ltsan not found error.

The doc doesn't say anything about Windows. Is it even possible to use Thread Sanitizer on Windows? If so, How?

torano
  • 97
  • 7

2 Answers2

0

The sanitizers you linked are implemented in Clang, not MSVC or gcc. You can use clang with Visual Studio. To do so you need to install the appropiate toolchain. You can run clang directly on Windows, via cygwin or via WSL.

In addition could you post your complete compile command (e.g. via godbolt.org)?

e.g.: https://godbolt.org/z/fax6o9E1f

Bernd
  • 2,113
  • 8
  • 22
  • I installed clang 13.0.0 win64 from the official repo, and run `clang DataRaceTest.cpp -fsanitize=thread -fPIE -pie -g` but still got `clang: error: unsupported option -fPIE for target x86_64-pc-windows-msvc` and `clang: error: unsupported option -fsanitize=thread for target x86_64-pc-windows-msvc` clang on windows doesn't support it. I don't know how to use that website but it looks good to test out small codes. – torano Jan 29 '22 at 08:09
0

Just use WSL and use thread sanitizer on it.

torano
  • 97
  • 7