aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r--lib/Driver/Tools.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 545645b9bd..5a4b7e29ba 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -37,6 +37,17 @@
using namespace clang::driver;
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
/// arguments that is shared with gcc.
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());
}
- const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath("as"));
+ const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
+ "as"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
@@ -3541,8 +3552,8 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
"crtn.o")));
}
- const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath("ld"));
+ const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
+ "ld"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}