[llvm-commits] [llvm] r97786 - /llvm/trunk/lib/CompilerDriver/Action.cpp

Mikhail Glushenkov foldr at codedgers.com
Thu Mar 4 20:46:28 PST 2010


Author: foldr
Date: Thu Mar  4 22:46:28 2010
New Revision: 97786

URL: http://llvm.org/viewvc/llvm-project?rev=97786&view=rev
Log:
Use FindExecutable as a fall-back search method.

Allows us to find executables that are in the same directory.

Modified:
    llvm/trunk/lib/CompilerDriver/Action.cpp

Modified: llvm/trunk/lib/CompilerDriver/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Action.cpp?rev=97786&r1=97785&r2=97786&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/Action.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Action.cpp Thu Mar  4 22:46:28 2010
@@ -15,6 +15,7 @@
 #include "llvm/CompilerDriver/BuiltinOptions.h"
 
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/SystemUtils.h"
 #include "llvm/System/Program.h"
 #include "llvm/System/TimeValue.h"
 
@@ -24,13 +25,23 @@
 using namespace llvm;
 using namespace llvmc;
 
+namespace llvmc {
+
+extern int Main(int argc, char** argv);
+extern const char* ProgramName;
+
+}
+
 namespace {
   int ExecuteProgram(const std::string& name,
                      const StrVector& args) {
     sys::Path prog = sys::Program::FindProgramByName(name);
 
-    if (prog.isEmpty())
-      throw std::runtime_error("Can't find program '" + name + "'");
+    if (prog.isEmpty()) {
+      prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main);
+      if (prog.isEmpty())
+        throw std::runtime_error("Can't find program '" + name + "'");
+    }
     if (!prog.canExecute())
       throw std::runtime_error("Program '" + name + "' is not executable.");
 





More information about the llvm-commits mailing list