From 68e7d10ff98afa96d4ae20ad7ced9d6b3ea51b66 Mon Sep 17 00:00:00 2001 From: TB Schardl Date: Thu, 2 Jul 2020 16:12:03 -0400 Subject: [PATCH] [Darwin] Fix link flags for Cilksan and Cilkscale on Darwin. --- clang/lib/Driver/ToolChains/Darwin.cpp | 15 ++++++++++++++- clang/lib/Driver/ToolChains/Darwin.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 402a7b2339ca..3b6e15c852a1 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1144,6 +1144,17 @@ void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args, AddLinkRuntimeLib(Args, CmdArgs, Sanitizer, RLO, Shared); } +void DarwinClang::AddCilktoolRTLibs(const ArgList &Args, + ArgStringList &CmdArgs) const { + if (Arg *A = Args.getLastArg(options::OPT_fcilktool_EQ)) { + StringRef Val = A->getValue(); + auto RLO = RuntimeLinkOptions(RLO_AlwaysLink); + AddLinkRuntimeLib(Args, CmdArgs, Val, RLO); + // Link in the C++ standard library + AddCXXStdlibLibArgs(Args, CmdArgs); + } +} + ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType( const ArgList &Args) const { if (Arg* A = Args.getLastArg(options::OPT_rtlib_EQ)) { @@ -1193,7 +1204,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, if (Sanitize.needsTsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan"); if (Sanitize.needsCilksanRt()) - AddLinkSanitizerLibArgs(Args, CmdArgs, "cilk"); + AddLinkSanitizerLibArgs(Args, CmdArgs, "cilksan"); if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) { AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false); @@ -1205,6 +1216,8 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, AddLinkSanitizerLibArgs(Args, CmdArgs, "stats"); } + AddCilktoolRTLibs(Args, CmdArgs); + const XRayArgs &XRay = getXRayArgs(); if (XRay.needsXRayRt()) { AddLinkRuntimeLib(Args, CmdArgs, "xray"); diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index 2dc7c85880f7..716c0e65ecef 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -533,6 +533,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin { StringRef Sanitizer, bool shared = true) const; + void AddCilktoolRTLibs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + bool AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, llvm::SmallString<128> Base,