[llvm-commits] [PATCH] Bugpoint/Support: Fix llvm::FindExecutable not looking for files ending with .exe

NAKAMURA Takumi geek4civic at gmail.com
Mon Aug 23 03:06:53 PDT 2010


Michael-san,
Chris-san,

An alternative patch is attached. Would you like a look into this?

I thought that patch was incomplete.
for example, assume path="c:/path/to/foo" and the executable
"c:/path/to/foo.exe" exists.

With that patch, path.canExecute() returns true.
But Win32 CreateProcess("c:/path/to/foo", ...) fails even if
"c:/path/to/foo.exe" exists.
(CreateProcess does not add suffix.exe when directory part exists)

I got succeeded to let test/BugPoint pass on mingw.


Thank you in advance, ... Takumi


ps. feel free to rewrite or modify my comments in this patch.
-------------- next part --------------
diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp
index 299032f..609c98b 100644
--- a/lib/Support/SystemUtils.cpp
+++ b/lib/Support/SystemUtils.cpp
@@ -49,6 +49,11 @@ sys::Path llvm::FindExecutable(const std::string &ExeName,
     Result.appendComponent(ExeName);
     if (Result.canExecute())
       return Result;
+    // Expect to retrieve the pathname with suffix .exe.
+    // It does not seek in PATH because Result has directory part.
+    sys::Path FoundPath = sys::Program::FindProgramByName(Result.str());
+    if (FoundPath.canExecute())
+      return FoundPath;
   }
 
   return sys::Path();


More information about the llvm-commits mailing list