The problem is that the sanitizer interface was added in a later version than the sanitizer flags themselves. Reproducer:
#if !defined(BOOST_ASIO_HAS_THREAD_SANITIZER)
#if defined(__SANITIZE_THREAD__)
#define BOOST_ASIO_HAS_THREAD_SANITIZER 1
#elif defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define BOOST_ASIO_HAS_THREAD_SANITIZER 1
#endif // __has_feature(thread_sanitizer)
#endif // defined(__SANITIZE_THREAD__)
#endif // !defined(BOOST_ASIO_HAS_THREAD_SANITIZER)
#include <iostream>
#if defined(BOOST_ASIO_HAS_THREAD_SANITIZER)
#include <sanitizer/tsan_interface.h>
#endif // defined(BOOST_ASIO_HAS_THREAD_SANITIZER)
int main() {
#ifdef BOOST_ASIO_HAS_THREAD_SANITIZER
std::cout << "Has tsan: true\n";
#else
std::cout << "Has tsan: false\n";
#endif
}
Build under clang 4.0 (Docker container ubuntu:16.04) and gcc 7 (Docker container ubuntu:18.04). The problem is that BOOST_ASIO_HAS_THREAD_SANITIZER is true, but the header sanitizer/tsan_interface.h does not exist.
Note that gcc 6 and lower has -fsanitize=thread but is not detected by any of the checks above. Builds using it report (hopefully) false positives.
The problem is that the sanitizer interface was added in a later version than the sanitizer flags themselves. Reproducer:
Build under clang 4.0 (Docker container ubuntu:16.04) and gcc 7 (Docker container ubuntu:18.04). The problem is that
BOOST_ASIO_HAS_THREAD_SANITIZERis true, but the headersanitizer/tsan_interface.hdoes not exist.Note that gcc 6 and lower has
-fsanitize=threadbut is not detected by any of the checks above. Builds using it report (hopefully) false positives.