//===------------------------------------------------------------------------===
//=== PHASE OPTIONS
//===------------------------------------------------------------------------===
-cl::opt<CompilerDriver::Phases> FinalPhase(
+cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional,
cl::desc("Choose final phase of compilation:"),
cl::init(CompilerDriver::LINKING),
cl::values(
//===------------------------------------------------------------------------===
//=== OPTIMIZATION OPTIONS
//===------------------------------------------------------------------------===
-cl::opt<CompilerDriver::OptimizationLevels> OptLevel(
+cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore,
cl::desc("Choose level of optimization to apply:"),
cl::init(CompilerDriver::OPT_FAST_COMPILE),
cl::values(
cl::desc("Pass specific options to the pre-processor"),
cl::value_desc("option"));
+cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore,
+ cl::desc("Alias for -Tpre"), cl::aliasopt(PreprocessorToolOpts));
+
cl::list<std::string> TranslatorToolOpts("Ttrn", cl::ZeroOrMore,
cl::desc("Pass specific options to the assembler"),
cl::value_desc("option"));
cl::desc("Pass specific options to the assembler"),
cl::value_desc("option"));
+cl::alias AssemblerToolOptsAlias("Wa,", cl::ZeroOrMore,
+ cl::desc("Alias for -Tasm"), cl::aliasopt(AssemblerToolOpts));
+
cl::list<std::string> OptimizerToolOpts("Topt", cl::ZeroOrMore,
cl::desc("Pass specific options to the optimizer"),
cl::value_desc("option"));
cl::desc("Pass specific options to the linker"),
cl::value_desc("option"));
+cl::alias LinkerToolOptsAlias("Wl,", cl::ZeroOrMore,
+ cl::desc("Alias for -Tlnk"), cl::aliasopt(LinkerToolOpts));
+
cl::list<std::string> fOpts("f", cl::ZeroOrMore, cl::Prefix,
cl::desc("Pass through -f options to compiler tools"),
cl::value_desc("optimization option"));
cl::desc("Pass through -W options to compiler tools"),
cl::value_desc("warnings category"));
+cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix,
+ cl::desc("Indicate where llvmc sub-tools are installed"),
+ cl::value_desc("directory path containing bin and lib directories"));
+
//===------------------------------------------------------------------------===
//=== INPUT OPTIONS
//===------------------------------------------------------------------------===
cl::list<std::string> LibPaths("L", cl::Prefix,
cl::desc("Specify a library search path"), cl::value_desc("directory"));
-
+
cl::list<std::string> Libraries("l", cl::Prefix,
cl::desc("Specify libraries to link to"), cl::value_desc("library prefix"));
cl::desc("Specify a symbol to define for source configuration"),
cl::value_desc("symbol definition"));
-
//===------------------------------------------------------------------------===
//=== OUTPUT OPTIONS
//===------------------------------------------------------------------------===
cl::opt<std::string> OutputFilename("o",
cl::desc("Override output filename"), cl::value_desc("filename"));
-cl::opt<bool> ForceOutput("F", cl::Optional, cl::init(false),
- cl::desc("Force output files to be overridden"));
-
cl::opt<std::string> OutputMachine("m", cl::Prefix,
cl::desc("Specify a target machine"), cl::value_desc("machine"));
-
+
cl::opt<bool> Native("native", cl::init(false),
cl::desc("Generative native object and executables instead of bytecode"));
cl::opt<bool> StripOutput("strip", cl::init(false),
cl::desc("Strip all symbols from linked output file"));
+cl::opt<std::string> PrintFileName("print-file-name", cl::Optional,
+ cl::value_desc("filename"),
+ cl::desc("Print the full path for the option's value"));
+
//===------------------------------------------------------------------------===
//=== INFORMATION OPTIONS
//===------------------------------------------------------------------------===
//=== POSITIONAL OPTIONS
//===------------------------------------------------------------------------===
-static cl::list<std::string> Files(cl::Positional, cl::OneOrMore,
+static cl::list<std::string> Files(cl::Positional, cl::ZeroOrMore,
cl::desc("[Sources/objects/libraries]"));
static cl::list<std::string> Languages("x", cl::ZeroOrMore,
} // end anonymous namespace
+void handleTerminatingOptions(CompilerDriver* CD) {
+ if (!PrintFileName.empty()) {
+ sys::Path path = CD->GetPathForLinkageItem(PrintFileName,false);
+ std::string p = path.toString();
+ if (p.empty())
+ std::cout << "Can't locate '" << PrintFileName << "'.\n";
+ else
+ std::cout << p << "\n";
+ exit(0);
+ }
+}
/// @brief The main program for llvmc
int main(int argc, char **argv) {
if (OutputFilename.empty())
if (OptLevel == CompilerDriver::LINKING)
OutputFilename = "a.out";
- else
- throw std::string("An output file must be specified. Please use the -o option");
// Construct the ConfigDataProvider object
LLVMC_ConfigDataProvider Provider;
if (Verbose) flags |= CompilerDriver::VERBOSE_FLAG;
if (Debug) flags |= CompilerDriver::DEBUG_FLAG;
if (DryRun) flags |= CompilerDriver::DRY_RUN_FLAG;
- if (ForceOutput) flags |= CompilerDriver::FORCE_FLAG;
if (Native) flags |= CompilerDriver::EMIT_NATIVE_FLAG;
if (EmitRawCode) flags |= CompilerDriver::EMIT_RAW_FLAG;
if (KeepTemps) flags |= CompilerDriver::KEEP_TEMPS_FLAG;
if (!LinkerToolOpts.empty())
CD->setPhaseArgs(CompilerDriver::LINKING, LinkerToolOpts);
+ // Check for options that cause us to terminate before any significant work
+ // is done.
+ handleTerminatingOptions(CD);
+
// Prepare the list of files to be compiled by the CompilerDriver.
CompilerDriver::InputList InpList;
std::vector<std::string>::iterator fileIt = Files.begin();
} catch (...) {
std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
}
+ return 1;
}