1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

For PR351:

* Pass sys::Path instead of std::string for paths
* Correct the types of arguments passed to RunProgramWithTimeout due to its
  interface using sys::Path instead of std::string
* Replace "/dev/null" (not portable) with empty string which
  sys::Program::ExecuteAndWait recognizes as "redirect to bit bucket"

llvm-svn: 19041
This commit is contained in:
Reid Spencer 2004-12-19 18:00:21 +00:00
parent d1b74b9f5b
commit 5b729e8d2d

View File

@ -22,7 +22,7 @@ using namespace llvm;
ToolExecutionError::~ToolExecutionError() throw() { }
static void ProcessFailure(std::string ProgPath, const char** Args) {
static void ProcessFailure(sys::Path ProgPath, const char** Args) {
std::ostringstream OS;
OS << "\nError running tool:\n ";
for (const char **Arg = Args; *Arg; ++Arg)
@ -32,8 +32,8 @@ static void ProcessFailure(std::string ProgPath, const char** Args) {
// Rerun the compiler, capturing any error messages to print them.
sys::Path ErrorFilename("error_messages");
ErrorFilename.makeUnique();
RunProgramWithTimeout(ProgPath, Args, "/dev/null", ErrorFilename.c_str(),
ErrorFilename.c_str());
RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
ErrorFilename);
// Print out the error messages generated by GCC if possible...
std::ifstream ErrorFile(ErrorFilename.c_str());
@ -102,8 +102,9 @@ int LLI::ExecuteProgram(const std::string &Bytecode,
std::cerr << " " << LLIArgs[i];
std::cerr << "\n";
);
return RunProgramWithTimeout(LLIPath, &LLIArgs[0],
InputFile, OutputFile, OutputFile, Timeout);
return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
Timeout);
}
// LLI create method - Try to find the LLI executable
@ -146,9 +147,9 @@ void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) {
std::cerr << " " << LLCArgs[i];
std::cerr << "\n";
);
if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
"/dev/null"))
ProcessFailure(LLCPath, &LLCArgs[0]);
if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0],
sys::Path(), sys::Path(), sys::Path()))
ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]);
}
void LLC::compileProgram(const std::string &Bytecode) {
@ -248,8 +249,9 @@ int JIT::ExecuteProgram(const std::string &Bytecode,
std::cerr << "\n";
);
DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
return RunProgramWithTimeout(LLIPath, &JITArgs[0],
InputFile, OutputFile, OutputFile, Timeout);
return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
Timeout);
}
/// createJIT - Try to find the LLI executable
@ -290,8 +292,8 @@ void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) {
std::cerr << " " << LLCArgs[i];
std::cerr << "\n";
);
if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
"/dev/null"))
if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(),
sys::Path()))
ProcessFailure(LLCPath, &LLCArgs[0]);
}
@ -321,14 +323,14 @@ int CBE::ExecuteProgram(const std::string &Bytecode,
CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
std::string &Message,
const std::vector<std::string> *Args) {
std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
if (LLCPath.empty()) {
sys::Path LLCPath = FindExecutable("llc", ProgramPath);
if (LLCPath.isEmpty()) {
Message =
"Cannot find `llc' in executable directory or PATH!\n";
return 0;
}
Message = "Found llc: " + LLCPath + "\n";
Message = "Found llc: " + LLCPath.toString() + "\n";
GCC *gcc = GCC::create(ProgramPath, Message);
if (!gcc) {
std::cerr << Message << "\n";
@ -376,8 +378,8 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
GCCArgs.push_back(0); // NULL terminator
std::cout << "<gcc>" << std::flush;
if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], "/dev/null", "/dev/null",
"/dev/null")) {
if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
sys::Path())) {
ProcessFailure(GCCPath, &GCCArgs[0]);
exit(1);
}
@ -398,8 +400,9 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
);
FileRemover OutputBinaryRemover(OutputBinary);
return RunProgramWithTimeout(OutputBinary.toString(), &ProgramArgs[0],
InputFile, OutputFile, OutputFile, Timeout);
return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
Timeout);
}
int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
@ -431,8 +434,8 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
};
std::cout << "<gcc>" << std::flush;
if (RunProgramWithTimeout(GCCPath, GCCArgs, "/dev/null", "/dev/null",
"/dev/null")) {
if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(),
sys::Path())) {
ProcessFailure(GCCPath, GCCArgs);
return 1;
}
@ -442,12 +445,12 @@ 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) {
std::string GCCPath = FindExecutable("gcc", ProgramPath).toString();
if (GCCPath.empty()) {
sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
if (GCCPath.isEmpty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n";
return 0;
}
Message = "Found gcc: " + GCCPath + "\n";
Message = "Found gcc: " + GCCPath.toString() + "\n";
return new GCC(GCCPath);
}