Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -140,6 +140,11 @@ append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARY) endif() +option(COMPILER_RT_ENABLE_LIBCXX "Use libc++ if available." OFF) +if (COMPILER_RT_ENABLE_LIBCXX) + check_cxx_compiler_flag("-stdlib=libc++" COMPILER_RT_CXX_SUPPORTS_STDLIB) +endif() + option(SANITIZER_USE_COMPILER_RT "Use compiler-rt builtins instead of libgcc" OFF) #================================ Index: lib/fuzzer/CMakeLists.txt =================================================================== --- lib/fuzzer/CMakeLists.txt +++ lib/fuzzer/CMakeLists.txt @@ -32,6 +32,10 @@ set(LIBFUZZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) +if(HAVE_LIBCXX AND COMPILER_RT_ENABLE_LIBCXX) + append_list_if(COMPILER_RT_CXX_SUPPORTS_STDLIB -stdlib=libc++ LIBFUZZER_CFLAGS) +endif() + if (CMAKE_CXX_FLAGS MATCHES "fsanitize-coverage") list(APPEND LIBFUZZER_CFLAGS -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters) endif()