Index: lib/Fuzzer/CMakeLists.txt =================================================================== --- lib/Fuzzer/CMakeLists.txt +++ lib/Fuzzer/CMakeLists.txt @@ -1,3 +1,16 @@ +include(CheckCXXSourceCompiles) + +CHECK_CXX_SOURCE_COMPILES(" + static thread_local234 int blah; + int main() { + return 0; + } + " HAS_THREAD_LOCAL) + +if ( NOT HAS_THREAD_LOCAL ) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dthread_local=__thread" ) +endif() + if( LLVM_USE_SANITIZE_COVERAGE ) set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}")