Skip to content

Commit 0656936

Browse files
committed
[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
1 parent 1262745 commit 0656936

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

compiler-rt/test/tsan/CMakeLists.txt

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,53 +49,40 @@ endforeach()
4949
# variable to select which iOS device or simulator to use, e.g.:
5050
# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
5151
if(APPLE)
52-
# FIXME(dliew): This logic should be refactored to the way UBSan Darwin
53-
# testing is done.
5452
set(EXCLUDE_FROM_ALL ON)
5553
set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
56-
57-
list_intersect(TSAN_TEST_IOSSIM_ARCHS TSAN_SUPPORTED_ARCH DARWIN_iossim_ARCHS)
58-
foreach(arch ${TSAN_TEST_IOSSIM_ARCHS})
59-
set(TSAN_TEST_APPLE_PLATFORM "iossim")
60-
set(TSAN_TEST_TARGET_ARCH ${arch})
61-
get_test_cflags_for_apple_platform(
62-
"${TSAN_TEST_APPLE_PLATFORM}"
63-
"${TSAN_TEST_TARGET_ARCH}"
64-
TSAN_TEST_TARGET_CFLAGS
65-
)
66-
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
67-
string(TOUPPER ${arch} ARCH_UPPER_CASE)
68-
set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
69-
configure_lit_site_cfg(
70-
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
71-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
72-
)
73-
add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
74-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
75-
DEPENDS ${TSAN_TEST_DEPS})
76-
endforeach()
77-
78-
list_intersect(TSAN_TEST_IOS_ARCHS TSAN_SUPPORTED_ARCH DARWIN_ios_ARCHS)
79-
foreach(arch ${TSAN_TEST_IOS_ARCHS})
80-
set(TSAN_TEST_APPLE_PLATFORM "ios")
81-
set(TSAN_TEST_TARGET_ARCH ${arch})
82-
get_test_cflags_for_apple_platform(
83-
"${TSAN_TEST_APPLE_PLATFORM}"
84-
"${TSAN_TEST_TARGET_ARCH}"
85-
TSAN_TEST_TARGET_CFLAGS
86-
)
87-
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
88-
string(TOUPPER ${arch} ARCH_UPPER_CASE)
89-
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
90-
configure_lit_site_cfg(
91-
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
92-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
93-
)
94-
add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS ${arch} tests"
95-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
96-
DEPENDS ${TSAN_TEST_DEPS})
54+
set(TSAN_APPLE_PLATFORMS ${TSAN_SUPPORTED_OS})
55+
foreach(platform ${TSAN_APPLE_PLATFORMS})
56+
if ("${platform}" STREQUAL "osx")
57+
# Skip macOS because it's handled by the code above that builds tests for the host machine.
58+
continue()
59+
endif()
60+
list_intersect(
61+
TSAN_TEST_${platform}_ARCHS
62+
TSAN_SUPPORTED_ARCH
63+
DARWIN_${platform}_ARCHS
64+
)
65+
foreach(arch ${TSAN_TEST_${platform}_ARCHS})
66+
get_test_cflags_for_apple_platform(
67+
"${platform}"
68+
"${arch}"
69+
TSAN_TEST_TARGET_CFLAGS
70+
)
71+
string(TOUPPER "${arch}" ARCH_UPPER_CASE)
72+
get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED)
73+
set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
74+
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
75+
set(TSAN_TEST_APPLE_PLATFORM "${platform}")
76+
set(TSAN_TEST_TARGET_ARCH "${arch}")
77+
configure_lit_site_cfg(
78+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
79+
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
80+
)
81+
add_lit_testsuite(check-tsan-${platform}-${arch} "ThreadSanitizer ${platform} ${arch} tests"
82+
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
83+
DEPENDS ${TSAN_TEST_DEPS})
84+
endforeach()
9785
endforeach()
98-
9986
set(EXCLUDE_FROM_ALL OFF)
10087
endif()
10188

0 commit comments

Comments
 (0)