aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-18 08:14:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-18 08:14:36 +0000
commit6b200b2b698b6ac9e310f2225c69c85d28ae4fb0 (patch)
tree32935f441d2c278f6988fa20d1f0f843cce80b87
parentae54af2fdcf2262e778f551941541913828fde49 (diff)
Lift AddLinkerSearchPaths() into Darwin tool chain.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82209 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Driver/ToolChains.cpp32
-rw-r--r--lib/Driver/ToolChains.h18
-rw-r--r--lib/Driver/Tools.cpp18
3 files changed, 42 insertions, 26 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 1013f24267..deb06720f4 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -60,32 +60,32 @@ Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
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 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const {
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 0e5ce34884..fc32019803 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -76,6 +76,9 @@ public:
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 @@ public:
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 @@ public:
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 bbf8449758..104d3a3567 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2008,23 +2008,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
// 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) {