diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-06-14 20:46:07 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-06-14 20:46:07 +0000 |
commit | 6813f247fb4b206b2ea76bd2782362f1de92df20 (patch) | |
tree | 7d6b04da5d5c3ac23f045d67eda687fbab7bbdda | |
parent | d3d797069c5a58d6eb8b1475bcf26f183f87bf15 (diff) |
[libFuzzer] [NFC] Support multi-arch and multi-OS building and testing
Differential Revision: https://reviews.llvm.org/D47296
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334768 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | cmake/config-ix.cmake | 2 | ||||
-rw-r--r-- | lib/fuzzer/CMakeLists.txt | 4 | ||||
-rw-r--r-- | lib/fuzzer/tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/fuzzer/CMakeLists.txt | 26 | ||||
-rw-r--r-- | test/fuzzer/lit.cfg | 17 | ||||
-rw-r--r-- | test/fuzzer/lit.site.cfg.in | 2 |
6 files changed, 44 insertions, 11 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 0a12b709b..d7e830f8d 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -192,7 +192,7 @@ set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${PPC64} ${S390X}) set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) -set(ALL_FUZZER_SUPPORTED_ARCH x86_64) +set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) if(APPLE) set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64}) diff --git a/lib/fuzzer/CMakeLists.txt b/lib/fuzzer/CMakeLists.txt index 085a981b3..1507608ea 100644 --- a/lib/fuzzer/CMakeLists.txt +++ b/lib/fuzzer/CMakeLists.txt @@ -50,9 +50,7 @@ if(NOT HAS_THREAD_LOCAL) list(APPEND LIBFUZZER_CFLAGS -Dthread_local=__thread) endif() -if(APPLE) - set(FUZZER_SUPPORTED_OS osx) -endif() +set(FUZZER_SUPPORTED_OS ${SANITIZER_COMMON_SUPPORTED_OS}) add_compiler_rt_object_libraries(RTfuzzer OS ${FUZZER_SUPPORTED_OS} diff --git a/lib/fuzzer/tests/CMakeLists.txt b/lib/fuzzer/tests/CMakeLists.txt index cc3be7de2..df5507f1c 100644 --- a/lib/fuzzer/tests/CMakeLists.txt +++ b/lib/fuzzer/tests/CMakeLists.txt @@ -6,6 +6,10 @@ set(LIBFUZZER_UNITTEST_CFLAGS -Werror -O2) +if (APPLE) + set(FUZZER_SUPPORTED_OS osx) +endif() + add_custom_target(FuzzerUnitTests) set_target_properties(FuzzerUnitTests PROPERTIES FOLDER "Compiler-RT Tests") diff --git a/test/fuzzer/CMakeLists.txt b/test/fuzzer/CMakeLists.txt index 0b611811a..1c397566e 100644 --- a/test/fuzzer/CMakeLists.txt +++ b/test/fuzzer/CMakeLists.txt @@ -10,6 +10,8 @@ endif() set(EXCLUDE_FROM_ALL ON) add_custom_target(check-fuzzer) +set(LIBFUZZER_TEST_IOS "0") +pythonize_bool(LIBFUZZER_TEST_IOS) if(COMPILER_RT_INCLUDE_TESTS) # libFuzzer unit tests. @@ -71,3 +73,27 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") test_fuzzer("static-libc++" DEPS cxx_static) endif() endif() + +if (APPLE) + set(EXCLUDE_FROM_ALL ON) + + foreach(arch ${DARWIN_ios_ARCHS}) + set(LIBFUZZER_TEST_IOS "1") + pythonize_bool(LIBFUZZER_TEST_IOS) + set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) + set(LIBFUZZER_TEST_FLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") + set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-ios") + 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.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ) + add_lit_testsuite(check-fuzzer-ios-${arch} "libFuzzer iOS ${arch} tests" + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ + DEPENDS ${LIBFUZZER_TEST_DEPS}) + + endforeach() + + set(EXCLUDE_FROM_ALL OFF) +endif() diff --git a/test/fuzzer/lit.cfg b/test/fuzzer/lit.cfg index e8f784de6..95674fb9a 100644 --- a/test/fuzzer/lit.cfg +++ b/test/fuzzer/lit.cfg @@ -2,7 +2,7 @@ import lit.formats import sys import os -config.name = "LLVMFuzzer" +config.name = "libFuzzer" + config.name_suffix config.test_format = lit.formats.ShTest(True) config.suffixes = ['.test'] config.test_source_root = os.path.dirname(__file__) @@ -51,6 +51,7 @@ config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root)) def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True): compiler_cmd = config.clang + extra_cmd = config.target_flags if config.clang and config.stdlib == 'libc++': link_cmd = '-stdlib=libc++ -Wl,-rpath=%s' % config.llvm_library_dir elif config.clang and config.stdlib == 'static-libc++': @@ -66,18 +67,14 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True): if fuzzer_enabled: sanitizers.append('fuzzer') sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers)) - if config.osx_sysroot_flag: - isysroot_cmd = config.osx_sysroot_flag - else: - isysroot_cmd = '' return " ".join([ compiler_cmd, std_cmd, link_cmd, "-O2 -gline-tables-only", - isysroot_cmd, sanitizers_cmd, - "-I%s" % libfuzzer_src_root + "-I%s" % libfuzzer_src_root, + extra_cmd ]) config.substitutions.append(('%cpp_compiler', @@ -95,3 +92,9 @@ config.substitutions.append(('%no_fuzzer_cpp_compiler', config.substitutions.append(('%no_fuzzer_c_compiler', generate_compiler_cmd(is_cpp=False, fuzzer_enabled=False) )) + +if config.host_os == 'Darwin': + if config.target_arch in ["x86_64", "x86_64h"]: + config.parallelism_group = "darwin-64bit-sanitizer" + elif config.ios and not config.iossim: + config.parallelism_group = "darwin-ios-device-sanitizer" diff --git a/test/fuzzer/lit.site.cfg.in b/test/fuzzer/lit.site.cfg.in index 41f146666..cbb74f37d 100644 --- a/test/fuzzer/lit.site.cfg.in +++ b/test/fuzzer/lit.site.cfg.in @@ -6,6 +6,8 @@ config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@" config.target_flags = "@LIBFUZZER_TEST_FLAGS@" config.c_compiler = "@LIBFUZZER_TEST_COMPILER@" config.stdlib = "@LIBFUZZER_TEST_STDLIB@" +config.ios = @LIBFUZZER_TEST_IOS_PYBOOL@ +config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@" config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@" config.cmake_binary_dir = "@CMAKE_BINARY_DIR@" |