1 //===- CompilerDriver.cpp - The LLVM Compiler Driver ------------*- C++ -*-===//
4 // The LLVM Compiler Infrastructure
6 // This file was developed by Reid Spencer and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file implements the bulk of the LLVM Compiler Driver (llvmc).
13 //===------------------------------------------------------------------------===
15 #include "CompilerDriver.h"
16 #include "ConfigLexer.h"
17 #include "llvm/Module.h"
18 #include "llvm/Bytecode/Reader.h"
19 #include "llvm/Support/Timer.h"
20 #include "llvm/System/Signals.h"
21 #include "llvm/ADT/SetVector.h"
22 #include "llvm/ADT/StringExtras.h"
29 void WriteAction(CompilerDriver::Action* action ) {
30 std::cerr << action->program.c_str();
31 std::vector<std::string>::const_iterator I = action->args.begin();
32 while (I != action->args.end()) {
33 std::cerr << " " << *I;
39 void DumpAction(CompilerDriver::Action* action) {
40 std::cerr << "command = " << action->program.c_str();
41 std::vector<std::string>::const_iterator I = action->args.begin();
42 while (I != action->args.end()) {
43 std::cerr << " " << *I;
47 std::cerr << "flags = " << action->flags << "\n";
50 void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){
51 std::cerr << "Configuration Data For '" << cd->langName << "' (" << type
53 std::cerr << "PreProcessor: ";
54 DumpAction(&cd->PreProcessor);
55 std::cerr << "Translator: ";
56 DumpAction(&cd->Translator);
57 std::cerr << "Optimizer: ";
58 DumpAction(&cd->Optimizer);
59 std::cerr << "Assembler: ";
60 DumpAction(&cd->Assembler);
61 std::cerr << "Linker: ";
62 DumpAction(&cd->Linker);
65 /// This specifies the passes to run for OPT_FAST_COMPILE (-O1)
66 /// which should reduce the volume of code and make compilation
67 /// faster. This is also safe on any llvm module.
68 static const char* DefaultFastCompileOptimizations[] = {
69 "-simplifycfg", "-mem2reg", "-instcombine"
72 class CompilerDriverImpl : public CompilerDriver {
73 /// @name Constructors
76 CompilerDriverImpl(ConfigDataProvider& confDatProv )
79 , optLevel(OPT_FAST_COMPILE)
86 TempDir = sys::Path::GetTemporaryDirectory();
87 sys::RemoveDirectoryOnSignal(TempDir);
88 AdditionalArgs.reserve(NUM_PHASES);
89 StringVector emptyVec;
90 for (unsigned i = 0; i < NUM_PHASES; ++i)
91 AdditionalArgs.push_back(emptyVec);
94 virtual ~CompilerDriverImpl() {
101 AdditionalArgs.clear();
111 virtual void setFinalPhase( Phases phase ) {
115 virtual void setOptimization( OptimizationLevels level ) {
119 virtual void setDriverFlags( unsigned flags ) {
120 Flags = flags & DRIVER_FLAGS_MASK;
123 virtual void setOutputMachine( const std::string& machineName ) {
124 machine = machineName;
127 virtual void setPhaseArgs(Phases phase, const StringVector& opts) {
128 assert(phase <= LINKING && phase >= PREPROCESSING);
129 AdditionalArgs[phase] = opts;
132 virtual void setIncludePaths(const StringVector& paths) {
133 StringVector::const_iterator I = paths.begin();
134 StringVector::const_iterator E = paths.end();
137 tmp.setDirectory(*I);
138 IncludePaths.push_back(tmp);
143 virtual void setSymbolDefines(const StringVector& defs) {
147 virtual void setLibraryPaths(const StringVector& paths) {
148 StringVector::const_iterator I = paths.begin();
149 StringVector::const_iterator E = paths.end();
152 tmp.setDirectory(*I);
153 LibraryPaths.push_back(tmp);
158 virtual void addLibraryPath( const sys::Path& libPath ) {
159 LibraryPaths.push_back(libPath);
162 virtual void addToolPath( const sys::Path& toolPath ) {
163 ToolPaths.push_back(toolPath);
166 virtual void setfPassThrough(const StringVector& fOpts) {
170 /// @brief Set the list of -M options to be passed through
171 virtual void setMPassThrough(const StringVector& MOpts) {
175 /// @brief Set the list of -W options to be passed through
176 virtual void setWPassThrough(const StringVector& WOpts) {
184 bool isSet(DriverFlags flag) {
185 return 0 != ((flag & DRIVER_FLAGS_MASK) & Flags);
189 if (!isSet(KEEP_TEMPS_FLAG)) {
190 if (TempDir.isDirectory() && TempDir.writable())
191 TempDir.destroyDirectory(/*remove_contents=*/true);
193 std::cout << "Temporary files are in " << TempDir << "\n";
197 sys::Path MakeTempFile(const std::string& basename,
198 const std::string& suffix ) {
199 sys::Path result(TempDir);
200 if (!result.appendFile(basename))
201 throw basename + ": can't use this file name";
202 if (!result.appendSuffix(suffix))
203 throw suffix + ": can't use this file suffix";
207 Action* GetAction(ConfigData* cd,
208 const sys::Path& input,
209 const sys::Path& output,
212 Action* pat = 0; ///< The pattern/template for the action
213 Action* action = new Action; ///< The actual action to execute
215 // Get the action pattern
217 case PREPROCESSING: pat = &cd->PreProcessor; break;
218 case TRANSLATION: pat = &cd->Translator; break;
219 case OPTIMIZATION: pat = &cd->Optimizer; break;
220 case ASSEMBLY: pat = &cd->Assembler; break;
221 case LINKING: pat = &cd->Linker; break;
223 assert(!"Invalid driver phase!");
226 assert(pat != 0 && "Invalid command pattern");
228 // Copy over some pattern things that don't need to change
229 action->program = pat->program;
230 action->flags = pat->flags;
232 // Do the substitutions from the pattern to the actual
233 StringVector::iterator PI = pat->args.begin();
234 StringVector::iterator PE = pat->args.end();
236 if ((*PI)[0] == '%' && PI->length() >2) {
240 if (*PI == "%args%") {
241 if (AdditionalArgs.size() > unsigned(phase))
242 if (!AdditionalArgs[phase].empty()) {
243 // Get specific options for each kind of action type
244 StringVector& addargs = AdditionalArgs[phase];
245 // Add specific options for each kind of action type
246 action->args.insert(action->args.end(), addargs.begin(),
253 if (*PI == "%defs%") {
254 StringVector::iterator I = Defines.begin();
255 StringVector::iterator E = Defines.end();
257 action->args.push_back( std::string("-D") + *I);
264 if (*PI == "%fOpts%") {
265 if (!fOptions.empty())
266 action->args.insert(action->args.end(), fOptions.begin(),
273 action->args.push_back(input.toString());
274 } else if (*PI == "%incls%") {
275 PathVector::iterator I = IncludePaths.begin();
276 PathVector::iterator E = IncludePaths.end();
278 action->args.push_back( std::string("-I") + I->toString() );
285 if (*PI == "%libs%") {
286 PathVector::iterator I = LibraryPaths.begin();
287 PathVector::iterator E = LibraryPaths.end();
289 action->args.push_back( std::string("-L") + I->toString() );
296 if (*PI == "%out%") {
297 action->args.push_back(output.toString());
298 } else if (*PI == "%opt%") {
299 if (!isSet(EMIT_RAW_FLAG)) {
300 if (cd->opts.size() > static_cast<unsigned>(optLevel) &&
301 !cd->opts[optLevel].empty())
302 action->args.insert(action->args.end(),
303 cd->opts[optLevel].begin(),
304 cd->opts[optLevel].end());
306 throw std::string("Optimization options for level ") +
307 utostr(unsigned(optLevel)) + " were not specified";
313 if (*PI == "%stats%") {
314 if (isSet(SHOW_STATS_FLAG))
315 action->args.push_back("-stats");
320 if (*PI == "%target%") {
321 action->args.push_back(std::string("-march=") + machine);
322 } else if (*PI == "%time%") {
323 if (isSet(TIME_PASSES_FLAG))
324 action->args.push_back("-time-passes");
329 if (*PI == "%verbose%") {
330 if (isSet(VERBOSE_FLAG))
331 action->args.push_back("-v");
336 if (*PI == "%Mopts%") {
337 if (!MOptions.empty())
338 action->args.insert(action->args.end(), MOptions.begin(),
344 if (*PI == "%Wopts%") {
345 for (StringVector::iterator I = WOptions.begin(),
346 E = WOptions.end(); I != E ; ++I ) {
347 action->args.push_back( std::string("-W") + *I );
357 // Did it even look like a substitution?
358 if (PI->length()>1 && (*PI)[0] == '%' &&
359 (*PI)[PI->length()-1] == '%') {
360 throw std::string("Invalid substitution token: '") + *PI +
361 "' for command '" + pat->program.toString() + "'";
362 } else if (!PI->empty()) {
363 // It's not a legal substitution, just pass it through
364 action->args.push_back(*PI);
367 } else if (!PI->empty()) {
368 // Its not a substitution, just put it in the action
369 action->args.push_back(*PI);
374 // Finally, we're done
378 bool DoAction(Action*action) {
379 assert(action != 0 && "Invalid Action!");
380 if (isSet(VERBOSE_FLAG))
382 if (!isSet(DRY_RUN_FLAG)) {
383 sys::Path progpath = sys::Program::FindProgramByName(
384 action->program.toString());
385 if (progpath.isEmpty())
386 throw std::string("Can't find program '" +
387 action->program.toString()+"'");
388 else if (progpath.executable())
389 action->program = progpath;
391 throw std::string("Program '"+action->program.toString()+
392 "' is not executable.");
394 // Invoke the program
395 const char** Args = (const char**)
396 alloca(sizeof(const char*)*action->args.size());
397 for (unsigned i = 0; i != action->args.size(); ++i) {
398 Args[i] = action->args[i].c_str();
400 if (isSet(TIME_ACTIONS_FLAG)) {
401 Timer timer(action->program.toString());
404 sys::Program::ExecuteAndWait(action->program,Args);
406 timer.print(timer,std::cerr);
407 return resultCode == 0;
411 sys::Program::ExecuteAndWait(action->program, Args);
416 /// This method tries various variants of a linkage item's file
417 /// name to see if it can find an appropriate file to link with
418 /// in the directories of the LibraryPaths.
419 llvm::sys::Path GetPathForLinkageItem(const std::string& link_item,
420 bool native = false) {
422 fullpath.setFile(link_item);
423 if (fullpath.readable())
425 for (PathVector::iterator PI = LibraryPaths.begin(),
426 PE = LibraryPaths.end(); PI != PE; ++PI) {
427 fullpath.setDirectory(PI->toString());
428 fullpath.appendFile(link_item);
429 if (fullpath.readable())
432 fullpath.appendSuffix("a");
434 fullpath.appendSuffix("bc");
435 if (fullpath.readable())
437 fullpath.elideSuffix();
438 fullpath.appendSuffix("o");
439 if (fullpath.readable())
442 fullpath.appendFile(std::string("lib") + link_item);
443 fullpath.appendSuffix("a");
444 if (fullpath.readable())
446 fullpath.elideSuffix();
447 fullpath.appendSuffix("so");
448 if (fullpath.readable())
458 /// This method processes a linkage item. The item could be a
459 /// Bytecode file needing translation to native code and that is
460 /// dependent on other bytecode libraries, or a native code
461 /// library that should just be linked into the program.
462 bool ProcessLinkageItem(const llvm::sys::Path& link_item,
463 SetVector<sys::Path>& set,
465 // First, see if the unadorned file name is not readable. If so,
466 // we must track down the file in the lib search path.
468 if (!link_item.readable()) {
469 // look for the library using the -L arguments specified
470 // on the command line.
471 fullpath = GetPathForLinkageItem(link_item.toString());
473 // If we didn't find the file in any of the library search paths
474 // we have to bail. No where else to look.
475 if (fullpath.isEmpty()) {
477 std::string("Can't find linkage item '") + link_item.toString() + "'";
481 fullpath = link_item;
484 // If we got here fullpath is the path to the file, and its readable.
485 set.insert(fullpath);
487 // If its an LLVM bytecode file ...
488 if (fullpath.isBytecodeFile()) {
489 // Process the dependent libraries recursively
490 Module::LibraryListType modlibs;
491 if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs)) {
492 // Traverse the dependent libraries list
493 Module::lib_iterator LI = modlibs.begin();
494 Module::lib_iterator LE = modlibs.end();
496 if (!ProcessLinkageItem(sys::Path(*LI),set,err)) {
498 err = std::string("Library '") + *LI +
499 "' is not valid for linking but is required by file '" +
500 fullpath.toString() + "'";
502 err += " which is required by file '" + fullpath.toString() + "'";
508 } else if (err.empty()) {
510 "The dependent libraries could not be extracted from '") +
522 virtual int execute(const InputList& InpList, const sys::Path& Output ) {
524 // Echo the configuration of options if we're running verbose
525 if (isSet(DEBUG_FLAG)) {
526 std::cerr << "Compiler Driver Options:\n";
527 std::cerr << "DryRun = " << isSet(DRY_RUN_FLAG) << "\n";
528 std::cerr << "Verbose = " << isSet(VERBOSE_FLAG) << " \n";
529 std::cerr << "TimeActions = " << isSet(TIME_ACTIONS_FLAG) << "\n";
530 std::cerr << "TimePasses = " << isSet(TIME_PASSES_FLAG) << "\n";
531 std::cerr << "ShowStats = " << isSet(SHOW_STATS_FLAG) << "\n";
532 std::cerr << "EmitRawCode = " << isSet(EMIT_RAW_FLAG) << "\n";
533 std::cerr << "EmitNativeCode = " << isSet(EMIT_NATIVE_FLAG) << "\n";
534 std::cerr << "KeepTemps = " << isSet(KEEP_TEMPS_FLAG) << "\n";
535 std::cerr << "OutputMachine = " << machine << "\n";
536 InputList::const_iterator I = InpList.begin();
537 while ( I != InpList.end() ) {
538 std::cerr << "Input: " << I->first << "(" << I->second
542 std::cerr << "Output: " << Output << "\n";
545 // If there's no input, we're done.
547 throw std::string("Nothing to compile.");
549 // If they are asking for linking and didn't provide an output
550 // file then its an error (no way for us to "make up" a meaningful
551 // file name based on the various linker input files).
552 if (finalPhase == LINKING && Output.isEmpty())
554 "An output file name must be specified for linker output");
556 // If they are not asking for linking, provided an output file and
557 // there is more than one input file, its an error
558 if (finalPhase != LINKING && !Output.isEmpty() && InpList.size() > 1)
559 throw std::string("An output file name cannot be specified ") +
560 "with more than one input file name when not linking";
562 // This vector holds all the resulting actions of the following loop.
563 std::vector<Action*> actions;
565 /// PRE-PROCESSING / TRANSLATION / OPTIMIZATION / ASSEMBLY phases
566 // for each input item
567 SetVector<sys::Path> LinkageItems;
568 StringVector LibFiles;
569 InputList::const_iterator I = InpList.begin();
570 for (InputList::const_iterator I = InpList.begin(), E = InpList.end();
572 // Get the suffix of the file name
573 const std::string& ftype = I->second;
575 // If its a library, bytecode file, or object file, save
576 // it for linking below and short circuit the
577 // pre-processing/translation/assembly phases
578 if (ftype.empty() || ftype == "o" || ftype == "bc" || ftype=="a") {
579 // We shouldn't get any of these types of files unless we're
580 // later going to link. Enforce this limit now.
581 if (finalPhase != LINKING) {
583 "Pre-compiled objects found but linking not requested");
586 LibFiles.push_back(I->first.toString());
588 LinkageItems.insert(I->first);
589 continue; // short circuit remainder of loop
592 // At this point, we know its something we need to translate
593 // and/or optimize. See if we can get the configuration data
594 // for this kind of file.
595 ConfigData* cd = cdp->ProvideConfigData(I->second);
597 throw std::string("Files of type '") + I->second +
598 "' are not recognized.";
599 if (isSet(DEBUG_FLAG))
600 DumpConfigData(cd,I->second);
602 // Add the config data's library paths to the end of the list
603 for (StringVector::iterator LPI = cd->libpaths.begin(),
604 LPE = cd->libpaths.end(); LPI != LPE; ++LPI){
605 LibraryPaths.push_back(sys::Path(*LPI));
608 // Initialize the input and output files
609 sys::Path InFile(I->first);
610 sys::Path OutFile(I->first.getBasename());
612 // PRE-PROCESSING PHASE
613 Action& action = cd->PreProcessor;
615 // Get the preprocessing action, if needed, or error if appropriate
616 if (!action.program.isEmpty()) {
617 if (action.isSet(REQUIRED_FLAG) || finalPhase == PREPROCESSING) {
618 if (finalPhase == PREPROCESSING) {
619 if (Output.isEmpty()) {
620 OutFile.appendSuffix("E");
621 actions.push_back(GetAction(cd,InFile,OutFile,PREPROCESSING));
623 actions.push_back(GetAction(cd,InFile,Output,PREPROCESSING));
626 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"E"));
627 actions.push_back(GetAction(cd,InFile,TempFile,
632 } else if (finalPhase == PREPROCESSING) {
633 throw cd->langName + " does not support pre-processing";
634 } else if (action.isSet(REQUIRED_FLAG)) {
635 throw std::string("Don't know how to pre-process ") +
636 cd->langName + " files";
639 // Short-circuit remaining actions if all they want is
641 if (finalPhase == PREPROCESSING) { continue; };
643 /// TRANSLATION PHASE
644 action = cd->Translator;
646 // Get the translation action, if needed, or error if appropriate
647 if (!action.program.isEmpty()) {
648 if (action.isSet(REQUIRED_FLAG) || finalPhase == TRANSLATION) {
649 if (finalPhase == TRANSLATION) {
650 if (Output.isEmpty()) {
651 OutFile.appendSuffix("o");
652 actions.push_back(GetAction(cd,InFile,OutFile,TRANSLATION));
654 actions.push_back(GetAction(cd,InFile,Output,TRANSLATION));
657 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans"));
658 actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION));
663 if (action.isSet(OUTPUT_IS_ASM_FLAG)) {
664 /// The output of the translator is an LLVM Assembly program
665 /// We need to translate it to bytecode
666 Action* action = new Action();
667 action->program.setFile("llvm-as");
668 action->args.push_back(InFile.toString());
669 action->args.push_back("-o");
670 InFile.appendSuffix("bc");
671 action->args.push_back(InFile.toString());
672 actions.push_back(action);
675 } else if (finalPhase == TRANSLATION) {
676 throw cd->langName + " does not support translation";
677 } else if (action.isSet(REQUIRED_FLAG)) {
678 throw std::string("Don't know how to translate ") +
679 cd->langName + " files";
682 // Short-circuit remaining actions if all they want is translation
683 if (finalPhase == TRANSLATION) { continue; }
685 /// OPTIMIZATION PHASE
686 action = cd->Optimizer;
688 // Get the optimization action, if needed, or error if appropriate
689 if (!isSet(EMIT_RAW_FLAG)) {
690 if (!action.program.isEmpty()) {
691 if (action.isSet(REQUIRED_FLAG) || finalPhase == OPTIMIZATION) {
692 if (finalPhase == OPTIMIZATION) {
693 if (Output.isEmpty()) {
694 OutFile.appendSuffix("o");
695 actions.push_back(GetAction(cd,InFile,OutFile,OPTIMIZATION));
697 actions.push_back(GetAction(cd,InFile,Output,OPTIMIZATION));
700 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"opt"));
701 actions.push_back(GetAction(cd,InFile,TempFile,OPTIMIZATION));
705 if (action.isSet(OUTPUT_IS_ASM_FLAG)) {
706 /// The output of the optimizer is an LLVM Assembly program
707 /// We need to translate it to bytecode with llvm-as
708 Action* action = new Action();
709 action->program.setFile("llvm-as");
710 action->args.push_back(InFile.toString());
711 action->args.push_back("-f");
712 action->args.push_back("-o");
713 InFile.appendSuffix("bc");
714 action->args.push_back(InFile.toString());
715 actions.push_back(action);
718 } else if (finalPhase == OPTIMIZATION) {
719 throw cd->langName + " does not support optimization";
720 } else if (action.isSet(REQUIRED_FLAG)) {
721 throw std::string("Don't know how to optimize ") +
722 cd->langName + " files";
726 // Short-circuit remaining actions if all they want is optimization
727 if (finalPhase == OPTIMIZATION) { continue; }
730 action = cd->Assembler;
732 if (finalPhase == ASSEMBLY) {
734 // Build either a native compilation action or a disassembly action
735 Action* action = new Action();
736 if (isSet(EMIT_NATIVE_FLAG)) {
737 // Use llc to get the native assembly file
738 action->program.setFile("llc");
739 action->args.push_back(InFile.toString());
740 action->args.push_back("-f");
741 action->args.push_back("-o");
742 if (Output.isEmpty()) {
743 OutFile.appendSuffix("o");
744 action->args.push_back(OutFile.toString());
746 action->args.push_back(Output.toString());
748 actions.push_back(action);
750 // Just convert back to llvm assembly with llvm-dis
751 action->program.setFile("llvm-dis");
752 action->args.push_back(InFile.toString());
753 action->args.push_back("-f");
754 action->args.push_back("-o");
755 if (Output.isEmpty()) {
756 OutFile.appendSuffix("ll");
757 action->args.push_back(OutFile.toString());
759 action->args.push_back(Output.toString());
763 // Put the action on the list
764 actions.push_back(action);
766 // Short circuit the rest of the loop, we don't want to link
770 // Register the result of the actions as a link candidate
771 LinkageItems.insert(InFile);
773 } // end while loop over each input file
775 /// RUN THE COMPILATION ACTIONS
776 std::vector<Action*>::iterator AI = actions.begin();
777 std::vector<Action*>::iterator AE = actions.end();
780 throw std::string("Action failed");
785 if (finalPhase == LINKING) {
787 // Insert the platform-specific system libraries to the path list
788 std::vector<sys::Path> SysLibs;
789 sys::Path::GetSystemLibraryPaths(SysLibs);
790 LibraryPaths.insert(LibraryPaths.end(), SysLibs.begin(), SysLibs.end());
792 // Set up the linking action with llvm-ld
793 Action* link = new Action();
794 link->program.setFile("llvm-ld");
796 // Add in the optimization level requested
798 case OPT_FAST_COMPILE:
799 link->args.push_back("-O1");
802 link->args.push_back("-O2");
805 link->args.push_back("-O3");
808 link->args.push_back("-O4");
810 case OPT_AGGRESSIVE_LINK_TIME:
811 link->args.push_back("-O5");
817 // Add in all the linkage items we generated. This includes the
818 // output from the translation/optimization phases as well as any
819 // -l arguments specified.
820 for (PathVector::const_iterator I=LinkageItems.begin(),
821 E=LinkageItems.end(); I != E; ++I )
822 link->args.push_back(I->toString());
824 // Add in all the libraries we found.
825 for (StringVector::const_iterator I=LibFiles.begin(),
826 E=LibFiles.end(); I != E; ++I )
827 link->args.push_back(std::string("-l")+*I);
829 // Add in all the library paths to the command line
830 for (PathVector::const_iterator I=LibraryPaths.begin(),
831 E=LibraryPaths.end(); I != E; ++I)
832 link->args.push_back( std::string("-L") + I->toString());
834 // Add in the additional linker arguments requested
835 for (StringVector::const_iterator I=AdditionalArgs[LINKING].begin(),
836 E=AdditionalArgs[LINKING].end(); I != E; ++I)
837 link->args.push_back( *I );
839 // Add in other optional flags
840 if (isSet(EMIT_NATIVE_FLAG))
841 link->args.push_back("-native");
842 if (isSet(VERBOSE_FLAG))
843 link->args.push_back("-v");
844 if (isSet(TIME_PASSES_FLAG))
845 link->args.push_back("-time-passes");
846 if (isSet(SHOW_STATS_FLAG))
847 link->args.push_back("-stats");
848 if (isSet(STRIP_OUTPUT_FLAG))
849 link->args.push_back("-s");
850 if (isSet(DEBUG_FLAG)) {
851 link->args.push_back("-debug");
852 link->args.push_back("-debug-pass=Details");
855 // Add in mandatory flags
856 link->args.push_back("-o");
857 link->args.push_back(Output.toString());
861 throw std::string("Action failed");
863 } catch (std::string& msg) {
868 throw std::string("Unspecified error");
878 ConfigDataProvider* cdp; ///< Where we get configuration data from
879 Phases finalPhase; ///< The final phase of compilation
880 OptimizationLevels optLevel; ///< The optimization level to apply
881 unsigned Flags; ///< The driver flags
882 std::string machine; ///< Target machine name
883 PathVector LibraryPaths; ///< -L options
884 PathVector IncludePaths; ///< -I options
885 PathVector ToolPaths; ///< -B options
886 StringVector Defines; ///< -D options
887 sys::Path TempDir; ///< Name of the temporary directory.
888 StringTable AdditionalArgs; ///< The -Txyz options
889 StringVector fOptions; ///< -f options
890 StringVector MOptions; ///< -M options
891 StringVector WOptions; ///< -W options
897 CompilerDriver::~CompilerDriver() {
901 CompilerDriver::Get(ConfigDataProvider& CDP) {
902 return new CompilerDriverImpl(CDP);
905 CompilerDriver::ConfigData::ConfigData()
913 StringVector emptyVec;
914 for (unsigned i = 0; i < NUM_PHASES; ++i)
915 opts.push_back(emptyVec);
918 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab