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 @@ -359,6 +359,7 @@ set(PROFILE_SUPPORTED_OS osx) set(TSAN_SUPPORTED_OS osx) set(XRAY_SUPPORTED_OS osx) + set(FUZZER_SUPPORTED_OS osx) # Note: In order to target x86_64h on OS X the minimum deployment target must # be 10.8 or higher. @@ -442,6 +443,7 @@ list(APPEND SANITIZER_COMMON_SUPPORTED_OS ${platform}sim) list(APPEND PROFILE_SUPPORTED_OS ${platform}sim) list(APPEND TSAN_SUPPORTED_OS ${platform}sim) + list(APPEND FUZZER_SUPPORTED_OS ${platform}sim) endif() foreach(arch ${DARWIN_${platform}sim_ARCHS}) list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) @@ -471,6 +473,7 @@ if(DARWIN_${platform}_TSAN_ARCHS) list(APPEND TSAN_SUPPORTED_OS ${platform}) endif() + list(APPEND FUZZER_SUPPORTED_OS ${platform}) endif() foreach(arch ${DARWIN_${platform}_ARCHS}) list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) diff --git a/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt --- a/compiler-rt/lib/fuzzer/CMakeLists.txt +++ b/compiler-rt/lib/fuzzer/CMakeLists.txt @@ -82,8 +82,6 @@ endif() endif() -set(FUZZER_SUPPORTED_OS ${SANITIZER_COMMON_SUPPORTED_OS}) - add_compiler_rt_component(fuzzer) add_compiler_rt_object_libraries(RTfuzzer diff --git a/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt --- a/compiler-rt/test/fuzzer/CMakeLists.txt +++ b/compiler-rt/test/fuzzer/CMakeLists.txt @@ -89,31 +89,38 @@ endif() if (APPLE) - # FIXME(dliew): This logic should be refactored to the way UBSan Darwin - # testing is done. set(EXCLUDE_FROM_ALL ON) - - list_intersect(FUZZER_TEST_IOS_ARCHS FUZZER_SUPPORTED_ARCH DARWIN_ios_ARCHS) - foreach(arch ${FUZZER_TEST_IOS_ARCHS}) - set(LIBFUZZER_TEST_APPLE_PLATFORM "ios") - set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) - get_test_cflags_for_apple_platform( - "${LIBFUZZER_TEST_APPLE_PLATFORM}" - "${LIBFUZZER_TEST_TARGET_ARCH}" - LIBFUZZER_TEST_FLAGS - ) - set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${LIBFUZZER_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-fuzzer-ios-${arch} "libFuzzer iOS ${arch} tests" - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ - DEPENDS ${LIBFUZZER_TEST_DEPS}) - + set(FUZZER_APPLE_PLATFORMS ${FUZZER_SUPPORTED_OS}) + foreach(platform ${FUZZER_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( + FUZZER_TEST_${platform}_ARCHS + FUZZER_SUPPORTED_ARCH + DARWIN_${platform}_ARCHS + ) + foreach(arch ${FUZZER_TEST_${platform}_ARCHS}) + get_test_cflags_for_apple_platform( + "${platform}" + "${arch}" + LIBFUZZER_TEST_FLAGS + ) + string(TOUPPER "${arch}" ARCH_UPPER_CASE) + get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED) + set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config") + set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${platform}") + set(LIBFUZZER_TEST_APPLE_PLATFORM "${platform}") + set(LIBFUZZER_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-fuzzer-${platform}-${arch} "libFuzzer ${platform} ${arch} tests" + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ + DEPENDS ${LIBFUZZER_TEST_DEPS}) + endforeach() endforeach() - set(EXCLUDE_FROM_ALL OFF) endif()