Introduce FindTargetProgramPath to check for a target-specific helper

program and fallback to plain version otherwise. Use this for the NetBSD
target to make it try e.g. i486--netbsdelf-as and -ld for target
i486--netbsdelf.

llvm-svn: 127996
This commit is contained in:
Joerg Sonnenberger 2011-03-21 14:01:40 +00:00
parent bc923f3f7d
commit fcc3ec90a5
1 changed files with 15 additions and 4 deletions

View File

@ -37,6 +37,17 @@
using namespace clang::driver; using namespace clang::driver;
using namespace clang::driver::tools; using namespace clang::driver::tools;
/// FindTargetProgramPath - Return path of the target specific version of
/// ProgName. If it doesn't exist, return path of ProgName itself.
static std::string FindTargetProgramPath(const ToolChain &TheToolChain,
const char *ProgName) {
std::string Executable(TheToolChain.getTripleString() + "-" + ProgName);
std::string Path(TheToolChain.GetProgramPath(Executable.c_str()));
if (Path != Executable)
return Path;
return TheToolChain.GetProgramPath(ProgName);
}
/// CheckPreprocessingOptions - Perform some validation of preprocessing /// CheckPreprocessingOptions - Perform some validation of preprocessing
/// arguments that is shared with gcc. /// arguments that is shared with gcc.
static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) { static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
@ -3427,8 +3438,8 @@ void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(II.getFilename()); CmdArgs.push_back(II.getFilename());
} }
const char *Exec = const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
Args.MakeArgString(getToolChain().GetProgramPath("as")); "as"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs)); C.addCommand(new Command(JA, *this, Exec, CmdArgs));
} }
@ -3541,8 +3552,8 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
"crtn.o"))); "crtn.o")));
} }
const char *Exec = const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
Args.MakeArgString(getToolChain().GetProgramPath("ld")); "ld"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs)); C.addCommand(new Command(JA, *this, Exec, CmdArgs));
} }