From: Roman Divacky Date: Sun, 10 Nov 2013 09:31:43 +0000 (+0000) Subject: Add gold plugin support to the FreeBSD link driver. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db33419ecf2c608f1024366364fe64220ec4a057;p=clang Add gold plugin support to the FreeBSD link driver. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194350 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 8398471994..acd0bbd96c 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -2497,6 +2497,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) addPathIfExists(SysRoot + "/usr/lib", Paths); } +bool FreeBSD::HasNativeLLVMSupport() const { + return true; +} + bool Linux::HasNativeLLVMSupport() const { return true; } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 0e86f8c6fe..c30b1b6484 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -514,6 +514,7 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { public: FreeBSD(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); + virtual bool HasNativeLLVMSupport() const; virtual bool IsMathErrnoDefault() const { return false; } virtual bool IsObjCNonFragileABIDefault() const { return true; } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7c987191d8..c69ad53360 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5770,6 +5770,26 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag); Args.AddAllArgs(CmdArgs, options::OPT_r); + // Tell the linker to load the plugin. This has to come before AddLinkerInputs + // as gold requires -plugin to come before any -plugin-opt that -Wl might + // forward. + if (D.IsUsingLTO(Args)) { + CmdArgs.push_back("-plugin"); + std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so"; + CmdArgs.push_back(Args.MakeArgString(Plugin)); + + // Try to pass driver level flags relevant to LTO code generation down to + // the plugin. + + // Handle flags for selecting CPU variants. + std::string CPU = getCPUName(Args, ToolChain.getTriple()); + if (!CPU.empty()) { + CmdArgs.push_back( + Args.MakeArgString(Twine("-plugin-opt=mcpu=") + + CPU)); + } + } + AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); if (!Args.hasArg(options::OPT_nostdlib) &&