#include "ToolRunner.h"
#include "llvm/Config/config.h" // for HAVE_LINK_R
#include "llvm/System/Program.h"
#include "ToolRunner.h"
#include "llvm/Config/config.h" // for HAVE_LINK_R
#include "llvm/System/Program.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
#include <fstream>
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
#include <fstream>
#include <iostream>
using namespace llvm;
#include <iostream>
using namespace llvm;
+namespace {
+ cl::opt<std::string>
+ RSHHost("rsh-host",
+ cl::desc("Remote execution (rsh) host"));
+
+ cl::opt<std::string>
+ RSHUser("rsh-user",
+ cl::desc("Remote execution (rsh) user id"));
+}
+
ToolExecutionError::~ToolExecutionError() throw() { }
/// RunProgramWithTimeout - This function provides an alternate interface to the
ToolExecutionError::~ToolExecutionError() throw() { }
/// RunProgramWithTimeout - This function provides an alternate interface to the
std::vector<const char*> ProgramArgs;
std::vector<const char*> ProgramArgs;
- ProgramArgs.push_back(OutputBinary.c_str());
+ if (RSHPath.isEmpty())
+ ProgramArgs.push_back(OutputBinary.c_str());
+ else {
+ ProgramArgs.push_back(RSHPath.c_str());
+ ProgramArgs.push_back(RSHHost.c_str());
+ ProgramArgs.push_back("-l");
+ ProgramArgs.push_back(RSHUser.c_str());
+
+ char* env_pwd = getenv("PWD");
+ std::string Exec = "cd ";
+ Exec += env_pwd;
+ Exec += "; ./";
+ Exec += OutputBinary.c_str();
+ ProgramArgs.push_back(Exec.c_str());
+ }
+
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
ProgramArgs.push_back(Args[i].c_str());
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
ProgramArgs.push_back(Args[i].c_str());
);
FileRemover OutputBinaryRemover(OutputBinary);
);
FileRemover OutputBinaryRemover(OutputBinary);
- return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
- sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
- Timeout, MemoryLimit);
+
+ if (RSHPath.isEmpty())
+ return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
+ sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
+ Timeout, MemoryLimit);
+ else
+ return RunProgramWithTimeout(sys::Path(RSHPath), &ProgramArgs[0],
+ sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
+ Timeout, MemoryLimit);
}
int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
}
int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
+ sys::Path RSHPath;
+ if (!RSHHost.empty())
+ RSHPath = FindExecutable("rsh", ProgramPath);
+
Message = "Found gcc: " + GCCPath.toString() + "\n";
Message = "Found gcc: " + GCCPath.toString() + "\n";
- return new GCC(GCCPath);
+ return new GCC(GCCPath, RSHPath);
//
class GCC {
sys::Path GCCPath; // The path to the gcc executable
//
class GCC {
sys::Path GCCPath; // The path to the gcc executable
- GCC(const sys::Path &gccPath) : GCCPath(gccPath) { }
+ sys::Path RSHPath; // The path to the rsh executable
+ GCC(const sys::Path &gccPath, const sys::Path &rshPath)
+ : GCCPath(gccPath), RSHPath(rshPath) { }
public:
enum FileType { AsmFile, CFile };
public:
enum FileType { AsmFile, CFile };