Skip to content

Commit

Permalink
[ASan] Don't link against libc++abi when not using libc++
Browse files Browse the repository at this point in the history
This is a follow-up to r233860 which added -lc++abi when using ASan
on Mac, and broke Chromium's ASan build which doesn't use libc++.

llvm-svn: 234521
  • Loading branch information
zmodem committed Apr 9, 2015
1 parent f8e68e2 commit 10821e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains.cpp
Expand Up @@ -338,9 +338,12 @@ void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
OS + "_dynamic.dylib").str(),
/*AlwaysLink*/ true, /*IsEmbedded*/ false,
/*AddRPath*/ true);
// Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export
// all RTTI-related symbols that UBSan uses.
CmdArgs.push_back("-lc++abi");

if (GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) {
// Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export
// all RTTI-related symbols that UBSan uses.
CmdArgs.push_back("-lc++abi");
}
}

void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/sanitizer-ld.c
Expand Up @@ -272,3 +272,11 @@
// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
// CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan

// RUN: %clangcxx -fsanitize=address %s -### -o %t.o 2>&1 \
// RUN: -mmacosx-version-min=10.6 \
// RUN: -target x86_64-apple-darwin13.4.0 \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-DARWIN106-CXX %s
// CHECK-ASAN-DARWIN106-CXX: "{{.*}}ld{{(.exe)?}}"
// CHECK-ASAN-DARWIN106-CXX: libclang_rt.asan_osx_dynamic.dylib
// CHECK-ASAN-DARWIN106-CXX-NOT: -lc++abi

0 comments on commit 10821e5

Please sign in to comment.