Index: lib/Fuzzer/CMakeLists.txt =================================================================== --- lib/Fuzzer/CMakeLists.txt +++ lib/Fuzzer/CMakeLists.txt @@ -11,12 +11,17 @@ add_subdirectory(Support) + if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(FUZZER_EXT_FUNCTIONS FuzzerExtFunctionsWeakAlias.cpp) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(FUZZER_EXT_FUNCTIONS FuzzerExtFunctionsWeak.cpp) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(FUZZER_EXT_FUNCTIONS FuzzerExtFunctionsDlsym.cpp) + endif() + add_library(LLVMFuzzerNoMainObjects OBJECT FuzzerCrossOver.cpp FuzzerDriver.cpp - FuzzerExtFunctionsDlsym.cpp - FuzzerExtFunctionsWeak.cpp - FuzzerExtFunctionsWeakAlias.cpp FuzzerLoop.cpp FuzzerMerge.cpp FuzzerMutate.cpp @@ -24,6 +29,7 @@ FuzzerTracePC.cpp FuzzerTraceState.cpp FuzzerUtil.cpp + ${FUZZER_EXT_FUNCTIONS} ) add_library(LLVMFuzzerNoMain STATIC $ Index: lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp =================================================================== --- lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp +++ lib/Fuzzer/FuzzerExtFunctionsDlsym.cpp @@ -11,8 +11,6 @@ // requires that clients of LibFuzzer pass ``--export-dynamic`` to the linker. // That is a complication we don't wish to expose to clients right now. //===----------------------------------------------------------------------===// -#include "Support/Platform.h" -#if LIBFUZZER_APPLE #include "FuzzerExtFunctions.h" #include "Support/UtilIO.h" @@ -48,5 +46,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_APPLE Index: lib/Fuzzer/FuzzerExtFunctionsWeak.cpp =================================================================== --- lib/Fuzzer/FuzzerExtFunctionsWeak.cpp +++ lib/Fuzzer/FuzzerExtFunctionsWeak.cpp @@ -12,8 +12,6 @@ // weak symbols to be undefined. That is a complication we don't want to expose // to clients right now. //===----------------------------------------------------------------------===// -#include "Support/Platform.h" -#if LIBFUZZER_LINUX #include "FuzzerExtFunctions.h" #include "Support/UtilIO.h" @@ -49,5 +47,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_LINUX Index: lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp =================================================================== --- lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp +++ lib/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // Implementation using weak aliases. Works for Windows. //===----------------------------------------------------------------------===// -#include "Support/Platform.h" -#if LIBFUZZER_WINDOWS #include "FuzzerExtFunctions.h" #include "Support/UtilIO.h" @@ -52,5 +50,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_WINDOWS Index: lib/Fuzzer/Support/CMakeLists.txt =================================================================== --- lib/Fuzzer/Support/CMakeLists.txt +++ lib/Fuzzer/Support/CMakeLists.txt @@ -1,10 +1,27 @@ -add_library(LLVMFuzzerSupport STATIC +set(FUZZER_SUPPORT_SOURCES Util.cpp - UtilDarwin.cpp - UtilLinux.cpp - UtilPosix.cpp - UtilWindows.cpp UtilIO.cpp - UtilIOPosix.cpp - UtilIOWindows.cpp ) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + list(APPEND FUZZER_SUPPORT_SOURCES + UtilWindows.cpp + UtilIOWindows.cpp + ) +else() + list(APPEND FUZZER_SUPPORT_SOURCES + UtilPosix.cpp + UtilIOPosix.cpp + ) + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + list(APPEND FUZZER_SUPPORT_SOURCES + UtilLinux.cpp + ) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + list(APPEND FUZZER_SUPPORT_SOURCES + UtilDarwin.cpp + ) + endif() +endif() + +add_library(LLVMFuzzerSupport STATIC ${FUZZER_SUPPORT_SOURCES}) Index: lib/Fuzzer/Support/UtilDarwin.cpp =================================================================== --- lib/Fuzzer/Support/UtilDarwin.cpp +++ lib/Fuzzer/Support/UtilDarwin.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // Misc utils for Darwin. //===----------------------------------------------------------------------===// -#include "Platform.h" -#if LIBFUZZER_APPLE #include "UtilIO.h" #include @@ -148,5 +146,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_APPLE Index: lib/Fuzzer/Support/UtilIOPosix.cpp =================================================================== --- lib/Fuzzer/Support/UtilIOPosix.cpp +++ lib/Fuzzer/Support/UtilIOPosix.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // IO functions implementation using Posix API. //===----------------------------------------------------------------------===// -#include "Platform.h" -#if LIBFUZZER_POSIX #include "UtilIO.h" #include @@ -84,5 +82,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_POSIX Index: lib/Fuzzer/Support/UtilIOWindows.cpp =================================================================== --- lib/Fuzzer/Support/UtilIOWindows.cpp +++ lib/Fuzzer/Support/UtilIOWindows.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // IO functions implementation for Windows. //===----------------------------------------------------------------------===// -#include "Platform.h" -#if LIBFUZZER_WINDOWS #include "UtilIO.h" #include @@ -278,5 +276,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_WINDOWS Index: lib/Fuzzer/Support/UtilLinux.cpp =================================================================== --- lib/Fuzzer/Support/UtilLinux.cpp +++ lib/Fuzzer/Support/UtilLinux.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // Misc utils for Linux. //===----------------------------------------------------------------------===// -#include "Platform.h" -#if LIBFUZZER_LINUX #include #include @@ -21,5 +19,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_LINUX Index: lib/Fuzzer/Support/UtilPosix.cpp =================================================================== --- lib/Fuzzer/Support/UtilPosix.cpp +++ lib/Fuzzer/Support/UtilPosix.cpp @@ -9,7 +9,6 @@ // Misc utils implementation using Posix API. //===----------------------------------------------------------------------===// #include "Platform.h" -#if LIBFUZZER_POSIX #include "Util.h" #include "UtilIO.h" #include @@ -105,5 +104,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_POSIX Index: lib/Fuzzer/Support/UtilWindows.cpp =================================================================== --- lib/Fuzzer/Support/UtilWindows.cpp +++ lib/Fuzzer/Support/UtilWindows.cpp @@ -8,8 +8,7 @@ //===----------------------------------------------------------------------===// // Misc utils implementation for Windows. //===----------------------------------------------------------------------===// -#include "Platform.h" -#if LIBFUZZER_WINDOWS + #include "Util.h" #include "UtilIO.h" #include @@ -185,5 +184,3 @@ } } // namespace fuzzer - -#endif // LIBFUZZER_WINDOWS