diff --git a/lib/CompilerDriver/Action.cpp b/lib/CompilerDriver/Action.cpp index 0be80496a3c..3503bd39db2 100644 --- a/lib/CompilerDriver/Action.cpp +++ b/lib/CompilerDriver/Action.cpp @@ -14,6 +14,7 @@ #include "llvm/CompilerDriver/Action.h" #include "llvm/CompilerDriver/BuiltinOptions.h" #include "llvm/CompilerDriver/Error.h" +#include "llvm/CompilerDriver/Main.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/SystemUtils.h" @@ -28,7 +29,6 @@ using namespace llvmc; namespace llvmc { -extern int Main(int argc, char** argv); extern const char* ProgramName; } @@ -55,10 +55,13 @@ namespace { int ExecuteProgram (const std::string& name, const StrVector& args) { - sys::Path prog = sys::Program::FindProgramByName(name); + sys::Path prog(name); + + if (!prog.isAbsolute()) + prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main); if (prog.isEmpty()) { - prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main); + prog = sys::Program::FindProgramByName(name); if (prog.isEmpty()) { PrintError("Can't find program '" + name + "'"); return -1;