From 7728ff0f872d01b12be31ee8552ecdeca6442cbb Mon Sep 17 00:00:00 2001 From: Marcos Pividori Date: Sun, 22 Jan 2017 02:28:12 +0000 Subject: [PATCH] [libFuzzer] Specify the CRT considered (MT or MD) for tests on Windows. Differential Revision: https://reviews.llvm.org/D28439 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292749 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Fuzzer/test/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Fuzzer/test/CMakeLists.txt b/lib/Fuzzer/test/CMakeLists.txt index f2dfcf21482..5f5ba57dcdf 100644 --- a/lib/Fuzzer/test/CMakeLists.txt +++ b/lib/Fuzzer/test/CMakeLists.txt @@ -18,6 +18,13 @@ endforeach() set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp,trace-div,trace-gep -gline-tables-only") if(MSVC) + # For tests use the CRT specified for release build + # (asan doesn't support MDd and MTd) + if ("${LLVM_USE_CRT_RELEASE}" STREQUAL "") + set(CRT_FLAG " /MD ") + else() + set(CRT_FLAG " /${LLVM_USE_CRT_RELEASE} ") + endif() # In order to use the sanitizers in Windows, we need to link against many # runtime libraries which will depend on the target being created # (executable or dll) and the c runtime library used (MT/MD). @@ -28,8 +35,8 @@ if(MSVC) # the rules for linking executables and shared libraries, using the compiler # instead of link.exe. Clang will consider the sanitizer flags, and # automatically provide the required libraries to the linker. - set(CMAKE_CXX_LINK_EXECUTABLE " ${CMAKE_CXX_FLAGS} -o /link ") - set(CMAKE_CXX_CREATE_SHARED_LIBRARY " ${CMAKE_CXX_FLAGS} /LD -o /link ") + set(CMAKE_CXX_LINK_EXECUTABLE " ${CMAKE_CXX_FLAGS} ${CRT_FLAG} -o /link ") + set(CMAKE_CXX_CREATE_SHARED_LIBRARY " ${CMAKE_CXX_FLAGS} ${CRT_FLAG} /LD -o /link ") endif() # add_libfuzzer_test( -- 2.40.0