[compiler-rt] r202472 - [CMake] Fix PR18987: discard /MD flag if we're adding /MT

Alexey Samsonov samsonov at google.com
Fri Feb 28 00:04:30 PST 2014


Author: samsonov
Date: Fri Feb 28 02:04:30 2014
New Revision: 202472

URL: http://llvm.org/viewvc/llvm-project?rev=202472&view=rev
Log:
[CMake] Fix PR18987: discard /MD flag if we're adding /MT

Modified:
    compiler-rt/trunk/CMakeLists.txt

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=202472&r1=202471&r2=202472&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Feb 28 02:04:30 2014
@@ -255,9 +255,15 @@ append_if(SANITIZER_COMMON_CFLAGS COMPIL
 append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden)
 append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections)
 
-append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_MT_FLAG /MT)
-append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_Oy_FLAG /Oy-)
-append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_GS_FLAG /GS-)
+if(MSVC)
+  # Remove /MD flag so that it doesn't conflict with /MT.
+  if(COMPILER_RT_HAS_MT_FLAG)
+    string(REGEX REPLACE "(^| ) */MD *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+    list(APPEND SANITIZER_COMMON_CFLAGS /MT)
+  endif()
+  append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_Oy_FLAG /Oy-)
+  append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_GS_FLAG /GS-)
+endif()
 
 # Build with optimization, unless we're in debug mode.
 if(NOT COMPILER_RT_DEBUG)





More information about the llvm-commits mailing list