diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -224,6 +224,18 @@ set(${cflags_out} "${test_cflags_str}" PARENT_SCOPE) endfunction() +function(get_capitalized_apple_platform platform platform_capitalized) + # TODO(dliew): Remove uses of this function. It exists to preserve needlessly complex + # directory naming conventions used by the Sanitizer lit test suites. + is_valid_apple_platform("${platform}" is_valid_platform) + if (NOT is_valid_platform) + message(FATAL_ERROR "\"${platform}\" is not a valid apple platform") + endif() + string(TOUPPER "${platform}" platform_upper) + string(REGEX REPLACE "OSSIM$" "OSSim" platform_upper_capitalized "${platform_upper}") + set(${platform_capitalized} "${platform_upper_capitalized}" PARENT_SCOPE) +endfunction() + function(is_valid_apple_platform platform is_valid_out) set(is_valid FALSE) if ("${platform}" STREQUAL "") diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt --- a/compiler-rt/test/asan/CMakeLists.txt +++ b/compiler-rt/test/asan/CMakeLists.txt @@ -82,56 +82,43 @@ # 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(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) set(ASAN_TEST_DYNAMIC True) + set(ASAN_APPLE_PLATFORMS ${SANITIZER_COMMON_SUPPORTED_OS}) - list_intersect(ASAN_TEST_IOSSIM_ARCHS ASAN_SUPPORTED_ARCH DARWIN_iossim_ARCHS) - foreach(arch ${ASAN_TEST_IOSSIM_ARCHS}) - set(ASAN_TEST_APPLE_PLATFORM "iossim") - set(ASAN_TEST_TARGET_ARCH ${arch}) - get_test_cflags_for_apple_platform( - "${ASAN_TEST_APPLE_PLATFORM}" - "${ASAN_TEST_TARGET_ARCH}" - ASAN_TEST_TARGET_CFLAGS - ) - set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}") - get_bits_for_arch(${arch} ASAN_TEST_BITS) - 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-asan-iossim-${arch} "AddressSanitizer iOS Simulator ${arch} tests" - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ - DEPENDS ${ASAN_TEST_DEPS}) - endforeach() - - list_intersect(ASAN_TEST_IOS_ARCHS ASAN_SUPPORTED_ARCH DARWIN_ios_ARCHS) - foreach (arch ${ASAN_TEST_IOS_ARCHS}) - set(ASAN_TEST_APPLE_PLATFORM "ios") - set(ASAN_TEST_TARGET_ARCH ${arch}) - get_test_cflags_for_apple_platform( - "${ASAN_TEST_APPLE_PLATFORM}" - "${arch}" - ASAN_TEST_TARGET_CFLAGS) - set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}") - get_bits_for_arch(${arch} ASAN_TEST_BITS) - 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-asan-ios-${arch} "AddressSanitizer iOS ${arch} tests" - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ - DEPENDS ${ASAN_TEST_DEPS}) + foreach(platform ${ASAN_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( + ASAN_TEST_${platform}_ARCHS + ASAN_SUPPORTED_ARCH + DARWIN_${platform}_ARCHS + ) + foreach(arch ${ASAN_TEST_${platform}_ARCHS}) + get_test_cflags_for_apple_platform( + "${platform}" + "${arch}" + ASAN_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(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}") + set(ASAN_TEST_APPLE_PLATFORM "${platform}") + set(ASAN_TEST_TARGET_ARCH "${arch}") + get_bits_for_arch(${arch} ASAN_TEST_BITS) + 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-asan-${platform}-${arch} "AddressSanitizer ${platform} ${arch} tests" + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ + DEPENDS ${ASAN_TEST_DEPS}) + endforeach() endforeach() - set(EXCLUDE_FROM_ALL OFF) endif()