From: Kostya Serebryany Date: Fri, 13 Nov 2015 01:54:40 +0000 (+0000) Subject: [libFuzzer] make libFuzzer build even with a compiler that does not have sanitizer... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=ad9ec32c1fe3df28839bd09631d3e032f51f1544 [libFuzzer] make libFuzzer build even with a compiler that does not have sanitizer headers git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253003 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Fuzzer/FuzzerDFSan.h b/lib/Fuzzer/FuzzerDFSan.h index 6398575e695..eb206ec61ce 100644 --- a/lib/Fuzzer/FuzzerDFSan.h +++ b/lib/Fuzzer/FuzzerDFSan.h @@ -12,15 +12,17 @@ #ifndef LLVM_FUZZER_DFSAN_H #define LLVM_FUZZER_DFSAN_H -#ifndef LLVM_FUZZER_SUPPORTS_DFSAN -# if defined(__linux__) -# define LLVM_FUZZER_SUPPORTS_DFSAN 1 -# else -# define LLVM_FUZZER_SUPPORTS_DFSAN 0 -# endif // __linux__ -#endif // LLVM_FUZZER_SUPPORTS_DFSAN +#define LLVM_FUZZER_SUPPORTS_DFSAN 0 +#if defined(__has_include) +# if __has_include() +# if defined (__linux__) +# undef LLVM_FUZZER_SUPPORTS_DFSAN +# define LLVM_FUZZER_SUPPORTS_DFSAN 1 +# include +# endif // __linux__ +# endif +#endif // defined(__has_include) -#include #if LLVM_FUZZER_SUPPORTS_DFSAN extern "C" { @@ -42,6 +44,14 @@ static bool ReallyHaveDFSan() { } } // namespace fuzzer #else +// When compiling with a compiler which does not support dfsan, +// this code is still expected to build (but not necessary work). +typedef unsigned short dfsan_label; +struct dfsan_label_info { + dfsan_label l1, l2; + const char *desc; + void *userdata; +}; namespace fuzzer { static bool ReallyHaveDFSan() { return false; } } // namespace fuzzer diff --git a/lib/Fuzzer/FuzzerIO.cpp b/lib/Fuzzer/FuzzerIO.cpp index 4bb2df5d71a..abc444a3d47 100644 --- a/lib/Fuzzer/FuzzerIO.cpp +++ b/lib/Fuzzer/FuzzerIO.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace fuzzer { diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index 455aa625337..48c1b35dccb 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -10,12 +10,17 @@ //===----------------------------------------------------------------------===// #include "FuzzerInternal.h" -#include #include +#if defined(__has_include) +# if __has_include() +# include +# endif +#endif + extern "C" { // Re-declare some of the sanitizer functions as "weak" so that -// libFuzzer can be linked w/o the sanitizers and sanitizer-coveragte +// libFuzzer can be linked w/o the sanitizers and sanitizer-coverage // (in which case it will complain at start-up time). __attribute__((weak)) void __sanitizer_print_stack_trace(); __attribute__((weak)) void __sanitizer_reset_coverage();