[llvm] r253003 - [libFuzzer] make libFuzzer build even with a compiler that does not have sanitizer headers
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 17:54:40 PST 2015
Author: kcc
Date: Thu Nov 12 19:54:40 2015
New Revision: 253003
URL: http://llvm.org/viewvc/llvm-project?rev=253003&view=rev
Log:
[libFuzzer] make libFuzzer build even with a compiler that does not have sanitizer headers
Modified:
llvm/trunk/lib/Fuzzer/FuzzerDFSan.h
llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerDFSan.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDFSan.h?rev=253003&r1=253002&r2=253003&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDFSan.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDFSan.h Thu Nov 12 19:54:40 2015
@@ -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(<sanitizer/dfsan_interface.h>)
+# if defined (__linux__)
+# undef LLVM_FUZZER_SUPPORTS_DFSAN
+# define LLVM_FUZZER_SUPPORTS_DFSAN 1
+# include <sanitizer/dfsan_interface.h>
+# endif // __linux__
+# endif
+#endif // defined(__has_include)
-#include <sanitizer/dfsan_interface.h>
#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
Modified: llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerIO.cpp?rev=253003&r1=253002&r2=253003&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerIO.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerIO.cpp Thu Nov 12 19:54:40 2015
@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <cstdarg>
#include <cstdio>
namespace fuzzer {
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=253003&r1=253002&r2=253003&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Thu Nov 12 19:54:40 2015
@@ -10,12 +10,17 @@
//===----------------------------------------------------------------------===//
#include "FuzzerInternal.h"
-#include <sanitizer/coverage_interface.h>
#include <algorithm>
+#if defined(__has_include)
+# if __has_include(<sanitizer/coverage_interface.h>)
+# include <sanitizer/coverage_interface.h>
+# 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();
More information about the llvm-commits
mailing list