[compiler-rt] r208682 - [ASan tests] Add Windows-specific flags to lib/asan/tests/CMakeLists.txt

Timur Iskhodzhanov timurrrr at google.com
Tue May 13 03:33:43 PDT 2014


Author: timurrrr
Date: Tue May 13 05:33:42 2014
New Revision: 208682

URL: http://llvm.org/viewvc/llvm-project?rev=208682&view=rev
Log:
[ASan tests] Add Windows-specific flags to lib/asan/tests/CMakeLists.txt

Reviewed at http://reviews.llvm.org/D3720

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/asan/tests/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=208682&r1=208681&r2=208682&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue May 13 05:33:42 2014
@@ -45,5 +45,6 @@ check_cxx_compiler_flag(/wd4722 COMPILER
 check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL)
 
 # Libraries.
+check_library_exists(m pow "" COMPILER_RT_HAS_LIBM)
 check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL)
 check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)

Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=208682&r1=208681&r2=208682&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Tue May 13 05:33:42 2014
@@ -28,10 +28,27 @@ set(ASAN_UNITTEST_COMMON_CFLAGS
   -I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/tests
   -Wno-format
   -Werror=sign-compare
-  -g
   -O2)
+append_if(COMPILER_RT_HAS_G_FLAG -g ASAN_UNITTEST_COMMON_CFLAGS)
+append_if(COMPILER_RT_HAS_Zi_FLAG -Zi ASAN_UNITTEST_COMMON_CFLAGS)
 append_if(COMPILER_RT_HAS_WNO_VARIADIC_MACROS_FLAG -Wno-variadic-macros ASAN_UNITTEST_COMMON_CFLAGS)
 
+if(MSVC)
+  # MSVC system headers and gtest use a lot of deprecated stuff.
+  list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+       -Wno-deprecated-declarations)
+
+  # clang-cl doesn't support exceptions yet.
+  list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+       /fallback
+       -D_HAS_EXCEPTIONS=0)
+
+  # We should teach clang-cl to understand more pragmas.
+  list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+       -Wno-unknown-pragmas
+       -Wno-undefined-inline)
+endif()
+
 # Use -D instead of definitions to please custom compile command.
 list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
   -DASAN_HAS_BLACKLIST=1
@@ -43,12 +60,13 @@ set(ASAN_UNITTEST_INSTRUMENTED_CFLAGS
   ${ASAN_UNITTEST_COMMON_CFLAGS}
   -fsanitize=address
   "-fsanitize-blacklist=${ASAN_BLACKLIST_FILE}"
-  -mllvm -asan-stack=1
-  -mllvm -asan-globals=1
 )
 
-# Unit tests require libstdc++.
-set(ASAN_UNITTEST_COMMON_LINKFLAGS --driver-mode=g++ -lstdc++)
+# Unit tests require libstdc++ on POSIX.
+if(NOT MSVC)
+  list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS --driver-mode=g++ -lstdc++)
+endif()
+
 # x86_64 FreeBSD 9.2 additionally requires libc++ to build the tests.
 if(CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE")
   list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS "-lc++")
@@ -74,8 +92,8 @@ set(ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_L
   ${ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS}
   -shared-libasan)
 
-set(ASAN_UNITTEST_NOINST_LINKFLAGS
-  ${ASAN_UNITTEST_COMMON_LINKFLAGS} -lm)
+set(ASAN_UNITTEST_NOINST_LINKFLAGS ${ASAN_UNITTEST_COMMON_LINKFLAGS})
+append_if(COMPILER_RT_HAS_LIBM -lm ASAN_UNITTEST_NOINST_LINKFLAGS)
 append_if(COMPILER_RT_HAS_LIBDL -ldl ASAN_UNITTEST_NOINST_LINKFLAGS)
 append_if(COMPILER_RT_HAS_LIBPTHREAD -lpthread ASAN_UNITTEST_NOINST_LINKFLAGS)
 append_if(COMPILER_RT_HAS_LIBPTHREAD -lpthread
@@ -108,7 +126,11 @@ macro(add_asan_test test_suite test_name
   endif()
   if(TEST_WITH_TEST_RUNTIME)
     list(APPEND TEST_DEPS ${ASAN_TEST_RUNTIME})
-    list(APPEND TEST_OBJECTS lib${ASAN_TEST_RUNTIME}.a)
+    if(NOT MSVC)
+      list(APPEND TEST_OBJECTS lib${ASAN_TEST_RUNTIME}.a)
+    else()
+      list(APPEND TEST_OBJECTS ${ASAN_TEST_RUNTIME}.lib)
+    endif()
   endif()
   add_compiler_rt_test(${test_suite} ${test_name}
                        OBJECTS ${TEST_OBJECTS}
@@ -183,9 +205,12 @@ macro(add_asan_tests_for_arch_and_kind a
       $<TARGET_OBJECTS:RTAsan.${arch}>
       $<TARGET_OBJECTS:RTAsan_cxx.${arch}>
       $<TARGET_OBJECTS:RTInterception.${arch}>
-      $<TARGET_OBJECTS:RTLSanCommon.${arch}>
       $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
       $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>)
+    if(NOT MSVC)
+      list(APPEND ASAN_TEST_RUNTIME_OBJECTS
+           $<TARGET_OBJECTS:RTLSanCommon.${arch}>)
+    endif()
   endif()
   add_library(${ASAN_TEST_RUNTIME} STATIC ${ASAN_TEST_RUNTIME_OBJECTS})
   set_target_properties(${ASAN_TEST_RUNTIME} PROPERTIES





More information about the llvm-commits mailing list