aboutsummaryrefslogtreecommitdiffstats
path: root/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
commit197f728d49fa0cc0baa5aadb2b905fbd8c22a81e (patch)
treedc9af5c9dde619ca176b0ad467636902011e0430 /tools/bugpoint/ToolRunner.cpp
parent7b3544ba97a31f21f24a9f923bd2a793df6d46ab (diff)
downloadexternal_llvm-197f728d49fa0cc0baa5aadb2b905fbd8c22a81e.zip
external_llvm-197f728d49fa0cc0baa5aadb2b905fbd8c22a81e.tar.gz
external_llvm-197f728d49fa0cc0baa5aadb2b905fbd8c22a81e.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/ToolRunner.cpp')
-rw-r--r--tools/bugpoint/ToolRunner.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 9180c53..bce4d52 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/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);