summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-12-01 23:40:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-12-01 23:40:18 +0000
commit94b54ea787e439496fde16b3d2882d6d1b22d4f0 (patch)
treea1e92585703fe260f3d8b2f6e92d3176c8e6d639
parentecc2c090e7146c029dd9ee9a5a2fd66b275c01c0 (diff)
Driver/Darwin: Add ASAN runtime library link support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145651 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Driver/ToolChains.cpp16
-rw-r--r--runtime/compiler-rt/Makefile2
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 5ebe282854..245b3e8308 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -467,6 +467,22 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
}
}
+ // Add ASAN runtime library, if required.
+ if (Args.hasFlag(options::OPT_faddress_sanitizer,
+ options::OPT_fno_address_sanitizer, false)) {
+ if (isTargetIPhoneOS()) {
+ getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
+ << "-faddress-sanitizer";
+ } else {
+ AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.asan_osx.a");
+
+ // The ASAN runtime library requires C++ and CoreFoundation.
+ AddCXXStdlibLibArgs(Args, CmdArgs);
+ CmdArgs.push_back("-framework");
+ CmdArgs.push_back("CoreFoundation");
+ }
+ }
+
// Otherwise link libSystem, then the dynamic runtime library, and finally any
// target specific static runtime library.
CmdArgs.push_back("-lSystem");
diff --git a/runtime/compiler-rt/Makefile b/runtime/compiler-rt/Makefile
index bba8fb3048..a8cd2e981d 100644
--- a/runtime/compiler-rt/Makefile
+++ b/runtime/compiler-rt/Makefile
@@ -78,7 +78,7 @@ ifeq ($(OS),Darwin)
RuntimeDirs += darwin
RuntimeLibrary.darwin.Configs := \
eprintf 10.4 osx ios cc_kext \
- profile_osx profile_ios
+ asan_osx profile_osx profile_ios
# On Darwin, fake Clang into using the iOS assembler (since compiler-rt wants to
# build ARM bits).