]> granicus.if.org Git - clang/commitdiff
Fix searching for gcc, we only want executable files.
authorMike Stump <mrs@apple.com>
Fri, 27 Mar 2009 00:40:20 +0000 (00:40 +0000)
committerMike Stump <mrs@apple.com>
Fri, 27 Mar 2009 00:40:20 +0000 (00:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67806 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
include/clang/Driver/ToolChain.h
lib/Driver/Driver.cpp
lib/Driver/ToolChain.cpp

index cb7f3b035adbf637dbe557ff9209342f3371723a..464faf8fa50947e1cd42908c42c11ab8cfcf1bf6 100644 (file)
@@ -178,8 +178,12 @@ public:
   ///
   /// \arg TC - The provided tool chain for additional information on
   /// directories to search.
+  ///
+  /// \arg WantFile - False when searching for an executable file, otherwise
+  /// true.  Defaults to false.
   // FIXME: This should be in CompilationInfo.
-  llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC) const;
+  llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC,
+                                 bool WantFile = false) const;
 
   /// HandleImmediateArgs - Handle any arguments which should be
   /// treated before building actions or binding tools.
index e85d7a7e204a5b7e39b47e531e44d206769ebc27..761b4990cb202eb65c94ac9a3d56c35a6b345e49 100644 (file)
@@ -72,7 +72,8 @@ public:
   // Helper methods
 
   llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const;
-  llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name) const;
+  llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name,
+                                 bool WantFile = false) const;
 
   // Platform defaults information
 
index 6202702f097c0403f6f6ccda4ec5e24b45d0d4b2..16e7e85ea8bb140d16148afce7b97a8f556c949b 100644 (file)
@@ -294,7 +294,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-    llvm::outs() << GetProgramPath("libgcc.a", TC).toString() << "\n";
+    llvm::outs() << GetProgramPath("libgcc.a", TC, true).toString() << "\n";
     return false;
   }
 
@@ -925,13 +925,14 @@ llvm::sys::Path Driver::GetFilePath(const char *Name,
 }
 
 llvm::sys::Path Driver::GetProgramPath(const char *Name, 
-                                       const ToolChain &TC) const {
+                                       const ToolChain &TC,
+                                       bool WantFile) const {
   const ToolChain::path_list &List = TC.getProgramPaths();
   for (ToolChain::path_list::const_iterator 
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
-    if (P.exists())
+    if (WantFile ? P.exists() : P.canExecute())
       return P;
   }
 
index aed58c94221ae3e9d04d60719916a60a5bae3416..a7f6550205327a620224e04233e26f0fadfee196 100644 (file)
@@ -30,6 +30,7 @@ llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
 }
 
 llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, 
-                                          const char *Name) const {
-  return Host.getDriver().GetProgramPath(Name, *this);
+                                          const char *Name,
+                                          bool WantFile) const {
+  return Host.getDriver().GetProgramPath(Name, *this, WantFile);
 }