From 220790f4f420e3564e6c71e5bddfe88fbef4684f Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 19 Dec 2018 14:40:30 +0000 Subject: [PATCH] Disable using `-fsanitize=leak` from the Clang Driver. LeakSanitizer (LSan) is not yet mature for Darwin so until this changes we should avoid supporting it in Swift Clang and AppleClang. rdar://problem/45841334 --- lib/Driver/ToolChains/Darwin.cpp | 3 +++ test/Driver/apple-clang-no-lsan.c | 7 +++++++ test/Driver/fsanitize.c | 14 +++++++------- test/Driver/sanitizer-ld.c | 5 ++--- 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 test/Driver/apple-clang-no-lsan.c diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp index bfe1e581088..1c61dd868ba 100644 --- a/lib/Driver/ToolChains/Darwin.cpp +++ b/lib/Driver/ToolChains/Darwin.cpp @@ -2358,6 +2358,9 @@ SanitizerMask Darwin::getSupportedSanitizers() const { Res |= SanitizerKind::FuzzerNoLink; Res |= SanitizerKind::Function; + // Apple-Clang: Don't support LSan. rdar://problem/45841334 + Res &= ~SanitizerKind::Leak; + // Prior to 10.9, macOS shipped a version of the C++ standard library without // C++11 support. The same is true of iOS prior to version 5. These OS'es are // incompatible with -fsanitize=vptr. diff --git a/test/Driver/apple-clang-no-lsan.c b/test/Driver/apple-clang-no-lsan.c new file mode 100644 index 00000000000..54787e3ddba --- /dev/null +++ b/test/Driver/apple-clang-no-lsan.c @@ -0,0 +1,7 @@ +// Apple-Clang: Don't support LSan +// REQUIRES: system-darwin +// RUN: not %clang -fsanitize=leak %s -o %t 2>&1 | FileCheck %s +// CHECK: unsupported option '-fsanitize=leak' +int main() { + return 0; +} diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c index 0a82174aaa4..f8badfbf549 100644 --- a/test/Driver/fsanitize.c +++ b/test/Driver/fsanitize.c @@ -551,25 +551,25 @@ // CHECK-ESAN-OPENBSD: error: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-pc-openbsd' // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN -// CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option +// CHECK-LSAN-X86-64-DARWIN: unsupported option // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-IOSSIMULATOR -// CHECK-LSAN-X86-64-IOSSIMULATOR-NOT: unsupported option +// CHECK-LSAN-X86-64-IOSSIMULATOR: unsupported option // RUN: %clang -target x86_64-apple-tvossimulator -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-TVOSSIMULATOR -// CHECK-LSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option +// CHECK-LSAN-X86-64-TVOSSIMULATOR: unsupported option // RUN: %clang -target i386-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-I386-DARWIN -// CHECK-LSAN-I386-DARWIN-NOT: unsupported option +// CHECK-LSAN-I386-DARWIN: unsupported option // RUN: %clang -target arm-apple-ios -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-ARM-IOS -// CHECK-LSAN-ARM-IOS-NOT: unsupported option +// CHECK-LSAN-ARM-IOS: unsupported option // RUN: %clang -target i386-apple-iossimulator -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-I386-IOSSIMULATOR -// CHECK-LSAN-I386-IOSSIMULATOR-NOT: unsupported option +// CHECK-LSAN-I386-IOSSIMULATOR: unsupported option // RUN: %clang -target i386-apple-tvossimulator -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-I386-TVOSSIMULATOR -// CHECK-LSAN-I386-TVOSSIMULATOR-NOT: unsupported option +// CHECK-LSAN-I386-TVOSSIMULATOR: unsupported option // RUN: %clang -target i686-linux-gnu -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-X86 // RUN: %clang -target i686-linux-gnu -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-X86 diff --git a/test/Driver/sanitizer-ld.c b/test/Driver/sanitizer-ld.c index db699410f7e..30adfa86c99 100644 --- a/test/Driver/sanitizer-ld.c +++ b/test/Driver/sanitizer-ld.c @@ -537,14 +537,13 @@ // CHECK-ASAN-DARWIN106-CXX: libclang_rt.asan_osx_dynamic.dylib // CHECK-ASAN-DARWIN106-CXX-NOT: -lc++abi +// Apple-Clang: Don't support LSan // RUN: %clangxx -fsanitize=leak %s -### -o %t.o 2>&1 \ // RUN: -mmacosx-version-min=10.6 \ // RUN: -target x86_64-apple-darwin13.4.0 -fuse-ld=ld -stdlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-LSAN-DARWIN106-CXX %s -// CHECK-LSAN-DARWIN106-CXX: "{{.*}}ld{{(.exe)?}}" -// CHECK-LSAN-DARWIN106-CXX: libclang_rt.lsan_osx_dynamic.dylib -// CHECK-LSAN-DARWIN106-CXX-NOT: -lc++abi +// CHECK-LSAN-DARWIN106-CXX: unsupported option '-fsanitize=leak' // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=safe-stack \