[compiler-rt] r334768 - [libFuzzer] [NFC] Support multi-arch and multi-OS building and testing

George Karpenkov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 13:46:08 PDT 2018


Author: george.karpenkov
Date: Thu Jun 14 13:46:07 2018
New Revision: 334768

URL: http://llvm.org/viewvc/llvm-project?rev=334768&view=rev
Log:
[libFuzzer] [NFC] Support multi-arch and multi-OS building and testing

Differential Revision: https://reviews.llvm.org/D47296

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/fuzzer/CMakeLists.txt
    compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt
    compiler-rt/trunk/test/fuzzer/CMakeLists.txt
    compiler-rt/trunk/test/fuzzer/lit.cfg
    compiler-rt/trunk/test/fuzzer/lit.site.cfg.in

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Thu Jun 14 13:46:07 2018
@@ -192,7 +192,7 @@ set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH
 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})

Modified: compiler-rt/trunk/lib/fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/CMakeLists.txt?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/fuzzer/CMakeLists.txt Thu Jun 14 13:46:07 2018
@@ -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}

Modified: compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt Thu Jun 14 13:46:07 2018
@@ -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")
 

Modified: compiler-rt/trunk/test/fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/CMakeLists.txt?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/fuzzer/CMakeLists.txt Thu Jun 14 13:46:07 2018
@@ -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 "Linu
     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()

Modified: compiler-rt/trunk/test/fuzzer/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.cfg?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.cfg (original)
+++ compiler-rt/trunk/test/fuzzer/lit.cfg Thu Jun 14 13:46:07 2018
@@ -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
 
 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, f
   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
 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"

Modified: compiler-rt/trunk/test/fuzzer/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.site.cfg.in?rev=334768&r1=334767&r2=334768&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/fuzzer/lit.site.cfg.in Thu Jun 14 13:46:07 2018
@@ -6,6 +6,8 @@ config.cpp_compiler = "@LIBFUZZER_TEST_C
 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@"




More information about the llvm-commits mailing list