[Mips] For MIPS '-fPIC -static' means to compile as -fPIC but link with
-static. So do not turn off the PIC flag if -static passed to the
driver in case of MIPS target.

http://llvm.org/bugs/show_bug.cgi?id=14693

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191947 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 2f824cb..d2ca9fb 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2139,7 +2139,13 @@
   if (KernelOrKext &&
       (!Triple.isiOS() || Triple.isOSVersionLT(6)))
     PIC = PIE = false;
-  if (Args.hasArg(options::OPT_static))
+  // Usually '-static' implies no-PIC. But for MIPS '-fPIC -static' means
+  // to compile as -fPIC but link with -static.
+  if (Args.hasArg(options::OPT_static) &&
+      getToolChain().getArch() != llvm::Triple::mips &&
+      getToolChain().getArch() != llvm::Triple::mipsel &&
+      getToolChain().getArch() != llvm::Triple::mips64 &&
+      getToolChain().getArch() != llvm::Triple::mips64el)
     PIC = PIE = false;
 
   if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {