Why is thread sanitizer option not building?

Viewed 352

I have the following CMake file on osx using IntelliJ/CLion:

cmake_minimum_required(VERSION 3.9)
project(GrepUtil)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -fsanitize=thread -Wall")

set(SOURCE_FILES main.cpp)
add_executable(GrepUtil ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} stdc++fs)

While building it, I am getting the following errors:

[ 50%] Building CXX object CMakeFiles/GrepUtil.dir/main.cpp.o
[100%] Linking CXX executable GrepUtil
Undefined symbols for architecture x86_64:
  "___tsan_atomic32_fetch_add", referenced from:
      __gnu_cxx::__exchange_and_add(int volatile*, int) in main.cpp.o
  "___tsan_atomic8_load", referenced from:

      ...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [GrepUtil] Error 1
make[2]: *** [CMakeFiles/GrepUtil.dir/all] Error 2
make[1]: *** [CMakeFiles/GrepUtil.dir/rule] Error 2

I am using g++-7 (7.1.0) compiler. Program builds fine without the sanitize option. Is tsan supported with/on Sierra?

0 Answers
Related