diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-11-21 14:17:42 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-11-21 14:17:42 +0000 |
commit | 69b77d7fb3265e0e18c91badd50b4cb23dddf3e7 (patch) | |
tree | d5e5c50eae96046e5fae6e5e70848302f76a9730 /lib/Driver/ToolChains.cpp | |
parent | 0061fe4094a088863fd47d2509a40cbfcb019f07 (diff) |
[Sanitizer] force linking with static sanitizer runtimes on Darwin even if they are not found in resource directory. Add test checking sanitizer linker flags on Darwin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains.cpp')
-rw-r--r-- | lib/Driver/ToolChains.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index a56d37bde1..94e3012329 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -261,16 +261,18 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args, void DarwinClang::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, - const char *DarwinStaticLib) const { + const char *DarwinStaticLib, + bool AlwaysLink) const { llvm::sys::Path P(getDriver().ResourceDir); P.appendComponent("lib"); P.appendComponent("darwin"); P.appendComponent(DarwinStaticLib); // For now, allow missing resource libraries to support developers who may - // not have compiler-rt checked out or integrated into their build. + // not have compiler-rt checked out or integrated into their build (unless + // we explicitly force linking with this library). bool Exists; - if (!llvm::sys::fs::exists(P.str(), Exists) && Exists) + if (AlwaysLink || (!llvm::sys::fs::exists(P.str(), Exists) && Exists)) CmdArgs.push_back(Args.MakeArgString(P.str())); } @@ -326,7 +328,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, getDriver().Diag(diag::err_drv_clang_unsupported_per_platform) << "-fsanitize=undefined"; } else { - AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ubsan_osx.a"); + AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ubsan_osx.a", true); // The Ubsan runtime library requires C++. AddCXXStdlibLibArgs(Args, CmdArgs); @@ -343,7 +345,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, getDriver().Diag(diag::err_drv_clang_unsupported_per_platform) << "-fsanitize=address"; } else { - AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.asan_osx.a"); + AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.asan_osx.a", true); // The ASAN runtime library requires C++ and CoreFoundation. AddCXXStdlibLibArgs(Args, CmdArgs); |