summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/base-config-ix.cmake8
-rw-r--r--cmake/config-ix.cmake2
-rw-r--r--lib/sanitizer_common/sanitizer_internal_defs.h2
4 files changed, 16 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66a3e4384..102655dea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,7 +135,14 @@ pythonize_bool(COMPILER_RT_DEBUG)
include(config-ix)
if(MSVC)
- append_string_if(COMPILER_RT_HAS_W3_FLAG /W3 CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ # Override any existing /W flags with /W4. This is what LLVM does. Failing to
+ # remove other /W[0-4] flags will result in a warning about overriding a
+ # previous flag.
+ if (COMPILER_RT_HAS_W4_FLAG)
+ string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ append_string_if(COMPILER_RT_HAS_W4_FLAG /W4 CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ endif()
else()
append_string_if(COMPILER_RT_HAS_WALL_FLAG -Wall CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
index 5d71fa9c1..d252ef8d9 100644
--- a/cmake/base-config-ix.cmake
+++ b/cmake/base-config-ix.cmake
@@ -106,6 +106,10 @@ macro(test_targets)
# Add this flag into the host build if this is clang-cl.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
append("${MSVC_VERSION_FLAG}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang")
+ # Add this flag to test compiles to suppress clang's auto-detection
+ # logic.
+ append("${MSVC_VERSION_FLAG}" COMPILER_RT_TEST_COMPILER_CFLAGS)
endif()
endif()
endif()
@@ -126,9 +130,9 @@ macro(test_targets)
test_target_arch(i386 __i386__ "-m32")
else()
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
- test_target_arch(i386 "" "${MSVC_VERSION_FLAG}")
+ test_target_arch(i386 "" "")
else()
- test_target_arch(x86_64 "" "${MSVC_VERSION_FLAG}")
+ test_target_arch(x86_64 "" "")
endif()
endif()
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index ca0c8eee4..bcedcfc6a 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -56,7 +56,7 @@ check_cxx_compiler_flag("-Werror -Wgnu" COMPILER_RT_HAS_WGNU_FLAG
check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG)
check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag(/W3 COMPILER_RT_HAS_W3_FLAG)
+check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG)
check_cxx_compiler_flag(/WX COMPILER_RT_HAS_WX_FLAG)
check_cxx_compiler_flag(/wd4146 COMPILER_RT_HAS_WD4146_FLAG)
check_cxx_compiler_flag(/wd4291 COMPILER_RT_HAS_WD4291_FLAG)
diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h
index 339da7fde..720672d29 100644
--- a/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -138,7 +138,7 @@ typedef u32 operator_new_size_type;
# define THREADLOCAL __declspec(thread)
# define LIKELY(x) (x)
# define UNLIKELY(x) (x)
-# define PREFETCH(x) /* _mm_prefetch(x, _MM_HINT_NTA) */
+# define PREFETCH(x) /* _mm_prefetch(x, _MM_HINT_NTA) */ (void)0
#else // _MSC_VER
# define ALWAYS_INLINE inline __attribute__((always_inline))
# define ALIAS(x) __attribute__((alias(x)))