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 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 LinkArgs; auto Add = [&](const Twine &S) { LinkArgs.push_back(S.str()); }; 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">,