]> granicus.if.org Git - clang/commitdiff
Driver: Make sure to get the default arch name from the tool chain, not the
authorDaniel Dunbar <daniel@zuster.org>
Tue, 17 Mar 2009 21:29:52 +0000 (21:29 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 17 Mar 2009 21:29:52 +0000 (21:29 +0000)
host; the toolchain may differ based on command line arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67106 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
test/Driver/phases.c

index e809487466d9d1121e19dd619bab14c10301223f..c2df48cbc1afd91698f832d1b832feeb0783cd51 100644 (file)
@@ -155,6 +155,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
   ArgList *Args = ParseArgStrings(Start, End);
 
   Host = GetHostInfo(HostTriple);
+  // FIXME: This shouldn't live inside Driver, the default tool chain
+  // is part of the compilation (it is arg dependent).
   DefaultToolChain = Host->getToolChain(*Args);
 
   // FIXME: This behavior shouldn't be here.
@@ -306,7 +308,7 @@ void Driver::BuildUniversalActions(ArgList &Args, ActionList &Actions) const {
   // When there is no explicit arch for this platform, get one from
   // the host so that -Xarch_ is handled correctly.
   if (!Archs.size()) {
-    const char *Arch = Host->getArchName().c_str();
+    const char *Arch = DefaultToolChain->getArchName().c_str();
     Archs.push_back(Arch);
   }
 
index 139fbca1b2bd4c9da79bedfab86676a771136aca..fa34b8f6e09b7808a364e0616f0932b422842513 100644 (file)
 // RUN: grep -F '5: bind-arch, "i386", {3}, object' %t &&
 // RUN: grep -F '6: lipo, {4, 5}, object' %t &&
 
+// Arch defaulting
+// RUN: clang-driver -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s &> %t &&
+// RUN: grep -F '2: bind-arch, "i386", {1}, object' %t &&
+// RUN: clang-driver -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s -m32 -m64 &> %t &&
+// RUN: grep -F '2: bind-arch, "x86_64", {1}, object' %t &&
+// RUN: clang-driver -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s &> %t &&
+// RUN: grep -F '2: bind-arch, "x86_64", {1}, object' %t &&
+// RUN: clang-driver -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s -m64 -m32 &> %t &&
+// RUN: grep -F '2: bind-arch, "i386", {1}, object' %t &&
+
 // RUN: true