[cfe-commits] r73555 - in /cfe/trunk: lib/Driver/HostInfo.cpp test/Driver/default-toolchain.c
Daniel Dunbar
daniel at zuster.org
Tue Jun 16 14:39:36 PDT 2009
Author: ddunbar
Date: Tue Jun 16 16:39:33 2009
New Revision: 73555
URL: http://llvm.org/viewvc/llvm-project?rev=73555&view=rev
Log:
Darwin/Driver: Also look at -arch command line options when finding the default
tool chain.
Added:
cfe/trunk/test/Driver/default-toolchain.c
Modified:
cfe/trunk/lib/Driver/HostInfo.cpp
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=73555&r1=73554&r2=73555&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Jun 16 16:39:33 2009
@@ -108,16 +108,34 @@
const char *ArchName) const {
std::string Arch;
if (!ArchName) {
- Arch = getArchName();
+ // If we aren't looking for a specific arch, infer the default architecture
+ // based on -arch and -m32/-m64 command line options.
+ if (Arg *A = Args.getLastArg(options::OPT_arch)) {
+ // The gcc driver behavior with multiple -arch flags wasn't consistent for
+ // things which rely on a default architecture. We just use the last -arch
+ // to find the default tool chain.
+ Arch = A->getValue(Args);
+
+ // Normalize arch name; we shouldn't be doing this here.
+ //
+ // FIXME: This should be unnecessary once everything moves over to using
+ // the ID based Triple interface.
+ if (Arch == "ppc")
+ Arch = "powerpc";
+ else if (Arch == "powerpc")
+ Arch = "powerpc64";
+ } else {
+ // Otherwise default to the arch of the host.
+ Arch = getArchName();
+ }
ArchName = Arch.c_str();
-
- // If no arch name is specified, infer it from the host and
- // -m32/-m64.
+
+ // Honor -m32 and -m64 when finding the default tool chain.
if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
- if (getArchName() == "i386" || getArchName() == "x86_64") {
- ArchName =
- (A->getOption().getId() == options::OPT_m32) ? "i386" : "x86_64";
- } else if (getArchName() == "powerpc" || getArchName() == "powerpc64") {
+ if (Arch == "i386" || Arch == "x86_64") {
+ ArchName = (A->getOption().getId() == options::OPT_m32) ? "i386" :
+ "x86_64";
+ } else if (Arch == "powerpc" || Arch == "powerpc64") {
ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" :
"powerpc64";
}
Added: cfe/trunk/test/Driver/default-toolchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/default-toolchain.c?rev=73555&view=auto
==============================================================================
--- cfe/trunk/test/Driver/default-toolchain.c (added)
+++ cfe/trunk/test/Driver/default-toolchain.c Tue Jun 16 16:39:33 2009
@@ -0,0 +1,5 @@
+// RUN: clang -ccc-host-triple i386-unknown-unknown -m64 -v 2> %t
+// RUN: grep 'Target: x86_64-unknown-unknown' %t &&
+
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -arch ppc -m64 -v 2> %t
+// RUN: grep 'Target: powerpc64-apple-darwin9' %t
More information about the cfe-commits
mailing list