summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2011-05-16 13:35:02 +0000
committerJoerg Sonnenberger <joerg@bec.de>2011-05-16 13:35:02 +0000
commit637603a7ccced82eb4166a421ce502b245586eb8 (patch)
treec2a34e99a4b11552420e45140e6b20be38d7b8e9 /clang/lib/Driver/Tools.cpp
parent5ec1941e5893ba5bf451e98e394ef6a47d37e50b (diff)
downloadbcm5719-llvm-637603a7ccced82eb4166a421ce502b245586eb8.tar.gz
bcm5719-llvm-637603a7ccced82eb4166a421ce502b245586eb8.zip
Make the triple an explicit argument of FindTargetProgramPath.
Preserve the original triple in the NetBSD toolchain when using -m32 or -m64 and the resulting effective target is different from the triple it started with. This allows -m32 to use the same assembler/linking in cross-compiling mode and avoids confusion about passing down target specific flags in that case like --32. llvm-svn: 131404
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index a8998c49a70..19a830cac14 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -47,8 +47,9 @@ 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 std::string TripleString,
const char *ProgName) {
- std::string Executable(TheToolChain.getTripleString() + "-" + ProgName);
+ std::string Executable(TripleString + "-" + ProgName);
std::string Path(TheToolChain.GetProgramPath(Executable.c_str()));
if (Path != Executable)
return Path;
@@ -3597,7 +3598,8 @@ void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
// When building 32-bit code on NetBSD/amd64, we have to explicitly
// instruct as in the base system to assemble 32-bit code.
- if (getToolChain().getArchName() == "i386")
+ if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
+ getToolChain().getArch() == llvm::Triple::x86)
CmdArgs.push_back("--32");
@@ -3620,7 +3622,8 @@ void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
}
const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
- "as"));
+ ToolTriple.getTriple(),
+ "as"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
@@ -3651,7 +3654,8 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
// When building 32-bit code on NetBSD/amd64, we have to explicitly
// instruct ld in the base system to link 32-bit code.
- if (getToolChain().getArchName() == "i386") {
+ if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
+ getToolChain().getArch() == llvm::Triple::x86) {
CmdArgs.push_back("-m");
CmdArgs.push_back("elf_i386");
}
@@ -3734,7 +3738,8 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
}
const char *Exec = Args.MakeArgString(FindTargetProgramPath(getToolChain(),
- "ld"));
+ ToolTriple.getTriple(),
+ "ld"));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
OpenPOWER on IntegriCloud