[lld] r361015 - [MinGW] Implement --help for the MinGW driver
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 04:07:38 PDT 2019
Author: mstorsjo
Date: Fri May 17 04:07:38 2019
New Revision: 361015
URL: http://llvm.org/viewvc/llvm-project?rev=361015&view=rev
Log:
[MinGW] Implement --help for the MinGW driver
Differential Revision: https://reviews.llvm.org/D62029
Modified:
lld/trunk/MinGW/Driver.cpp
lld/trunk/MinGW/Options.td
Modified: lld/trunk/MinGW/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Driver.cpp?rev=361015&r1=361014&r2=361015&view=diff
==============================================================================
--- lld/trunk/MinGW/Driver.cpp (original)
+++ lld/trunk/MinGW/Driver.cpp Fri May 17 04:07:38 2019
@@ -78,6 +78,13 @@ public:
};
} // 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 @@ opt::InputArgList MinGWOptTable::parse(A
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 @@ bool mingw::link(ArrayRef<const char *>
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()); };
Modified: lld/trunk/MinGW/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Options.td?rev=361015&r1=361014&r2=361015&view=diff
==============================================================================
--- lld/trunk/MinGW/Options.td (original)
+++ lld/trunk/MinGW/Options.td Fri May 17 04:07:38 2019
@@ -16,6 +16,7 @@ def exclude_all_symbols: F<"exclude-all-
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">,
More information about the llvm-commits
mailing list