Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use clang thread sanitizer on OSX?

I am trying to use --thread-sanitizer option of clang on OSX:

$ clang++ -fthread-sanitizer -fpic tsan1.cc
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
[...]
clang -cc1 version 4.2 based upon LLVM 3.2svn default target x86_64-apple-darwin12.3.0
[...]
Undefined symbols for architecture x86_64:
  "___tsan_func_entry", referenced from:
      threadfunc(void*) in tsan1-6f7gbr.o
[...]
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like a linkage error. Should I link with some additional libs?

like image 200
grep Avatar asked Oct 22 '22 12:10

grep


2 Answers

ThreadSanitizer is unsupported on Darwin for C++ yet. This is unlikely to change in at least half a year.

like image 139
Glider Avatar answered Nov 01 '22 16:11

Glider


It's been fixed. According to https://clang.llvm.org/docs/ThreadSanitizer.html

ThreadSanitizer is supported on the following OS: ... Darwin arm64, x86_64, ...

Also I just used it without any problems.

like image 38
TmsKtel Avatar answered Nov 01 '22 16:11

TmsKtel