[llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp
Reid Spencer
reid at x10sys.com
Mon Jun 5 17:00:56 PDT 2006
Changes in directory llvm/lib/Support:
ToolRunner.cpp updated: 1.50 -> 1.51
---
Log message:
Add the -Xlinker option to bugpoint which allows an option to be passed
through to gcc when its being used as a linker. This allows -L and -l
(and any other) options to be added so that non-complete bytecode files
can be processed with bugpoint. The -Xlinker option can be added as many
times as needed.
---
Diffs of the changes: (+31 -9)
ToolRunner.cpp | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
Index: llvm/lib/Support/ToolRunner.cpp
diff -u llvm/lib/Support/ToolRunner.cpp:1.50 llvm/lib/Support/ToolRunner.cpp:1.51
--- llvm/lib/Support/ToolRunner.cpp:1.50 Fri Feb 3 23:02:27 2006
+++ llvm/lib/Support/ToolRunner.cpp Mon Jun 5 19:00:42 2006
@@ -88,6 +88,7 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0);
@@ -98,12 +99,16 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs,
unsigned Timeout) {
if (!SharedLibs.empty())
throw ToolExecutionError("LLI currently does not support "
"loading shared libraries.");
+ if (!GCCArgs.empty())
+ throw ToolExecutionError("LLI currently does not support "
+ "GCC Arguments.");
std::vector<const char*> LLIArgs;
LLIArgs.push_back(LLIPath.c_str());
LLIArgs.push_back("-force-interpreter=true");
@@ -184,6 +189,7 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &ArgsForGCC,
const std::vector<std::string> &SharedLibs,
unsigned Timeout) {
@@ -191,9 +197,12 @@
OutputAsm(Bytecode, OutputAsmFile);
FileRemover OutFileRemover(OutputAsmFile);
+ std::vector<std::string> GCCArgs(ArgsForGCC);
+ GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
+
// Assuming LLC worked, compile the result with GCC and run it.
return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
- InputFile, OutputFile, SharedLibs, Timeout);
+ InputFile, OutputFile, GCCArgs, Timeout);
}
/// createLLC - Try to find the LLC executable
@@ -234,8 +243,11 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &GCCArgs =
+ std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
- std::vector<std::string>(), unsigned Timeout =0);
+ std::vector<std::string>(),
+ unsigned Timeout =0 );
};
}
@@ -243,8 +255,11 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs,
unsigned Timeout) {
+ if (!GCCArgs.empty())
+ throw ToolExecutionError("JIT does not support GCC Arguments.");
// Construct a vector of parameters, incorporating those from the command-line
std::vector<const char*> JITArgs;
JITArgs.push_back(LLIPath.c_str());
@@ -329,6 +344,7 @@
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
+ const std::vector<std::string> &ArgsForGCC,
const std::vector<std::string> &SharedLibs,
unsigned Timeout) {
sys::Path OutputCFile;
@@ -336,8 +352,10 @@
FileRemover CFileRemove(OutputCFile);
+ std::vector<std::string> GCCArgs(ArgsForGCC);
+ GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile,
- InputFile, OutputFile, SharedLibs, Timeout);
+ InputFile, OutputFile, GCCArgs, Timeout);
}
/// createCBE - Try to find the 'llc' executable
@@ -369,16 +387,12 @@
FileType fileType,
const std::string &InputFile,
const std::string &OutputFile,
- const std::vector<std::string> &SharedLibs,
- unsigned Timeout) {
+ const std::vector<std::string> &ArgsForGCC,
+ unsigned Timeout ) {
std::vector<const char*> GCCArgs;
GCCArgs.push_back(GCCPath.c_str());
- // Specify the shared libraries to link in...
- for (unsigned i = 0, e = SharedLibs.size(); i != e; ++i)
- GCCArgs.push_back(SharedLibs[i].c_str());
-
// Specify -x explicitly in case the extension is wonky
GCCArgs.push_back("-x");
if (fileType == CFile) {
@@ -395,6 +409,14 @@
sys::Path OutputBinary (ProgramFile+".gcc.exe");
OutputBinary.makeUnique();
GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
+
+ // Add any arguments intended for GCC. We locate them here because this is
+ // most likely -L and -l options that need to come before other libraries but
+ // after the source. Other options won't be sensitive to placement on the
+ // command line, so this should be safe.
+ for (unsigned i = 0, e = ArgsForGCC.size(); i != e; ++i)
+ GCCArgs.push_back(ArgsForGCC[i].c_str());
+
GCCArgs.push_back("-lm"); // Hard-code the math library...
GCCArgs.push_back("-O2"); // Optimize the program a bit...
#if defined (HAVE_LINK_R)
More information about the llvm-commits
mailing list