Lift AddLinkerSearchPaths() into Darwin tool chain.

llvm-svn: 82209
This commit is contained in:
Daniel Dunbar 2009-09-18 08:14:36 +00:00
parent 48622c13f7
commit 4c30b89def
3 changed files with 42 additions and 26 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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) {