Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1015,6 +1015,8 @@ Group; def fsanitize_link_cxx_runtime : Flag<["-"], "fsanitize-link-c++-runtime">, Group; +def fno_sanitize_link_cxx_runtime : Flag<["-"], "fno-sanitize-link-c++-runtime">, + Group; def fsanitize_cfi_cross_dso : Flag<["-"], "fsanitize-cfi-cross-dso">, Group, HelpText<"Enable control flow integrity (CFI) checks for cross-DSO calls.">; Index: lib/Driver/SanitizerArgs.cpp =================================================================== --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -743,7 +743,8 @@ // Parse -link-cxx-sanitizer flag. LinkCXXRuntimes = - Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX(); + Args.hasFlag(options::OPT_fsanitize_link_cxx_runtime, + options::OPT_fno_sanitize_link_cxx_runtime, D.CCCIsCXX()); // Finally, initialize the set of available and recoverable sanitizers. Sanitizers.Mask |= Kinds; Index: test/Driver/sanitizer-ld.c =================================================================== --- test/Driver/sanitizer-ld.c +++ test/Driver/sanitizer-ld.c @@ -115,6 +115,12 @@ // CHECK-ASAN-LINUX-CXX-STATIC: "--whole-archive" "{{.*}}libclang_rt.asan-i386.a" "--no-whole-archive" // CHECK-ASAN-LINUX-CXX-STATIC: stdc++ +// RUN: %clangxx -x c++ %s -### -o /dev/null -fsanitize=address -fno-sanitize-link-c++-runtime \ +// RUN: -target i386-unknown-linux -fuse-ld=ld 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-CXX-RUNTIME %s +// +// CHECK-ASAN-NO-LINK-CXX-RUNTIME-NOT: asan_cxx + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-gnueabi -fuse-ld=ld -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \