Index: compiler-rt/cmake/config-ix.cmake =================================================================== --- compiler-rt/cmake/config-ix.cmake +++ compiler-rt/cmake/config-ix.cmake @@ -648,10 +648,7 @@ endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND FUZZER_SUPPORTED_ARCH AND - OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD|OpenBSD|Fuchsia|Windows" AND - # TODO: Support builds with MSVC. - NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND - NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD|OpenBSD|Fuchsia|Windows") set(COMPILER_RT_HAS_FUZZER TRUE) else() set(COMPILER_RT_HAS_FUZZER FALSE) Index: compiler-rt/lib/fuzzer/CMakeLists.txt =================================================================== --- compiler-rt/lib/fuzzer/CMakeLists.txt +++ compiler-rt/lib/fuzzer/CMakeLists.txt @@ -71,6 +71,10 @@ if(NOT HAS_THREAD_LOCAL) list(APPEND LIBFUZZER_CFLAGS -Dthread_local=__thread) + # Needed to compile with MSVC. + if (OS_NAME MATCHES "Windows") + list(APPEND LIBFUZZER_CFLAGS -D_XKEYCHECK_H=1) + endif() endif() set(FUZZER_SUPPORTED_OS ${SANITIZER_COMMON_SUPPORTED_OS}) Index: compiler-rt/lib/fuzzer/FuzzerSHA1.cpp =================================================================== --- compiler-rt/lib/fuzzer/FuzzerSHA1.cpp +++ compiler-rt/lib/fuzzer/FuzzerSHA1.cpp @@ -32,7 +32,9 @@ #ifdef __BIG_ENDIAN__ # define SHA_BIG_ENDIAN -#elif defined __LITTLE_ENDIAN__ +// Added "|| LIBFUZZER_WINDOWS" for libFuzzer to compile with MSVC since it +// doesn't have and Windows is always little endian. +#elif defined __LITTLE_ENDIAN__ || LIBFUZZER_WINDOWS /* override */ #elif defined __BYTE_ORDER # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ Index: compiler-rt/lib/fuzzer/FuzzerValueBitMap.h =================================================================== --- compiler-rt/lib/fuzzer/FuzzerValueBitMap.h +++ compiler-rt/lib/fuzzer/FuzzerValueBitMap.h @@ -35,7 +35,7 @@ uintptr_t WordIdx = Idx / kBitsInWord; uintptr_t BitIdx = Idx % kBitsInWord; uintptr_t Old = Map[WordIdx]; - uintptr_t New = Old | (1UL << BitIdx); + uintptr_t New = Old | (1ULL << BitIdx); Map[WordIdx] = New; return New != Old; } @@ -49,7 +49,7 @@ assert(Idx < kMapSizeInBits); uintptr_t WordIdx = Idx / kBitsInWord; uintptr_t BitIdx = Idx % kBitsInWord; - return Map[WordIdx] & (1UL << BitIdx); + return Map[WordIdx] & (1ULL << BitIdx); } size_t SizeInBits() const { return kMapSizeInBits; }