Add gold plugin support to the FreeBSD link driver.

llvm-svn: 194350
This commit is contained in:
Roman Divacky 2013-11-10 09:31:43 +00:00
parent 78d1acb3af
commit f0d7f94490
3 changed files with 25 additions and 0 deletions

View File

@ -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;
}

View File

@ -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; }

View File

@ -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) &&