Lift AddLinkerSearchPaths() into Darwin tool chain.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82209 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 1013f24..deb0672 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -60,32 +60,32 @@
if (getArchName() == "x86_64") {
Path = getHost().getDriver().Dir;
Path += "/../lib/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
Path += "/x86_64";
getFilePaths().push_back(Path);
Path = "/usr/lib/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
Path += "/x86_64";
getFilePaths().push_back(Path);
}
Path = getHost().getDriver().Dir;
Path += "/../lib/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
getFilePaths().push_back(Path);
Path = "/usr/lib/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
getFilePaths().push_back(Path);
Path = getHost().getDriver().Dir;
Path += "/../libexec/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
getProgramPaths().push_back(Path);
Path = "/usr/libexec/gcc/";
- Path += getToolChainDir();
+ Path += ToolChainDir;
getProgramPaths().push_back(Path);
Path = getHost().getDriver().Dir;
@@ -134,6 +134,26 @@
return *T;
}
+void Darwin::AddLinkSearchPathArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ // FIXME: Derive these correctly.
+ if (getArchName() == "x86_64") {
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
+ "/x86_64"));
+ // Intentionally duplicated for (temporary) gcc bug compatibility.
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
+ "/x86_64"));
+ }
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir));
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
+ // Intentionally duplicated for (temporary) gcc bug compatibility.
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
+ "/../../../" + ToolChainDir));
+ CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
+ "/../../.."));
+}
+
DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
const char *BoundArch) const {
DerivedArgList *DAL = new DerivedArgList(Args, false);
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index 0e5ce34..fc32019 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -76,6 +76,9 @@
bool IsIPhone);
~Darwin();
+ /// @name Darwin Specific Toolchain API
+ /// {
+
void getDarwinVersion(unsigned (&Res)[3]) const {
Res[0] = DarwinVersion[0];
Res[1] = DarwinVersion[1];
@@ -96,12 +99,19 @@
return IPhoneOSVersionMin.c_str();
}
- const std::string &getToolChainDir() const {
- return ToolChainDir;
- }
+ /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
+ ///
+ /// \param Args - The input argument list.
+ /// \param CmdArgs [out] - The command argument list to append the paths
+ /// (prefixed by -L) to.
+ void AddLinkSearchPathArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
bool isIPhone() const { return IsIPhone; }
+ /// }
+ /// @name ToolChain Implementation
+ /// {
+
virtual DerivedArgList *TranslateArgs(InputArgList &Args,
const char *BoundArch) const;
@@ -111,6 +121,8 @@
virtual bool IsUnwindTablesDefault() const;
virtual const char *GetDefaultRelocationModel() const;
virtual const char *GetForcedPicModel() const;
+
+ /// }
};
/// Darwin_GCC - Generic Darwin tool chain using gcc.
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index bbf8449..104d3a3 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2008,23 +2008,7 @@
// This is more complicated in gcc...
CmdArgs.push_back("-lgomp");
- // FIXME: Derive these correctly.
- llvm::StringRef TCDir = getDarwinToolChain().getToolChainDir();
- if (getToolChain().getArchName() == "x86_64") {
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir +
- "/x86_64"));
- // Intentionally duplicated for (temporary) gcc bug compatibility.
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir +
- "/x86_64"));
- }
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + TCDir));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir));
- // Intentionally duplicated for (temporary) gcc bug compatibility.
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir +
- "/../../../" + TCDir));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + TCDir +
- "/../../.."));
+ getDarwinToolChain().AddLinkSearchPathArgs(Args, CmdArgs);
for (InputInfoList::const_iterator
it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {