[PATCH] D62029: [LLD] [MinGW] Implement --help for the MinGW driver
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 13:31:04 PDT 2019
mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk.
Herald added a project: LLVM.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D62029
Files:
MinGW/Driver.cpp
MinGW/Options.td
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -16,6 +16,7 @@
def export_all_symbols: F<"export-all-symbols">,
HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
def gc_sections: F<"gc-sections">, HelpText<"Remove unused sections">;
+def help: F<"help">, HelpText<"Print option help">;
def icf: J<"icf=">, HelpText<"Identical code folding">;
def image_base: S<"image-base">, HelpText<"Base address of the program">;
def insert_timestamp: F<"insert-timestamp">,
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -78,6 +78,13 @@
};
} // namespace
+static void printHelp(const char *Argv0) {
+ MinGWOptTable().PrintHelp(
+ outs(), (std::string(Argv0) + " [options] file...").c_str(), "lld",
+ false /*ShowHidden*/, true /*ShowAllAliases*/);
+ outs() << "\n";
+}
+
opt::InputArgList MinGWOptTable::parse(ArrayRef<const char *> Argv) {
unsigned MissingIndex;
unsigned MissingCount;
@@ -89,8 +96,6 @@
fatal(StringRef(Args.getArgString(MissingIndex)) + ": missing argument");
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
fatal("unknown argument: " + Arg->getSpelling());
- if (!Args.hasArg(OPT_INPUT) && !Args.hasArg(OPT_l))
- fatal("no input files");
return Args;
}
@@ -129,6 +134,14 @@
MinGWOptTable Parser;
opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
+ if (Args.hasArg(OPT_help)) {
+ printHelp(ArgsArr[0]);
+ return true;
+ }
+
+ if (!Args.hasArg(OPT_INPUT) && !Args.hasArg(OPT_l))
+ fatal("no input files");
+
std::vector<std::string> LinkArgs;
auto Add = [&](const Twine &S) { LinkArgs.push_back(S.str()); };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62029.199889.patch
Type: text/x-patch
Size: 1814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190516/9a4d0c06/attachment.bin>
More information about the llvm-commits
mailing list