Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -42,6 +42,8 @@ set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib") elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined") set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib") + elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread") + set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib") else() message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X") endif() Index: test/libcxx/test/target_info.py =================================================================== --- test/libcxx/test/target_info.py +++ test/libcxx/test/target_info.py @@ -115,7 +115,7 @@ return False def add_sanitizer_features(self, sanitizer_type, features): - if san == 'Undefined': + if sanitizer_type == 'Undefined': features.add('sanitizer-new-delete') Index: test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp +++ test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// + +// struct once_flag; + +// template +// void call_once(once_flag& flag, Callable&& func, Args&&... args); + +// This test is supposed to be run with ThreadSanitizer and verifies that +// call_once propertly synchronizes user state, a data race that was fixed +// in https://reviews.llvm.org/D24028. + +#include +#include +#include + +std::once_flag flg0; +long global = 0; + +void init0() +{ + ++global; +} + +void f0() +{ + std::call_once(flg0, init0); + assert(global == 1); +} + +int main() +{ + std::thread t0(f0); + std::thread t1(f0); + t0.join(); + t1.join(); + assert(global == 1); +}