- CompilerDriver CD(Provider);
-
- // Configure the driver based on options
- CD.setVerbose(Verbose);
- CD.setDebug(Debug);
- CD.setDryRun(DryRun);
- CD.setFinalPhase(FinalPhase);
- CD.setOptimization(OptLevel);
- CD.setOutputMachine(OutputMachine);
- CD.setEmitNativeCode(Native);
- CD.setEmitRawCode(EmitRawCode);
- CD.setTimeActions(TimeActions);
- CD.setTimePasses(TimePasses);
- CD.setShowStats(ShowStats);
- CD.setKeepTemporaries(KeepTemporaries);
- CD.setLibraryPaths(LibPaths);
+ CompilerDriver* CD = CompilerDriver::Get(Provider);
+
+ // If the LLVM_LIB_SEARCH_PATH environment variable is
+ // set, append it to the list of places to search for libraries
+ char *srchPath = getenv("LLVM_LIB_SEARCH_PATH");
+ if (srchPath != NULL && strlen(srchPath) != 0)
+ LibPaths.push_back(std::string(srchPath));
+
+ // Set the driver flags based on command line options
+ unsigned flags = 0;
+ if (Verbose) flags |= CompilerDriver::VERBOSE_FLAG;
+ if (Debug) flags |= CompilerDriver::DEBUG_FLAG;
+ if (DryRun) flags |= CompilerDriver::DRY_RUN_FLAG;
+ if (Native) flags |= CompilerDriver::EMIT_NATIVE_FLAG;
+ if (EmitRawCode) flags |= CompilerDriver::EMIT_RAW_FLAG;
+ if (KeepTemps) flags |= CompilerDriver::KEEP_TEMPS_FLAG;
+ if (ShowStats) flags |= CompilerDriver::SHOW_STATS_FLAG;
+ if (TimeActions) flags |= CompilerDriver::TIME_ACTIONS_FLAG;
+ if (StripOutput) flags |= CompilerDriver::STRIP_OUTPUT_FLAG;
+ CD->setDriverFlags(flags);
+
+ // Specify required parameters
+ CD->setFinalPhase(FinalPhase);
+ CD->setOptimization(OptLevel);
+ CD->setOutputMachine(OutputMachine);
+ CD->setIncludePaths(Includes);
+ CD->setSymbolDefines(Defines);
+ CD->setLibraryPaths(LibPaths);
+ CD->setfPassThrough(fOpts);
+ CD->setMPassThrough(MOpts);
+ CD->setWPassThrough(WOpts);
+
+ // Provide additional tool arguments