#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include <iostream>
+#include "llvm/Config/alloca.h"
using namespace llvm;
void WriteAction(CompilerDriver::Action* action ) {
std::cerr << action->program.c_str();
- std::vector<std::string>::iterator I = action->args.begin();
+ std::vector<std::string>::const_iterator I = action->args.begin();
while (I != action->args.end()) {
- std::cerr << " " + *I;
+ std::cerr << " " << *I;
++I;
}
std::cerr << "\n";
void DumpAction(CompilerDriver::Action* action) {
std::cerr << "command = " << action->program.c_str();
- std::vector<std::string>::iterator I = action->args.begin();
+ std::vector<std::string>::const_iterator I = action->args.begin();
while (I != action->args.end()) {
- std::cerr << " " + *I;
+ std::cerr << " " << *I;
++I;
}
std::cerr << "\n";
if (TempDir.isDirectory() && TempDir.writable())
TempDir.destroyDirectory(/*remove_contents=*/true);
} else {
- std::cout << "Temporary files are in " << TempDir.toString() << "\n";
+ std::cout << "Temporary files are in " << TempDir << "\n";
}
}
"' is not executable.");
// Invoke the program
+ const char** Args = (const char**)
+ alloca(sizeof(const char*)*(action->args.size()+2));
+ Args[0] = action->program.toString().c_str();
+ for (unsigned i = 1; i != action->args.size(); ++i)
+ Args[i] = action->args[i].c_str();
+ Args[action->args.size()] = 0; // null terminate list.
if (isSet(TIME_ACTIONS_FLAG)) {
Timer timer(action->program.toString());
timer.startTimer();
- int resultCode =
- sys::Program::ExecuteAndWait(action->program,action->args);
+ int resultCode = sys::Program::ExecuteAndWait(action->program, Args);
timer.stopTimer();
timer.print(timer,std::cerr);
return resultCode == 0;
}
else
- return 0 ==
- sys::Program::ExecuteAndWait(action->program, action->args);
+ return 0 == sys::Program::ExecuteAndWait(action->program, Args);
}
return true;
}
std::cerr << "OutputMachine = " << machine << "\n";
InputList::const_iterator I = InpList.begin();
while ( I != InpList.end() ) {
- std::cerr << "Input: " << I->first.toString() << "(" << I->second
+ std::cerr << "Input: " << I->first << "(" << I->second
<< ")\n";
++I;
}
- std::cerr << "Output: " << Output.toString() << "\n";
+ std::cerr << "Output: " << Output << "\n";
}
// If there's no input, we're done.
/// PRE-PROCESSING / TRANSLATION / OPTIMIZATION / ASSEMBLY phases
// for each input item
SetVector<sys::Path> LinkageItems;
- std::vector<std::string> LibFiles;
+ StringVector LibFiles;
InputList::const_iterator I = InpList.begin();
for (InputList::const_iterator I = InpList.begin(), E = InpList.end();
I != E; ++I ) {
if (finalPhase == LINKING) {
// Insert the platform-specific system libraries to the path list
- LibraryPaths.push_back(sys::Path::GetSystemLibraryPath1());
- LibraryPaths.push_back(sys::Path::GetSystemLibraryPath2());
+ std::vector<sys::Path> SysLibs;
+ sys::Path::GetSystemLibraryPaths(SysLibs);
+ LibraryPaths.insert(LibraryPaths.end(), SysLibs.begin(), SysLibs.end());
// Set up the linking action with llvm-ld
Action* link = new Action();
link->args.push_back(I->toString());
// Add in all the libraries we found.
- for (std::vector<std::string>::const_iterator I=LibFiles.begin(),
+ for (StringVector::const_iterator I=LibFiles.begin(),
E=LibFiles.end(); I != E; ++I )
link->args.push_back(std::string("-l")+*I);