Driver/Darwin: Catch another case where ld ends up using ld_classic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113226 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 0215cdf..24d05c1 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2209,6 +2209,16 @@
     // FIXME: This is a temporary workaround, ld should be handling this.
     bool UsesLdClassic = (getToolChain().getArch() == llvm::Triple::x86 &&
                           Args.hasArg(options::OPT_static));
+    if (getToolChain().getArch() == llvm::Triple::x86) {
+      for (arg_iterator it = Args.filtered_begin(options::OPT_Xlinker,
+                                                 options::OPT_Wl_COMMA),
+             ie = Args.filtered_end(); it != ie; ++it) {
+        const Arg *A = *it;
+        for (unsigned i = 0, e = A->getNumValues(); i != e; ++i)
+          if (llvm::StringRef(A->getValue(Args, i)) == "-kext")
+            UsesLdClassic = true;
+      }
+    }
     if (!UsesLdClassic)
       CmdArgs.push_back("-demangle");
   }