From 309182a7d3bb7fd5a46e312118d46239d19c8b6b Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Fri, 21 Apr 2017 17:39:50 +0000 Subject: [PATCH] [libFuzzer] Changing thread_local to __thread in libFuzzer Old Apple compilers do not support thread_local keyword. This patch adds -Dthread_local=__thread when the compiler doesn't support thread_local. Differential Revision: https://reviews.llvm.org/D32312 llvm-svn: 301007 --- llvm/lib/Fuzzer/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/llvm/lib/Fuzzer/CMakeLists.txt b/llvm/lib/Fuzzer/CMakeLists.txt index 59cef04cdece1..d44c12de3e169 100644 --- a/llvm/lib/Fuzzer/CMakeLists.txt +++ b/llvm/lib/Fuzzer/CMakeLists.txt @@ -1,3 +1,16 @@ +include(CheckCXXSourceCompiles) + +CHECK_CXX_SOURCE_COMPILES(" + static thread_local 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() + set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}") # Disable the coverage and sanitizer instrumentation for the fuzzer itself. set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters -Werror")