]> granicus.if.org Git - clang/commitdiff
For linking on FreeBSD, don't add a hardcoded "-L/usr/lib", but
authorRoman Divacky <rdivacky@freebsd.org>
Tue, 1 Mar 2011 17:53:14 +0000 (17:53 +0000)
committerRoman Divacky <rdivacky@freebsd.org>
Tue, 1 Mar 2011 17:53:14 +0000 (17:53 +0000)
retrieve the library paths from the ToolChain object instead.

Copy the relevant code from linuxtools::Link::ConstructJob(), and
replace the std::string stuff with llvm::StringRef, while we're here.

Patch by Dimitry Andric!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp

index 2e11d30d04285501d1a301b65ef4b329731581a6..0205cf6ff261f03b6cf8e9198d991fb508c8d096 100644 (file)
@@ -3274,7 +3274,10 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  CmdArgs.push_back("-L/usr/lib");
+  const ToolChain::path_list Paths = getToolChain().getFilePaths();
+  for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end();
+       i != e; ++i)
+    CmdArgs.push_back(Args.MakeArgString(llvm::StringRef("-L") + *i));
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
   Args.AddAllArgs(CmdArgs, options::OPT_s);
@@ -3639,12 +3642,9 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
 
   const ToolChain::path_list Paths = ToolChain.getFilePaths();
 
-  for (ToolChain::path_list::const_iterator i = Paths.begin(),
-         e = Paths.end();
-       i != e; ++i) {
-    const std::string &s = *i;
-    CmdArgs.push_back(Args.MakeArgString(std::string("-L") + s));
-  }
+  for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end();
+       i != e; ++i)
+    CmdArgs.push_back(Args.MakeArgString(llvm::StringRef("-L") + *i));
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);