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 | d1e0365ce38238ca3f5e7ad30b376587d208e270 (patch) | |
tree | 603cc3bc4cd60323bb325316b5ac9383673a762c | |
parent | 6b1db82acf7785ed0b6c103b424402d25ee19891 (diff) | |
download | bcm5719-llvm-d1e0365ce38238ca3f5e7ad30b376587d208e270.tar.gz bcm5719-llvm-d1e0365ce38238ca3f5e7ad30b376587d208e270.zip |
[libFuzzer] [NFC] Support multi-arch and multi-OS building and testing
Differential Revision: https://reviews.llvm.org/D47296
llvm-svn: 334768
-rw-r--r-- | compiler-rt/cmake/config-ix.cmake | 2 | ||||
-rw-r--r-- | compiler-rt/lib/fuzzer/CMakeLists.txt | 4 | ||||
-rw-r--r-- | compiler-rt/lib/fuzzer/tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | compiler-rt/test/fuzzer/CMakeLists.txt | 26 | ||||
-rw-r--r-- | compiler-rt/test/fuzzer/lit.cfg | 17 | ||||
-rw-r--r-- | compiler-rt/test/fuzzer/lit.site.cfg.in | 2 |
6 files changed, 44 insertions, 11 deletions
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 0a12b709bdd..d7e830f8d6e 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/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/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt index 085a981b387..1507608eaa4 100644 --- a/compiler-rt/lib/fuzzer/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/lib/fuzzer/tests/CMakeLists.txt b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt index cc3be7de2bc..df5507f1cf6 100644 --- a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt index 0b611811ad4..1c397566efb 100644 --- a/compiler-rt/test/fuzzer/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/fuzzer/lit.cfg b/compiler-rt/test/fuzzer/lit.cfg index e8f784de606..95674fb9ac7 100644 --- a/compiler-rt/test/fuzzer/lit.cfg +++ b/compiler-rt/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/compiler-rt/test/fuzzer/lit.site.cfg.in b/compiler-rt/test/fuzzer/lit.site.cfg.in index 41f14666621..cbb74f37d56 100644 --- a/compiler-rt/test/fuzzer/lit.site.cfg.in +++ b/compiler-rt/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@" |