From: Daniel Dunbar Date: Thu, 8 Nov 2012 03:38:26 +0000 (+0000) Subject: Driver/Darwin: The -arch argument values aren't exactly the arch names from a X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3bd9f5c50814e930bc150ca3f6754919ac18d96;p=platform%2Fupstream%2Fllvm.git Driver/Darwin: The -arch argument values aren't exactly the arch names from a triple. - Translate the special case of powerpc to its expected -arch name. llvm-svn: 167571 --- diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index d694e0f..71736d6 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -85,6 +85,10 @@ public: StringRef getPlatform() const { return Triple.getVendorName(); } StringRef getOS() const { return Triple.getOSName(); } + /// \brief Provide the default architecture name (as expected by -arch) for + /// this toolchain. Note t + std::string getDefaultUniversalArchName() const; + std::string getTripleString() const { return Triple.getTriple(); } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 0c16410..7d63bf4 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -806,7 +806,7 @@ void Driver::BuildUniversalActions(const ToolChain &TC, // When there is no explicit arch for this platform, make sure we still bind // the architecture (to the default) so that -Xarch_ is handled correctly. if (!Archs.size()) - Archs.push_back(Args.MakeArgString(TC.getArchName())); + Archs.push_back(Args.MakeArgString(TC.getDefaultUniversalArchName())); // FIXME: We killed off some others but these aren't yet detected in a // functional manner. If we added information to jobs about which "auxiliary" diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 9dcdafc..de8ed1d 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -33,6 +33,21 @@ const Driver &ToolChain::getDriver() const { return D; } +std::string ToolChain::getDefaultUniversalArchName() const { + // In universal driver terms, the arch name accepted by -arch isn't exactly + // the same as the ones that appear in the triple. Roughly speaking, this is + // an inverse of the darwin::getArchTypeForDarwinArchName() function, but the + // only interesting special case is powerpc. + switch (Triple.getArch()) { + case llvm::Triple::ppc: + return "ppc"; + case llvm::Triple::ppc64: + return "ppc64"; + default: + return Triple.getArchName(); + } +} + bool ToolChain::IsUnwindTablesDefault() const { return false; } diff --git a/clang/test/Driver/darwin-arch-default.c b/clang/test/Driver/darwin-arch-default.c new file mode 100644 index 0000000..60bf61d --- /dev/null +++ b/clang/test/Driver/darwin-arch-default.c @@ -0,0 +1,7 @@ +// Check that the name of the arch we bind is "ppc" not "powerpc". +// +// RUN: %clang -target powerpc-apple-darwin8 -### \ +// RUN: -ccc-print-phases %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-POWERPC < %t %s +// +// CHECK-POWERPC: bind-arch, "ppc"