Skip to content

Commit 1b42b81

Browse files
committed
[Sanitizers Win] Move duplicate Windows-specific compiler flags to a common CMake variable
Reviewed at http://reviews.llvm.org/D3952 llvm-svn: 209889
1 parent 9e35488 commit 1b42b81

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ macro(add_compiler_rt_darwin_dynamic_runtime name os)
113113
LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
114114
endmacro()
115115

116+
set(COMPILER_RT_TEST_CFLAGS)
117+
116118
# Unittests support.
117119
set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
118120
set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
@@ -124,8 +126,18 @@ set(COMPILER_RT_GTEST_CFLAGS
124126
)
125127

126128
if(MSVC)
129+
# clang doesn't support exceptions on Windows yet.
130+
list(APPEND COMPILER_RT_TEST_CFLAGS
131+
-D_HAS_EXCEPTIONS=0)
132+
133+
# We should teach clang to understand "#pragma intrinsic", see PR19898.
134+
list(APPEND COMPILER_RT_TEST_CFLAGS -Wno-undefined-inline)
135+
127136
# Clang doesn't support SEH on Windows yet.
128137
list(APPEND COMPILER_RT_GTEST_CFLAGS -DGTEST_HAS_SEH=0)
138+
139+
# gtest use a lot of stuff marked as deprecated on Windows.
140+
list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations)
129141
endif()
130142

131143
# Link objects into a single executable with COMPILER_RT_TEST_COMPILER,

compiler-rt/lib/asan/tests/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set(ASAN_UNITTEST_HEADERS
2121
asan_test_utils.h)
2222

2323
set(ASAN_UNITTEST_COMMON_CFLAGS
24+
${COMPILER_RT_TEST_CFLAGS}
2425
${COMPILER_RT_GTEST_CFLAGS}
2526
-I${COMPILER_RT_SOURCE_DIR}/include
2627
-I${COMPILER_RT_SOURCE_DIR}/lib
@@ -39,21 +40,6 @@ else()
3940
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -g)
4041
endif()
4142

42-
if(MSVC)
43-
# MSVC system headers and gtest use a lot of deprecated stuff.
44-
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
45-
-Wno-deprecated-declarations)
46-
47-
# clang doesn't support exceptions on Windows yet.
48-
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
49-
-D_HAS_EXCEPTIONS=0)
50-
51-
# We should teach clang to understand more pragmas.
52-
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
53-
-Wno-unknown-pragmas
54-
-Wno-undefined-inline)
55-
endif()
56-
5743
# Use -D instead of definitions to please custom compile command.
5844
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
5945
-DASAN_HAS_BLACKLIST=1

compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ foreach(header ${SANITIZER_HEADERS})
3434
endforeach()
3535

3636
set(SANITIZER_TEST_CFLAGS_COMMON
37+
${COMPILER_RT_TEST_CFLAGS}
3738
${COMPILER_RT_GTEST_CFLAGS}
3839
-I${COMPILER_RT_SOURCE_DIR}/include
3940
-I${COMPILER_RT_SOURCE_DIR}/lib
@@ -50,21 +51,6 @@ else()
5051
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -g)
5152
endif()
5253

53-
if(MSVC)
54-
# MSVC system headers and gtest use a lot of deprecated stuff.
55-
list(APPEND SANITIZER_TEST_CFLAGS_COMMON
56-
-Wno-deprecated-declarations)
57-
58-
# clang doesn't support exceptions on Windows yet.
59-
list(APPEND SANITIZER_TEST_CFLAGS_COMMON
60-
-D_HAS_EXCEPTIONS=0)
61-
62-
# We should teach clang to understand more pragmas.
63-
list(APPEND SANITIZER_TEST_CFLAGS_COMMON
64-
-Wno-unknown-pragmas
65-
-Wno-undefined-inline)
66-
endif()
67-
6854
if(NOT MSVC)
6955
list(APPEND SANITIZER_TEST_LINK_FLAGS_COMMON --driver-mode=g++)
7056
endif()

0 commit comments

Comments
 (0)