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 @@ -230,7 +230,7 @@ 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} ${ARM64}) +set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${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 --- a/compiler-rt/lib/fuzzer/CMakeLists.txt +++ b/compiler-rt/lib/fuzzer/CMakeLists.txt @@ -121,10 +121,15 @@ COMPILER_RT_LIBCXX_PATH AND COMPILER_RT_LIBCXXABI_PATH) macro(partially_link_libcxx name dir arch) + if(${arch} MATCHES "i386") + set(EMULATION_ARGUMENT "-m" "elf_i386") + else() + set(EMULATION_ARGUMENT "") + endif() set(cxx_${arch}_merge_dir "${CMAKE_CURRENT_BINARY_DIR}/cxx_${arch}_merge.dir") file(MAKE_DIRECTORY ${cxx_${arch}_merge_dir}) add_custom_command(TARGET clang_rt.${name}-${arch} POST_BUILD - COMMAND ${CMAKE_LINKER} --whole-archive "$" --no-whole-archive ${dir}/lib/libc++.a -r -o ${name}.o + COMMAND ${CMAKE_LINKER} --whole-archive ${EMULATION_ARGUMENT} "$" --no-whole-archive ${dir}/lib/libc++.a -r -o ${name}.o COMMAND ${CMAKE_OBJCOPY} --localize-hidden ${name}.o COMMAND ${CMAKE_COMMAND} -E remove "$" COMMAND ${CMAKE_AR} qcs "$" ${name}.o 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 @@ -49,6 +49,7 @@ set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER}) get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS) + set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) set(LIBFUZZER_TEST_APPLE_PLATFORM "osx") set(LIBFUZZER_TEST_STDLIB ${stdlib}) diff --git a/compiler-rt/test/fuzzer/compressed.test b/compiler-rt/test/fuzzer/compressed.test --- a/compiler-rt/test/fuzzer/compressed.test +++ b/compiler-rt/test/fuzzer/compressed.test @@ -1,5 +1,8 @@ REQUIRES: linux REQUIRES: zlib +# zlib is "supported" on i386 even when only for x86_64, explicitly make i386 +# unsupported by this test. +UNSUPPORTED: i386 # Custom mutator should find this bug, w/o custom -- no chance. RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestCustom -DCUSTOM_MUTATOR -lz RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestPlain -lz diff --git a/compiler-rt/test/fuzzer/dataflow.test b/compiler-rt/test/fuzzer/dataflow.test --- a/compiler-rt/test/fuzzer/dataflow.test +++ b/compiler-rt/test/fuzzer/dataflow.test @@ -1,6 +1,5 @@ # Tests the data flow tracer. -REQUIRES: linux -UNSUPPORTED: aarch64 +REQUIRES: linux, x86_64 # Build the tracer and the test. RUN: %no_fuzzer_cpp_compiler -c -fno-sanitize=all -fsanitize=dataflow %S/../../lib/fuzzer/dataflow/DataFlow.cpp -o %t-DataFlow.o diff --git a/compiler-rt/test/fuzzer/fork.test b/compiler-rt/test/fuzzer/fork.test --- a/compiler-rt/test/fuzzer/fork.test +++ b/compiler-rt/test/fuzzer/fork.test @@ -11,8 +11,8 @@ RUN: %cpp_compiler %S/OutOfMemoryTest.cpp -o %t-OutOfMemoryTest RUN: not %run %t-OutOfMemoryTest -fork=1 -ignore_ooms=0 -rss_limit_mb=128 2>&1 | FileCheck %s --check-prefix=OOM -# access-violation is the error thrown on Windows. -CRASH: {{SEGV|access-violation}} on unknown address 0x000000000000 +# access-violation is the error thrown on Windows. Address will be smaller on i386. +CRASH: {{SEGV|access-violation}} on unknown address {{0x000000000000|0x00000000}} RUN: %cpp_compiler %S/ShallowOOMDeepCrash.cpp -o %t-ShallowOOMDeepCrash RUN: not %run %t-ShallowOOMDeepCrash -fork=1 -rss_limit_mb=128 2>&1 | FileCheck %s --check-prefix=CRASH diff --git a/compiler-rt/test/fuzzer/lit.cfg b/compiler-rt/test/fuzzer/lit.cfg --- a/compiler-rt/test/fuzzer/lit.cfg +++ b/compiler-rt/test/fuzzer/lit.cfg @@ -6,6 +6,7 @@ config.test_format = lit.formats.ShTest(True) config.suffixes = ['.test'] config.test_source_root = os.path.dirname(__file__) +config.available_features.add(config.target_arch) # Choose between lit's internal shell pipeline runner and a real shell. If # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. @@ -24,7 +25,7 @@ # the test runner updated. config.test_format = lit.formats.ShTest(execute_external) -# LeakSanitizer is not supported on OSX or Windows right now. +# LeakSanitizer is not supported on OSX, Windows, or i386 right now. if (sys.platform.startswith('darwin') or sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd') or @@ -35,7 +36,8 @@ config.available_features.add('lsan') # MemorySanitizer is not supported on OSX or Windows right now -if sys.platform.startswith('darwin') or sys.platform.startswith('win'): +if (sys.platform.startswith('darwin') or sys.platform.startswith('win') or + config.target_arch == 'i386'): lit_config.note('msan feature unavailable') assert 'msan' not in config.available_features else: diff --git a/compiler-rt/test/fuzzer/lit.site.cfg.in b/compiler-rt/test/fuzzer/lit.site.cfg.in --- a/compiler-rt/test/fuzzer/lit.site.cfg.in +++ b/compiler-rt/test/fuzzer/lit.site.cfg.in @@ -11,6 +11,7 @@ config.cmake_binary_dir = "@CMAKE_BINARY_DIR@" config.llvm_library_dir = "@LLVM_LIBRARY_DIR@" config.target_triple = "@TARGET_TRIPLE@" +config.target_arch = "@LIBFUZZER_TEST_TARGET_ARCH@" # Load common config for all compiler-rt lit tests. lit_config.load_config(config, diff --git a/compiler-rt/test/fuzzer/only-some-bytes.test b/compiler-rt/test/fuzzer/only-some-bytes.test --- a/compiler-rt/test/fuzzer/only-some-bytes.test +++ b/compiler-rt/test/fuzzer/only-some-bytes.test @@ -1,6 +1,5 @@ # Tests the data flow tracer. -REQUIRES: linux -UNSUPPORTED: aarch64 +REQUIRES: linux, x86_64 # Build the tracer and the test. RUN: %no_fuzzer_cpp_compiler -c -fno-sanitize=all -fsanitize=dataflow %S/../../lib/fuzzer/dataflow/DataFlow.cpp -o %t-DataFlow.o diff --git a/compiler-rt/test/fuzzer/trace-malloc-threaded.test b/compiler-rt/test/fuzzer/trace-malloc-threaded.test --- a/compiler-rt/test/fuzzer/trace-malloc-threaded.test +++ b/compiler-rt/test/fuzzer/trace-malloc-threaded.test @@ -1,7 +1,7 @@ // FIXME: This test infinite loops on darwin because it crashes // printing a stack trace repeatedly // FIXME: Disabled on Windows because of a crash (possibly related to above). -UNSUPPORTED: darwin, aarch64, windows +UNSUPPORTED: darwin, aarch64, windows, i386 RUN: %cpp_compiler %S/TraceMallocThreadedTest.cpp -o \ RUN: %t-TraceMallocThreadedTest