]> granicus.if.org Git - clang/commitdiff
Add gold plugin support to the FreeBSD link driver.
authorRoman Divacky <rdivacky@freebsd.org>
Sun, 10 Nov 2013 09:31:43 +0000 (09:31 +0000)
committerRoman Divacky <rdivacky@freebsd.org>
Sun, 10 Nov 2013 09:31:43 +0000 (09:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194350 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
lib/Driver/Tools.cpp

index 8398471994aae19803b196d0c044eafd9e9a454b..acd0bbd96ce2492f0c90890e1145f33c5148481c 100644 (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;
 }
index 0e86f8c6fe14eabf2b31a5618af03fd54150c563..c30b1b64847c0a91d8ac1305f4454f3ba4b953fd 100644 (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; }
index 7c987191d8006e731f4f4c8d9f9075ff57aad31e..c69ad53360f5d5fdcb37af1fcfc144f4e16e8307 100644 (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) &&