Skip to content

Commit 9d9b470

Browse files
committed
[CMake] Refactor iOS simulator/device test configuration generation code for LibFuzzer.
Summary: In order to do this `FUZZER_SUPPORTED_OS` had to be pulled out of `lib/fuzzer/CMakeLists.txt` and into the main config so we can use it from the `test/fuzzer/CMakeList.txt`. `FUZZER_SUPPORTED_OS` currently has the same value of `SANITIZER_COMMON_SUPPORTED_OS` which preserves the existing behaviour but this allows us in the future to adjust the supported platforms independent of `SANITIZER_COMMON_SUPPORTED_OS`. This mirrors the other sanitizers. For non-Apple platforms `FUZZER_SUPPORTED_OS` is not defined and surprisingly this was the behaviour before this patch because `SANITIZER_COMMON_SUPPORTED_OS` was actually empty. This appears to not matter right now because the functions that take an `OS` as an argument seem to ignore it on non-Apple platforms. While this change tries to be NFC it is technically not because we now generate an iossim config whereas previously we didn't. This seems like the right thing to do because the build system was configured to compile LibFuzzer for iossim but previously we weren't generating a lit test config for it. The device/simulator testing configs don't run by default anyway so this shouldn't break testing. 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/D73243
1 parent 0656936 commit 9d9b470

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed

compiler-rt/cmake/config-ix.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ if(APPLE)
359359
set(PROFILE_SUPPORTED_OS osx)
360360
set(TSAN_SUPPORTED_OS osx)
361361
set(XRAY_SUPPORTED_OS osx)
362+
set(FUZZER_SUPPORTED_OS osx)
362363

363364
# Note: In order to target x86_64h on OS X the minimum deployment target must
364365
# be 10.8 or higher.
@@ -442,6 +443,7 @@ if(APPLE)
442443
list(APPEND SANITIZER_COMMON_SUPPORTED_OS ${platform}sim)
443444
list(APPEND PROFILE_SUPPORTED_OS ${platform}sim)
444445
list(APPEND TSAN_SUPPORTED_OS ${platform}sim)
446+
list(APPEND FUZZER_SUPPORTED_OS ${platform}sim)
445447
endif()
446448
foreach(arch ${DARWIN_${platform}sim_ARCHS})
447449
list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
@@ -471,6 +473,7 @@ if(APPLE)
471473
if(DARWIN_${platform}_TSAN_ARCHS)
472474
list(APPEND TSAN_SUPPORTED_OS ${platform})
473475
endif()
476+
list(APPEND FUZZER_SUPPORTED_OS ${platform})
474477
endif()
475478
foreach(arch ${DARWIN_${platform}_ARCHS})
476479
list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})

compiler-rt/lib/fuzzer/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ else()
8282
endif()
8383
endif()
8484

85-
set(FUZZER_SUPPORTED_OS ${SANITIZER_COMMON_SUPPORTED_OS})
86-
8785
add_compiler_rt_component(fuzzer)
8886

8987
add_compiler_rt_object_libraries(RTfuzzer

compiler-rt/test/fuzzer/CMakeLists.txt

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,39 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
8989
endif()
9090

9191
if (APPLE)
92-
# FIXME(dliew): This logic should be refactored to the way UBSan Darwin
93-
# testing is done.
9492
set(EXCLUDE_FROM_ALL ON)
95-
96-
list_intersect(FUZZER_TEST_IOS_ARCHS FUZZER_SUPPORTED_ARCH DARWIN_ios_ARCHS)
97-
foreach(arch ${FUZZER_TEST_IOS_ARCHS})
98-
set(LIBFUZZER_TEST_APPLE_PLATFORM "ios")
99-
set(LIBFUZZER_TEST_TARGET_ARCH ${arch})
100-
get_test_cflags_for_apple_platform(
101-
"${LIBFUZZER_TEST_APPLE_PLATFORM}"
102-
"${LIBFUZZER_TEST_TARGET_ARCH}"
103-
LIBFUZZER_TEST_FLAGS
104-
)
105-
set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${LIBFUZZER_TEST_APPLE_PLATFORM}")
106-
string(TOUPPER ${arch} ARCH_UPPER_CASE)
107-
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
108-
configure_lit_site_cfg(
109-
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
110-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
111-
)
112-
add_lit_testsuite(check-fuzzer-ios-${arch} "libFuzzer iOS ${arch} tests"
113-
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
114-
DEPENDS ${LIBFUZZER_TEST_DEPS})
115-
93+
set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
94+
set(FUZZER_APPLE_PLATFORMS ${FUZZER_SUPPORTED_OS})
95+
foreach(platform ${FUZZER_APPLE_PLATFORMS})
96+
if ("${platform}" STREQUAL "osx")
97+
# Skip macOS because it's handled by the code above that builds tests for the host machine.
98+
continue()
99+
endif()
100+
list_intersect(
101+
FUZZER_TEST_${platform}_ARCHS
102+
FUZZER_SUPPORTED_ARCH
103+
DARWIN_${platform}_ARCHS
104+
)
105+
foreach(arch ${FUZZER_TEST_${platform}_ARCHS})
106+
get_test_cflags_for_apple_platform(
107+
"${platform}"
108+
"${arch}"
109+
LIBFUZZER_TEST_FLAGS
110+
)
111+
string(TOUPPER "${arch}" ARCH_UPPER_CASE)
112+
get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED)
113+
set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
114+
set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
115+
set(LIBFUZZER_TEST_APPLE_PLATFORM "${platform}")
116+
set(LIBFUZZER_TEST_TARGET_ARCH "${arch}")
117+
configure_lit_site_cfg(
118+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
119+
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
120+
)
121+
add_lit_testsuite(check-fuzzer-${platform}-${arch} "libFuzzer ${platform} ${arch} tests"
122+
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
123+
DEPENDS ${LIBFUZZER_TEST_DEPS})
124+
endforeach()
116125
endforeach()
117-
118126
set(EXCLUDE_FROM_ALL OFF)
119127
endif()

0 commit comments

Comments
 (0)