Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -90,6 +90,10 @@ option(SANITIZER_CAN_USE_CXXABI "Sanitizers can use cxxabi" ${use_cxxabi_default}) pythonize_bool(SANITIZER_CAN_USE_CXXABI) +option(SANITIZER_USE_SOFTWARE_MEMORY_MANAGER + "Experimental: Do not rely on availability of mmap() in sanitizers." OFF) +mark_as_advanced(SANITIZER_USE_SOFTWARE_MEMORY_MANAGER) + #================================ # Setup Compiler Flags #================================ Index: lib/asan/tests/CMakeLists.txt =================================================================== --- lib/asan/tests/CMakeLists.txt +++ lib/asan/tests/CMakeLists.txt @@ -34,6 +34,13 @@ -Wno-non-virtual-dtor) append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros ASAN_UNITTEST_COMMON_CFLAGS) +# With the software memory manager enabled we need the RTL to handle all +# shadow memory accesses. +if(SANITIZER_USE_SOFTWARE_MEMORY_MANAGER) + list(APPEND ASAN_UNITTEST_COMMON_CFLAGS + -mllvm -asan-instrumentation-with-call-threshold=0) +endif() + # This will ensure the target linker is used # during cross compilation set(ASAN_UNITTEST_COMMON_LINK_FLAGS @@ -328,9 +335,14 @@ darwin_filter_host_archs(ASAN_SUPPORTED_ARCH ASAN_TEST_ARCH) endif() foreach(arch ${ASAN_TEST_ARCH}) - add_asan_tests_for_arch_and_kind(${arch} "-inline") - add_asan_tests_for_arch_and_kind(${arch} "-with-calls" - -mllvm -asan-instrumentation-with-call-threshold=0) + # The software memory manager requires out-of-line instrumentation. + if(SANITIZER_USE_SOFTWARE_MEMORY_MANAGER) + add_asan_tests_for_arch_and_kind(${arch} "-with-calls") + else() + add_asan_tests_for_arch_and_kind(${arch} "-inline") + add_asan_tests_for_arch_and_kind(${arch} "-with-calls" + -mllvm -asan-instrumentation-with-call-threshold=0) + endif() endforeach() endif() Index: test/asan/lit.cfg =================================================================== --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -81,6 +81,9 @@ config.debug_info_flags + target_cflags) if config.target_arch == 's390x': clang_asan_static_cflags.append("-mbackchain") +if config.use_software_memory_manager == 'ON': + clang_asan_static_cflags.extend( + ["-mllvm", "-asan-instrumentation-with-call-threshold=0"]) clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags asan_dynamic_flags = [] Index: test/lit.common.configured.in =================================================================== --- test/lit.common.configured.in +++ test/lit.common.configured.in @@ -28,6 +28,8 @@ set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@) set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@) set_default("can_symbolize", @CAN_SYMBOLIZE@) +set_default("use_software_memory_manager", + "@SANITIZER_USE_SOFTWARE_MEMORY_MANAGER@") config.available_features.add('target-is-%s' % config.target_arch) # LLVM tools dir can be passed in lit parameters, so try to