| From d69bb4b646428fb4b177cd61e467f975d77277da Mon Sep 17 00:00:00 2001 |
| From: Robin Sommer <robin@icir.org> |
| Date: Sun, 15 Jun 2014 19:57:19 -0700 |
| Subject: Adapting linker arguments. |
| |
| - Adding -L<prefix>/lib to default linker arguments. |
| - On Linux and FreeBSD, and -rpath. |
| - Fix FreeBSD builtin library search paths. |
| --- |
| lib/Driver/ToolChains.cpp | 3 +++ |
| lib/Driver/Tools.cpp | 9 +++++++++ |
| 2 files changed, 12 insertions(+) |
| |
| diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp |
| index 2309b2d..db59c01 100644 |
| --- a/lib/Driver/ToolChains.cpp |
| +++ b/lib/Driver/ToolChains.cpp |
| @@ -2524,6 +2524,9 @@ void Bitrig::AddCXXStdlibLibArgs(const ArgList &Args, |
| |
| FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args) |
| : Generic_ELF(D, Triple, Args) { |
| + // Look in the prefix before going into /usr/lib. Otherwise we'll wind up |
| + // with the wrong libc++. |
| + getFilePaths().push_back(getDriver().Dir + "/../lib"); |
| |
| // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall |
| // back to '/usr/lib' if it doesn't exist. |
| diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp |
| index 9a5b361..32228fd 100644 |
| --- a/lib/Driver/Tools.cpp |
| +++ b/lib/Driver/Tools.cpp |
| @@ -214,6 +214,15 @@ static void AddLinkerInputs(const ToolChain &TC, |
| // and only supported on native toolchains. |
| if (!TC.isCrossCompiling()) |
| addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH"); |
| + |
| + if (!TC.isCrossCompiling()) { |
| + CmdArgs.push_back(Args.MakeArgString("-L" + D.InstalledDir + "/../lib")); |
| + |
| + auto os = TC.getTriple().getOS(); |
| + if (os == llvm::Triple::Linux || os == llvm::Triple::FreeBSD) |
| + CmdArgs.push_back(Args.MakeArgString("-rpath=" + D.InstalledDir + "/../lib")); |
| + } |
| + |
| } |
| |
| /// \brief Determine whether Objective-C automated reference counting is |
| -- |
| 2.1.2 |
| |