X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvmc%2FCompilerDriver.cpp;h=1a316c84390bbb471b9f35ede6495096a50257f1;hb=c30088f9612c949b047884deab045e2421690691;hp=61d0d5ac8b94d772795f8f9e852843bb39f57a99;hpb=1fce09125cb46c91407668ca29915c450a482811;p=oota-llvm.git diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index 61d0d5ac8b9..1a316c84390 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -21,6 +21,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringExtras.h" #include +#include "llvm/Config/alloca.h" using namespace llvm; @@ -28,9 +29,9 @@ namespace { void WriteAction(CompilerDriver::Action* action ) { std::cerr << action->program.c_str(); - std::vector::iterator I = action->args.begin(); + std::vector::const_iterator I = action->args.begin(); while (I != action->args.end()) { - std::cerr << " " + *I; + std::cerr << " " << *I; ++I; } std::cerr << "\n"; @@ -38,9 +39,9 @@ void WriteAction(CompilerDriver::Action* action ) { void DumpAction(CompilerDriver::Action* action) { std::cerr << "command = " << action->program.c_str(); - std::vector::iterator I = action->args.begin(); + std::vector::const_iterator I = action->args.begin(); while (I != action->args.end()) { - std::cerr << " " + *I; + std::cerr << " " << *I; ++I; } std::cerr << "\n"; @@ -190,7 +191,7 @@ private: 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"; } } @@ -392,18 +393,22 @@ private: "' 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; } @@ -530,11 +535,11 @@ public: 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. @@ -560,7 +565,7 @@ public: /// PRE-PROCESSING / TRANSLATION / OPTIMIZATION / ASSEMBLY phases // for each input item SetVector LinkageItems; - std::vector LibFiles; + StringVector LibFiles; InputList::const_iterator I = InpList.begin(); for (InputList::const_iterator I = InpList.begin(), E = InpList.end(); I != E; ++I ) { @@ -780,8 +785,9 @@ public: 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 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(); @@ -816,7 +822,7 @@ public: link->args.push_back(I->toString()); // Add in all the libraries we found. - for (std::vector::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);