summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint/ToolRunner.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-05 20:21:17 +0000
committerDan Gohman <gohman@apple.com>2009-08-05 20:21:17 +0000
commit46ffffa75013b66089cc2bba311f04141f483bcd (patch)
treed048aeca3c2e819871525d70765511a00642d449 /llvm/tools/bugpoint/ToolRunner.cpp
parent798ae47b59cb33dd7780ee2d08c86362db60988c (diff)
downloadbcm5719-llvm-46ffffa75013b66089cc2bba311f04141f483bcd.tar.gz
bcm5719-llvm-46ffffa75013b66089cc2bba311f04141f483bcd.zip
Fix FindExecutable to use sys::Path::GetMainExecutable instead of
just argv[0]. And remove the code for searching the current working directory and for searching PATH; the point of FindExecutable is not to find whatever version of the executable can be found by searching around, but to find an executable that accompanies the current executable. Update the tools to use sys::Program::FindProgramByName when they want PATH searching. llvm-svn: 78240
Diffstat (limited to 'llvm/tools/bugpoint/ToolRunner.cpp')
-rw-r--r--llvm/tools/bugpoint/ToolRunner.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/llvm/tools/bugpoint/ToolRunner.cpp b/llvm/tools/bugpoint/ToolRunner.cpp
index 9180c53557c..bce4d52c69d 100644
--- a/llvm/tools/bugpoint/ToolRunner.cpp
+++ b/llvm/tools/bugpoint/ToolRunner.cpp
@@ -228,10 +228,12 @@ int LLI::ExecuteProgram(const std::string &Bitcode,
}
// LLI create method - Try to find the LLI executable
-AbstractInterpreter *AbstractInterpreter::createLLI(const std::string &ProgPath,
+AbstractInterpreter *AbstractInterpreter::createLLI(const char *Argv0,
std::string &Message,
const std::vector<std::string> *ToolArgs) {
- std::string LLIPath = FindExecutable("lli", ProgPath).toString();
+ std::string LLIPath =
+ FindExecutable("lli", Argv0,
+ reinterpret_cast<void *>(&createLLI)).toString();
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new LLI(LLIPath, ToolArgs);
@@ -298,7 +300,6 @@ int CustomExecutor::ExecuteProgram(const std::string &Bitcode,
// Custom execution environment create method, takes the execution command
// as arguments
AbstractInterpreter *AbstractInterpreter::createCustom(
- const std::string &ProgramPath,
std::string &Message,
const std::string &ExecCommandLine) {
@@ -332,7 +333,7 @@ AbstractInterpreter *AbstractInterpreter::createCustom(
pos = ExecCommandLine.find_first_of(delimiters, lastPos);
}
- std::string CmdPath = FindExecutable(Command, ProgramPath).toString();
+ std::string CmdPath = sys::Program::FindProgramByName(Command).toString();
if (CmdPath.empty()) {
Message =
std::string("Cannot find '") + Command +
@@ -414,18 +415,20 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
/// createLLC - Try to find the LLC executable
///
-LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
+LLC *AbstractInterpreter::createLLC(const char *Argv0,
std::string &Message,
const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs) {
- std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
+ std::string LLCPath =
+ FindExecutable("llc", Argv0,
+ reinterpret_cast<void *>(&createLLC)).toString();
if (LLCPath.empty()) {
Message = "Cannot find `llc' in executable directory or PATH!\n";
return 0;
}
Message = "Found llc: " + LLCPath + "\n";
- GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
+ GCC *gcc = GCC::create(Message, GCCArgs);
if (!gcc) {
errs() << Message << "\n";
exit(1);
@@ -501,9 +504,11 @@ int JIT::ExecuteProgram(const std::string &Bitcode,
/// createJIT - Try to find the LLI executable
///
-AbstractInterpreter *AbstractInterpreter::createJIT(const std::string &ProgPath,
+AbstractInterpreter *AbstractInterpreter::createJIT(const char *Argv0,
std::string &Message, const std::vector<std::string> *Args) {
- std::string LLIPath = FindExecutable("lli", ProgPath).toString();
+ std::string LLIPath =
+ FindExecutable("lli", Argv0,
+ reinterpret_cast<void *>(&createJIT)).toString();
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new JIT(LLIPath, Args);
@@ -577,11 +582,13 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
/// createCBE - Try to find the 'llc' executable
///
-CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
+CBE *AbstractInterpreter::createCBE(const char *Argv0,
std::string &Message,
const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs) {
- sys::Path LLCPath = FindExecutable("llc", ProgramPath);
+ sys::Path LLCPath =
+ FindExecutable("llc", Argv0,
+ reinterpret_cast<void *>(&createCBE));
if (LLCPath.isEmpty()) {
Message =
"Cannot find `llc' in executable directory or PATH!\n";
@@ -589,7 +596,7 @@ CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
}
Message = "Found llc: " + LLCPath.toString() + "\n";
- GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
+ GCC *gcc = GCC::create(Message, GCCArgs);
if (!gcc) {
errs() << Message << "\n";
exit(1);
@@ -827,9 +834,9 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
/// create - Try to find the `gcc' executable
///
-GCC *GCC::create(const std::string &ProgramPath, std::string &Message,
+GCC *GCC::create(std::string &Message,
const std::vector<std::string> *Args) {
- sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
+ sys::Path GCCPath = sys::Program::FindProgramByName("gcc");
if (GCCPath.isEmpty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n";
return 0;
@@ -837,7 +844,7 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message,
sys::Path RemoteClientPath;
if (!RemoteClient.empty())
- RemoteClientPath = FindExecutable(RemoteClient.c_str(), ProgramPath);
+ RemoteClientPath = sys::Program::FindProgramByName(RemoteClient);
Message = "Found gcc: " + GCCPath.toString() + "\n";
return new GCC(GCCPath, RemoteClientPath, Args);
OpenPOWER on IntegriCloud