[lld] r215781 - [mach-o] improve darwin driver 'usage' message when run with no args

Nick Kledzik kledzik at apple.com
Fri Aug 15 15:42:46 PDT 2014


Author: kledzik
Date: Fri Aug 15 17:42:46 2014
New Revision: 215781

URL: http://llvm.org/viewvc/llvm-project?rev=215781&view=rev
Log:
[mach-o] improve darwin driver 'usage' message when run with no args

Modified:
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/Driver/DarwinLdOptions.td

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=215781&r1=215780&r2=215781&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Aug 15 17:42:46 2014
@@ -320,16 +320,6 @@ bool DarwinLdDriver::parse(int argc, con
   if (llvm::opt::Arg *loader = parsedArgs->getLastArg(OPT_bundle_loader))
     ctx.setBundleLoader(loader->getValue());
 
-  // Handle -help
-  if (parsedArgs->getLastArg(OPT_help)) {
-    table.PrintHelp(llvm::outs(), argv[0], "LLVM Darwin Linker", false);
-    // If only -help on command line, don't try to do any linking
-    if (argc == 2) {
-      ctx.setDoNothing(true);
-      return true;
-    }
-  }
-
   // Handle -sectalign segname sectname align
   for (auto &alignArg : parsedArgs->filtered(OPT_sectalign)) {
     const char* segName   = alignArg->getValue(0);
@@ -480,6 +470,10 @@ bool DarwinLdDriver::parse(int argc, con
   }
 
   if (!inputGraph->size()) {
+    if (parsedArgs->size() == 0) {
+      table.PrintHelp(llvm::outs(), "lld", "LLVM Linker", false);
+      return false;
+    }
     diagnostics << "No input files\n";
     return false;
   }

Modified: lld/trunk/lib/Driver/DarwinLdOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=215781&r1=215780&r2=215781&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdOptions.td (original)
+++ lld/trunk/lib/Driver/DarwinLdOptions.td Fri Aug 15 17:42:46 2014
@@ -4,108 +4,124 @@ include "llvm/Option/OptParser.td"
 // output kinds
 def grp_kind : OptionGroup<"outs">, HelpText<"OUTPUT KIND">;
 def relocatable : Flag<["-"], "r">,
-                HelpText<"Create relocatable object file">, Group<grp_kind>;
+     HelpText<"Create relocatable object file">, Group<grp_kind>;
 def static : Flag<["-"], "static">,
-                HelpText<"Create static executable">, Group<grp_kind>;
+     HelpText<"Create static executable">, Group<grp_kind>;
 def dynamic : Flag<["-"], "dynamic">,
-                HelpText<"Create dynamic executable (default)">,Group<grp_kind>;
+     HelpText<"Create dynamic executable (default)">,Group<grp_kind>;
 def dylib : Flag<["-"], "dylib">,
-                HelpText<"Create dynamic library">, Group<grp_kind>;
+     HelpText<"Create dynamic library">, Group<grp_kind>;
 def bundle : Flag<["-"], "bundle">,
-                HelpText<"Create dynamic bundle">, Group<grp_kind>;
+     HelpText<"Create dynamic bundle">, Group<grp_kind>;
 def execute : Flag<["-"], "execute">,
-                HelpText<"Create main executable (default)">, Group<grp_kind>;
+     HelpText<"Create main executable (default)">, Group<grp_kind>;
 def preload : Flag<["-"], "preload">,
-                HelpText<"Create preload">, Group<grp_kind>;
+     HelpText<"Create binary for use with embedded systems">, Group<grp_kind>;
 
 // optimizations
 def grp_opts : OptionGroup<"opts">, HelpText<"OPTIMIZATIONS">;
 def dead_strip : Flag<["-"], "dead_strip">,
-                HelpText<"Remove unreference code and data">, Group<grp_opts>;
+     HelpText<"Remove unreference code and data">, Group<grp_opts>;
 def macosx_version_min : Separate<["-"], "macosx_version_min">,
-                HelpText<"Minimum Mac OS X version">, Group<grp_opts>;
+     MetaVarName<"<version>">,
+     HelpText<"Minimum Mac OS X version">, Group<grp_opts>;
 def ios_version_min : Separate<["-"], "ios_version_min">,
-                HelpText<"Minimum iOS version">, Group<grp_opts>;
+     MetaVarName<"<version>">,
+     HelpText<"Minimum iOS version">, Group<grp_opts>;
 def ios_simulator_version_min : Separate<["-"], "ios_simulator_version_min">,
-                HelpText<"Minimum iOS simulator version">, Group<grp_opts>;
+     MetaVarName<"<version>">,
+     HelpText<"Minimum iOS simulator version">, Group<grp_opts>;
 def mllvm : Separate<["-"], "mllvm">,
-                HelpText<"Options to pass to LLVM during LTO">, Group<grp_opts>;
+     MetaVarName<"<option>">,
+     HelpText<"Options to pass to LLVM during LTO">, Group<grp_opts>;
 
 // main executable options
 def grp_main : OptionGroup<"opts">, HelpText<"MAIN EXECUTABLE OPTIONS">;
-def entry : Separate<["-"], "e">, HelpText<"entry symbol name">,Group<grp_main>;
+def entry : Separate<["-"], "e">,
+     MetaVarName<"<entry-name>">,
+     HelpText<"entry symbol name">,Group<grp_main>;
 
 // dylib executable options
 def grp_dylib : OptionGroup<"opts">, HelpText<"DYLIB EXECUTABLE OPTIONS">;
 def install_name : Separate<["-"], "install_name">,
-    HelpText<"The dylib's install name">, Group<grp_dylib>;
+     MetaVarName<"<path>">,
+     HelpText<"The dylib's install name">, Group<grp_dylib>;
 def mark_dead_strippable_dylib : Flag<["-"], "mark_dead_strippable_dylib">,
-    HelpText<"Marks the dylib as having no side effects during initialization">,
-    Group<grp_dylib>;
+     HelpText<"Marks the dylib as having no side effects during initialization">,
+     Group<grp_dylib>;
 def compatibility_version : Separate<["-"], "compatibility_version">,
-    HelpText<"The dylib's compatibility version">, Group<grp_dylib>;
+     MetaVarName<"<version>">,
+     HelpText<"The dylib's compatibility version">, Group<grp_dylib>;
 def current_version : Separate<["-"], "current_version">,
-    HelpText<"The dylib's current version">, Group<grp_dylib>;
+     MetaVarName<"<version>">,
+     HelpText<"The dylib's current version">, Group<grp_dylib>;
 
 // dylib executable options - compatibility aliases
 def dylib_install_name : Separate<["-"], "dylib_install_name">,
-    Alias<install_name>;
-def dylib_compatibility_version :
-    Separate<["-"], "dylib_compatibility_version">,
-    Alias<compatibility_version>;
+     Alias<install_name>;
+def dylib_compatibility_version : Separate<["-"], "dylib_compatibility_version">,
+     MetaVarName<"<version>">, Alias<compatibility_version>;
 def dylib_current_version : Separate<["-"], "dylib_current_version">,
-    Alias<current_version>;
+     MetaVarName<"<version>">, Alias<current_version>;
 
 // bundle executable options
 def grp_bundle : OptionGroup<"opts">, HelpText<"BUNDLE EXECUTABLE OPTIONS">;
 def bundle_loader : Separate<["-"], "bundle_loader">,
-    HelpText<"The executable that will be loading this Mach-O bundle">,
-    Group<grp_bundle>;
+     MetaVarName<"<path>">,
+     HelpText<"The executable that will be loading this Mach-O bundle">,
+     Group<grp_bundle>;
 
 // library options
 def grp_libs : OptionGroup<"libs">, HelpText<"LIBRARY OPTIONS">;
 def L : JoinedOrSeparate<["-"], "L">,
-        HelpText<"Add directory to library search path">, Group<grp_libs>;
+     MetaVarName<"<dir>">,
+     HelpText<"Add directory to library search path">, Group<grp_libs>;
 def F : JoinedOrSeparate<["-"], "F">,
-        HelpText<"Add directory to framework search path">, Group<grp_libs>;
+     MetaVarName<"<dir>">,
+     HelpText<"Add directory to framework search path">, Group<grp_libs>;
 def Z : Flag<["-"], "Z">,
      HelpText<"Do not search standard directories for libraries or frameworks">;
 def all_load : Flag<["-"], "all_load">,
-        HelpText<"Forces all members of all static libraries to be loaded">,
-        Group<grp_libs>;
-def syslibroot : Separate<["-"], "syslibroot">,
-        HelpText<"Add path to SDK to all absolute library search paths">,
-        Group<grp_libs>;
+     HelpText<"Forces all members of all static libraries to be loaded">,
+     Group<grp_libs>;
+def syslibroot : Separate<["-"], "syslibroot">, MetaVarName<"<dir>">,
+     HelpText<"Add path to SDK to all absolute library search paths">,
+     Group<grp_libs>;
 
 // Input options
 def l : Joined<["-"], "l">,
-        HelpText<"Base name of library searched for in -L directories">;
+     MetaVarName<"<libname>">,
+     HelpText<"Base name of library searched for in -L directories">;
 def framework : Separate<["-"], "framework">,
-    HelpText<"Base name of framework searched for in -F directories">;
+     MetaVarName<"<name>">,
+     HelpText<"Base name of framework searched for in -F directories">;
 def filelist : Separate<["-"], "filelist">,
-    HelpText<"file containing paths to input files">;
+     MetaVarName<"<path>">,
+     HelpText<"file containing paths to input files">;
 
 
 // test case options
 def print_atoms : Flag<["-"], "print_atoms">,
-        HelpText<"Emit output as yaml atoms">;
+     HelpText<"Emit output as yaml atoms">;
 def test_file_usage : Flag<["-"], "test_file_usage">,
-        HelpText<"Only files specified by -file_exists are considered to exist."
-                 " Print which files would be used.">;
+     HelpText<"Only files specified by -file_exists are considered to exist. "
+              "Print which files would be used">;
 def path_exists : Separate<["-"], "path_exists">,
-        HelpText<"When used with -test_file_usage, only these paths exist">;
+     MetaVarName<"<path>">,
+     HelpText<"Used with -test_file_usage to declare a path">;
 
 
 // general options
-def output : Separate<["-"], "o">, HelpText<"Output file path">;
-def arch : Separate<["-"], "arch">, HelpText<"Architecture to link">;
+def output : Separate<["-"], "o">,
+     MetaVarName<"<path>">,
+     HelpText<"Output file path">;
+def arch : Separate<["-"], "arch">,
+     MetaVarName<"<arch-name>">,
+     HelpText<"Architecture to link">;
 def sectalign : MultiArg<["-"], "sectalign", 3>,
-                HelpText<"alignment for segment/section">;
+     MetaVarName<"<segname> <sectname> <alignment>">,
+     HelpText<"alignment for segment/section">;
 def t : Flag<["-"], "t">,
      HelpText<"Print the names of the input files as ld processes them">;
 def v : Flag<["-"], "v">,
      HelpText<"Print linker information">;
-
-
-// extras
-def help : Flag<["-"], "help">;





More information about the llvm-commits mailing list