]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Add ASAN runtime library link support.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 1 Dec 2011 23:40:18 +0000 (23:40 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 1 Dec 2011 23:40:18 +0000 (23:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145651 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
runtime/compiler-rt/Makefile

index 5ebe2828547d12b59c3eddabdb11d2cab5b96677..245b3e83084d3c4541b0709c4d23be890d92ddd3 100644 (file)
@@ -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");
index bba8fb304810abc84e6d7bcf33dae8ab78221b41..a8cd2e981d64eb188205e683aacf420dc4320cf5 100644 (file)
@@ -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).