[PATCH] D15006: Driver: Better detection of mingw-gcc

Martell Malone via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 25 21:26:35 PST 2015


martell created this revision.
martell added a reviewer: yaron.keren.
martell added a subscriber: cfe-commits.

As discussed after r253898 here is the better gcc detection.

Note: I could add a break in the new for loop but I don't feel it is needed

Thoughts?


http://reviews.llvm.org/D15006

Files:
  lib/Driver/MinGWToolChain.cpp

Index: lib/Driver/MinGWToolChain.cpp
===================================================================
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -66,15 +66,22 @@
     : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
+  llvm::SmallVector<llvm::SmallString<32>, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+
+  for (StringRef CandidateGcc : Gccs)
+    if (llvm::ErrorOr<std::string> GPPName =
+          llvm::sys::findProgramByName(CandidateGcc)) {
+      Base = llvm::sys::path::parent_path(
+          llvm::sys::path::parent_path(GPPName.get()));
+      break;
+    }
+
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr<std::string> GPPName =
-               llvm::sys::findProgramByName("gcc"))
-    Base = llvm::sys::path::parent_path(
-        llvm::sys::path::parent_path(GPPName.get()));
-#endif
+    Base = getDriver().SysRoot;
+
   if (!Base.size())
     Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15006.41207.patch
Type: text/x-patch
Size: 1231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151126/91950258/attachment.bin>


More information about the cfe-commits mailing list