[cfe-commits] r72794 - in /cfe/trunk: include/clang/Driver/HostInfo.h lib/Driver/HostInfo.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Jun 3 11:59:56 PDT 2009
Author: efriedma
Date: Wed Jun 3 13:59:56 2009
New Revision: 72794
URL: http://llvm.org/viewvc/llvm-project?rev=72794&view=rev
Log:
PR4308: Fix support for -m32/-m64 on Linux.
I'll look into cleaning this up a bit as a followup.
Modified:
cfe/trunk/include/clang/Driver/HostInfo.h
cfe/trunk/lib/Driver/HostInfo.cpp
Modified: cfe/trunk/include/clang/Driver/HostInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=72794&r1=72793&r2=72794&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/HostInfo.h (original)
+++ cfe/trunk/include/clang/Driver/HostInfo.h Wed Jun 3 13:59:56 2009
@@ -28,10 +28,10 @@
/// being run from. For testing purposes, the HostInfo used by the
/// driver may differ from the actual host.
class HostInfo {
+protected:
const Driver &TheDriver;
const llvm::Triple Triple;
-protected:
HostInfo(const Driver &D, const llvm::Triple &_Triple);
public:
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=72794&r1=72793&r2=72794&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Wed Jun 3 13:59:56 2009
@@ -194,11 +194,13 @@
std::string Arch = getArchName();
ArchName = Arch.c_str();
if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
- if (getArchName() == "i386" || getArchName() == "x86_64") {
- ArchName =
+ if (Triple.getArch() == llvm::Triple::x86 ||
+ Triple.getArch() == llvm::Triple::x86_64) {
+ ArchName =
(A->getOption().getId() == options::OPT_m32) ? "i386" : "x86_64";
- } else if (getArchName() == "powerpc" || getArchName() == "powerpc64") {
- ArchName =
+ } else if (Triple.getArch() == llvm::Triple::ppc ||
+ Triple.getArch() == llvm::Triple::ppc64) {
+ ArchName =
(A->getOption().getId() == options::OPT_m32) ? "powerpc" : "powerpc64";
}
}
@@ -361,13 +363,26 @@
assert(!ArchName &&
"Unexpected arch name on platform without driver driver support.");
- ArchName = getArchName().c_str();
-
+ // Automatically handle some instances of -m32/-m64 we know about.
+ std::string Arch = getArchName();
+ ArchName = Arch.c_str();
+ if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
+ if (Triple.getArch() == llvm::Triple::x86 ||
+ Triple.getArch() == llvm::Triple::x86_64) {
+ ArchName =
+ (A->getOption().getId() == options::OPT_m32) ? "i386" : "x86_64";
+ } else if (Triple.getArch() == llvm::Triple::ppc ||
+ Triple.getArch() == llvm::Triple::ppc64) {
+ ArchName =
+ (A->getOption().getId() == options::OPT_m32) ? "powerpc" : "powerpc64";
+ }
+ }
+
ToolChain *&TC = ToolChains[ArchName];
if (!TC) {
llvm::Triple TCTriple(getTriple());
- TCTriple.setArchName(getArchName());
+ TCTriple.setArchName(ArchName);
TC = new toolchains::Linux(*this, TCTriple);
}
More information about the cfe-commits
mailing list