]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Transparently fallback when compiling i386 -fapple-kext code, we
authorDaniel Dunbar <daniel@zuster.org>
Fri, 18 Mar 2011 20:14:03 +0000 (20:14 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 18 Mar 2011 20:14:03 +0000 (20:14 +0000)
don't support the ABI yet.

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

lib/Driver/ToolChains.cpp
test/Driver/apple-kext-i386.cpp [new file with mode: 0644]

index 77fc0219a64a66ca433b3ed99fdf15d5936b4032..523ff14b0a58877dd304eda8f7621b1fdd0613cf 100644 (file)
@@ -172,9 +172,18 @@ std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args) const {
 Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA,
                          const ActionList &Inputs) const {
   Action::ActionClass Key;
-  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
-    Key = Action::AnalyzeJobClass;
-  else
+
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) {
+    // Fallback to llvm-gcc for i386 kext compiles, we don't support that ABI.
+    if (Inputs.size() == 1 &&
+        types::isCXX(Inputs[0]->getType()) &&
+        getTriple().getOS() == llvm::Triple::Darwin &&
+        getTriple().getArch() == llvm::Triple::x86 &&
+        C.getArgs().getLastArg(options::OPT_fapple_kext))
+      Key = JA.getKind();
+    else
+      Key = Action::AnalyzeJobClass;
+  } else
     Key = JA.getKind();
 
   // FIXME: This doesn't belong here, but ideally we will support static soon
diff --git a/test/Driver/apple-kext-i386.cpp b/test/Driver/apple-kext-i386.cpp
new file mode 100644 (file)
index 0000000..dc4e6a6
--- /dev/null
@@ -0,0 +1,9 @@
+// Check that we transparently fallback to llvm-gcc for i386 kexts, we don't
+// support the ABI they use (yet).
+
+// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN:   -fapple-kext -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK < %t %s
+
+// CHECK: cc1plus"
+// CHECK: "-fapple-kext"