[compiler-rt] 0656936 - [CMake][NFC] Refactor iOS simulator/device test configuration generation code for TSan.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 12:44:40 PST 2020


Author: Dan Liew
Date: 2020-01-23T12:44:00-08:00
New Revision: 06569361d0185c130299d87e4d32637fd5ada34b

URL: https://github.com/llvm/llvm-project/commit/06569361d0185c130299d87e4d32637fd5ada34b
DIFF: https://github.com/llvm/llvm-project/commit/06569361d0185c130299d87e4d32637fd5ada34b.diff

LOG: [CMake][NFC] Refactor iOS simulator/device test configuration generation code for TSan.

Summary:
The previous code hard-coded platform names but compiler-rt's CMake
build system actually already knows which Apple platforms TSan supports.

This change uses this information to enumerate the different Apple
platforms.

This change relies on the `get_capitalized_apple_platform()` function
added in a previous commit.

rdar://problem/58798733

Reviewers: kubamracek, yln

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D73238

Added: 
    

Modified: 
    compiler-rt/test/tsan/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/tsan/CMakeLists.txt b/compiler-rt/test/tsan/CMakeLists.txt
index 9159e75129b0..87457ea4494d 100644
--- a/compiler-rt/test/tsan/CMakeLists.txt
+++ b/compiler-rt/test/tsan/CMakeLists.txt
@@ -49,53 +49,40 @@ endforeach()
 # variable to select which iOS device or simulator to use, e.g.:
 # SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
 if(APPLE)
-  # FIXME(dliew): This logic should be refactored to the way UBSan Darwin
-  # testing is done.
   set(EXCLUDE_FROM_ALL ON)
   set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
-
-  list_intersect(TSAN_TEST_IOSSIM_ARCHS TSAN_SUPPORTED_ARCH DARWIN_iossim_ARCHS)
-  foreach(arch ${TSAN_TEST_IOSSIM_ARCHS})
-    set(TSAN_TEST_APPLE_PLATFORM "iossim")
-    set(TSAN_TEST_TARGET_ARCH ${arch})
-    get_test_cflags_for_apple_platform(
-      "${TSAN_TEST_APPLE_PLATFORM}"
-      "${TSAN_TEST_TARGET_ARCH}"
-      TSAN_TEST_TARGET_CFLAGS
-      )
-    set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
-    string(TOUPPER ${arch} ARCH_UPPER_CASE)
-    set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
-    configure_lit_site_cfg(
-      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
-      )
-    add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
-      DEPENDS ${TSAN_TEST_DEPS})
-  endforeach()
-
-  list_intersect(TSAN_TEST_IOS_ARCHS TSAN_SUPPORTED_ARCH DARWIN_ios_ARCHS)
-  foreach(arch ${TSAN_TEST_IOS_ARCHS})
-    set(TSAN_TEST_APPLE_PLATFORM "ios")
-    set(TSAN_TEST_TARGET_ARCH ${arch})
-    get_test_cflags_for_apple_platform(
-      "${TSAN_TEST_APPLE_PLATFORM}"
-      "${TSAN_TEST_TARGET_ARCH}"
-      TSAN_TEST_TARGET_CFLAGS
-      )
-    set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
-    string(TOUPPER ${arch} ARCH_UPPER_CASE)
-    set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
-    configure_lit_site_cfg(
-      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
-      )
-    add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS ${arch} tests"
-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
-      DEPENDS ${TSAN_TEST_DEPS})
+  set(TSAN_APPLE_PLATFORMS ${TSAN_SUPPORTED_OS})
+  foreach(platform ${TSAN_APPLE_PLATFORMS})
+    if ("${platform}" STREQUAL "osx")
+      # Skip macOS because it's handled by the code above that builds tests for the host machine.
+      continue()
+    endif()
+    list_intersect(
+      TSAN_TEST_${platform}_ARCHS
+      TSAN_SUPPORTED_ARCH
+      DARWIN_${platform}_ARCHS
+    )
+    foreach(arch ${TSAN_TEST_${platform}_ARCHS})
+      get_test_cflags_for_apple_platform(
+        "${platform}"
+        "${arch}"
+        TSAN_TEST_TARGET_CFLAGS
+        )
+      string(TOUPPER "${arch}" ARCH_UPPER_CASE)
+      get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED)
+      set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
+      set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
+      set(TSAN_TEST_APPLE_PLATFORM "${platform}")
+      set(TSAN_TEST_TARGET_ARCH "${arch}")
+      configure_lit_site_cfg(
+        ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+        ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
+        )
+      add_lit_testsuite(check-tsan-${platform}-${arch} "ThreadSanitizer ${platform} ${arch} tests"
+        ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
+        DEPENDS ${TSAN_TEST_DEPS})
+    endforeach()
   endforeach()
-
   set(EXCLUDE_FROM_ALL OFF)
 endif()
 


        


More information about the llvm-commits mailing list