Simplify `ld.lld --help` message.

Previously, we printed out two lines of help messages for `--foo bar`
and `--foo=bar` like this:

  --soname=<value>        Set DT_SONAME
  --soname <value>        Set DT_SONAME
  --sort-section=<value>  Specifies sections sorting rule when linkerscript is used
  --sort-section <value>  Specifies sections sorting rule when linkerscript is used

This change eliminates duplicate lines that doesn't contain `=` for such
options like this.

  --soname=<value>        Set DT_SONAME
  --sort-section=<value>  Specifies sections sorting rule when linkerscript is used

Differential Revision: https://reviews.llvm.org/D47558

llvm-svn: 333596
This commit is contained in:
Rui Ueyama 2018-05-30 21:25:53 +00:00
parent b54ac414d1
commit eea690dae5
1 changed files with 67 additions and 79 deletions

View File

@ -5,9 +5,10 @@ include "llvm/Option/OptParser.td"
class F<string name>: Flag<["--", "-"], name>;
class J<string name>: Joined<["--", "-"], name>;
multiclass Eq<string name> {
multiclass Eq<string name, string help> {
def NAME: Separate<["--", "-"], name>;
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
HelpText<help>;
}
multiclass B<string name, string help1, string help2> {
@ -15,8 +16,7 @@ multiclass B<string name, string help1, string help2> {
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
}
defm auxiliary: Eq<"auxiliary">,
HelpText<"Set DT_AUXILIARY field to the specified name">;
defm auxiliary: Eq<"auxiliary", "Set DT_AUXILIARY field to the specified name">;
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
@ -35,24 +35,21 @@ defm check_sections : B<"check-sections",
"Check section addresses for overlaps",
"Do not check section addresses for overlaps">;
defm compress_debug_sections : Eq<"compress-debug-sections">,
HelpText<"Compress DWARF debug sections">;
defm compress_debug_sections:
Eq<"compress-debug-sections", "Compress DWARF debug sections">;
defm defsym: Eq<"defsym">, HelpText<"Define a symbol alias">;
defm defsym: Eq<"defsym", "Define a symbol alias">;
defm library_path: Eq<"library-path">,
HelpText<"Add a directory to the library search path">, MetaVarName<"<dir>">;
defm library_path:
Eq<"library-path", "Add a directory to the library search path">, MetaVarName<"<dir>">;
def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
defm Tbss: Eq<"Tbss">,
HelpText<"Same as --section-start with .bss as the sectionname">;
defm Tbss: Eq<"Tbss", "Same as --section-start with .bss as the sectionname">;
defm Tdata: Eq<"Tdata">,
HelpText<"Same as --section-start with .data as the sectionname">;
defm Tdata: Eq<"Tdata", "Same as --section-start with .data as the sectionname">;
defm Ttext: Eq<"Ttext">,
HelpText<"Same as --section-start with .text as the sectionname">;
defm Ttext: Eq<"Ttext", "Same as --section-start with .text as the sectionname">;
defm allow_multiple_definition: B<"allow-multiple-definition",
"Allow multiple definitions",
@ -66,11 +63,11 @@ defm as_needed: B<"as-needed",
"Only set DT_NEEDED for shared libraries if used",
"Always set DT_NEEDED for shared libraries">;
defm call_graph_ordering_file: Eq<"call-graph-ordering-file">,
HelpText<"Layout sections to optimize the given callgraph">;
defm call_graph_ordering_file:
Eq<"call-graph-ordering-file", "Layout sections to optimize the given callgraph">;
// -chroot doesn't have a help text because it is an internal option.
defm chroot: Eq<"chroot">;
def chroot: Separate<["--", "-"], "chroot">;
def color_diagnostics: F<"color-diagnostics">,
HelpText<"Use colors in diagnostics">;
@ -101,11 +98,9 @@ def discard_locals: F<"discard-locals">,
def discard_none: F<"discard-none">,
HelpText<"Keep all symbols in the symbol table">;
defm dynamic_linker: Eq<"dynamic-linker">,
HelpText<"Which dynamic linker to use">;
defm dynamic_linker: Eq<"dynamic-linker", "Which dynamic linker to use">;
defm dynamic_list: Eq<"dynamic-list">,
HelpText<"Read a list of dynamic symbols">;
defm dynamic_list: Eq<"dynamic-list", "Read a list of dynamic symbols">;
defm eh_frame_hdr: B<"eh-frame-hdr",
"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header",
@ -122,40 +117,36 @@ def end_group: F<"end-group">,
def end_lib: F<"end-lib">,
HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
defm entry: Eq<"entry">, HelpText<"Name of entry point symbol">,
defm entry: Eq<"entry", "Name of entry point symbol">,
MetaVarName<"<entry>">;
defm error_limit: Eq<"error-limit">,
HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
defm error_limit:
Eq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
def error_unresolved_symbols: F<"error-unresolved-symbols">,
HelpText<"Report unresolved symbols as errors">;
defm exclude_libs: Eq<"exclude-libs">,
HelpText<"Exclude static libraries from automatic export">;
defm exclude_libs: Eq<"exclude-libs", "Exclude static libraries from automatic export">;
defm export_dynamic: B<"export-dynamic",
"Put symbols in the dynamic symbol table",
"Do not put symbols in the dynamic symbol table">;
defm export_dynamic_symbol: Eq<"export-dynamic-symbol">,
HelpText<"Put a symbol in the dynamic symbol table">;
defm export_dynamic_symbol:
Eq<"export-dynamic-symbol", "Put a symbol in the dynamic symbol table">;
defm fatal_warnings: B<"fatal-warnings",
"Treat warnings as errors",
"Do not treat warnings as errors">;
defm filter: Eq<"filter">,
HelpText<"Set DT_FILTER field to the specified name">;
defm filter: Eq<"filter", "Set DT_FILTER field to the specified name">;
defm fini: Eq<"fini">,
HelpText<"Specify a finalizer function">, MetaVarName<"<symbol>">;
defm fini: Eq<"fini", "Specify a finalizer function">, MetaVarName<"<symbol>">;
def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
defm format: Eq<"format">,
HelpText<"Change the input format of the inputs following this option">,
defm format: Eq<"format", "Change the input format of the inputs following this option">,
MetaVarName<"<input-format>">;
defm gc_sections: B<"gc-sections",
@ -170,8 +161,7 @@ defm gnu_unique: B<"gnu-unique",
"Enable STB_GNU_UNIQUE symbol binding",
"Disable STB_GNU_UNIQUE symbol binding">;
defm hash_style: Eq<"hash-style">,
HelpText<"Specify hash style (sysv, gnu or both)">;
defm hash_style: Eq<"hash-style", "Specify hash style (sysv, gnu or both)">;
def help: F<"help">, HelpText<"Print option help">;
@ -185,21 +175,21 @@ def ignore_function_address_equality: F<"ignore-function-address-equality">,
def ignore_data_address_equality: F<"ignore-data-address-equality">,
HelpText<"lld can break the address equality of data">;
defm image_base : Eq<"image-base">, HelpText<"Set the base address">;
defm image_base: Eq<"image-base", "Set the base address">;
defm init: Eq<"init">, HelpText<"Specify an initializer function">,
defm init: Eq<"init", "Specify an initializer function">,
MetaVarName<"<symbol>">;
defm just_symbols: Eq<"just-symbols">, HelpText<"Just link symbols">;
defm just_symbols: Eq<"just-symbols", "Just link symbols">;
defm keep_unique: Eq<"keep-unique">, HelpText<"Do not fold this symbol during ICF">;
defm keep_unique: Eq<"keep-unique", "Do not fold this symbol during ICF">;
defm library: Eq<"library">, HelpText<"Root name of library to use">,
defm library: Eq<"library", "Root name of library to use">,
MetaVarName<"<libName>">;
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
defm Map: Eq<"Map">, HelpText<"Print a link map to the specified file">;
defm Map: Eq<"Map", "Print a link map to the specified file">;
defm merge_exidx_entries: B<"merge-exidx-entries",
"Enable merging .ARM.exidx entries",
@ -235,11 +225,12 @@ def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">,
def omagic: Flag<["--"], "omagic">, MetaVarName<"<magic>">,
HelpText<"Set the text and data sections to be readable and writable">;
defm orphan_handling: Eq<"orphan-handling">,
HelpText<"Control how orphan sections are handled when linker script used">;
defm orphan_handling:
Eq<"orphan-handling", "Control how orphan sections are handled when linker script used">;
defm pack_dyn_relocs: Eq<"pack-dyn-relocs">, MetaVarName<"<format>">,
HelpText<"Pack dynamic relocations in the given format (none or android)">;
defm pack_dyn_relocs:
Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format (none or android)">,
MetaVarName<"<format>">;
defm pie: B<"pie",
"Create a position independent executable",
@ -256,28 +247,27 @@ defm print_icf_sections: B<"print-icf-sections",
def print_map: F<"print-map">,
HelpText<"Print a link map to the standard output">;
defm reproduce: Eq<"reproduce">,
HelpText<"Dump linker invocation and input files for debugging">;
defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">;
defm rpath: Eq<"rpath">, HelpText<"Add a DT_RUNPATH to the output">;
defm rpath: Eq<"rpath", "Add a DT_RUNPATH to the output">;
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
defm retain_symbols_file: Eq<"retain-symbols-file">,
HelpText<"Retain only the symbols listed in the file">,
defm retain_symbols_file:
Eq<"retain-symbols-file", "Retain only the symbols listed in the file">,
MetaVarName<"<file>">;
defm script: Eq<"script">, HelpText<"Read linker script">;
defm script: Eq<"script", "Read linker script">;
defm section_start: Eq<"section-start">, MetaVarName<"<address>">,
HelpText<"Set address of section">;
defm section_start: Eq<"section-start", "Set address of section">,
MetaVarName<"<address>">;
def shared: F<"shared">, HelpText<"Build a shared object">;
defm soname: Eq<"soname">, HelpText<"Set DT_SONAME">;
defm soname: Eq<"soname", "Set DT_SONAME">;
defm sort_section: Eq<"sort-section">,
HelpText<"Specifies sections sorting rule when linkerscript is used">;
defm sort_section:
Eq<"sort-section", "Specifies sections sorting rule when linkerscript is used">;
def start_group: F<"start-group">,
HelpText<"Ignored for compatibility with GNU unless you pass --warn-backrefs">;
@ -289,17 +279,17 @@ def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
defm symbol_ordering_file: Eq<"symbol-ordering-file">,
HelpText<"Layout sections to place symbols in the order specified by symbol ordering file">;
defm symbol_ordering_file:
Eq<"symbol-ordering-file", "Layout sections to place symbols in the order specified by symbol ordering file">;
defm sysroot: Eq<"sysroot">, HelpText<"Set the system root">;
defm sysroot: Eq<"sysroot", "Set the system root">;
def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32">;
defm target2: Eq<"target2">,
HelpText<"Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">,
defm target2:
Eq<"target2", "Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">,
MetaVarName<"<type>">;
defm threads: B<"threads",
@ -308,20 +298,19 @@ defm threads: B<"threads",
def trace: F<"trace">, HelpText<"Print the names of the input files">;
defm trace_symbol : Eq<"trace-symbol">, HelpText<"Trace references to symbols">;
defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
defm undefined: Eq<"undefined">,
HelpText<"Force undefined symbol during linking">;
defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
defm unresolved_symbols: Eq<"unresolved-symbols">,
HelpText<"Determine how to handle unresolved symbols">;
defm unresolved_symbols:
Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
defm undefined_version: B<"undefined-version",
"Allow unused version in version script",
"Report version scripts that refer undefined symbols">;
defm rsp_quoting: Eq<"rsp-quoting">,
HelpText<"Quoting style for response files. Values supported: windows|posix">;
defm rsp_quoting:
Eq<"rsp-quoting", "Quoting style for response files. Values supported: windows|posix">;
def v: Flag<["-"], "v">, HelpText<"Display the version number">;
@ -329,7 +318,7 @@ def verbose: F<"verbose">, HelpText<"Verbose mode">;
def version: F<"version">, HelpText<"Display the version number and exit">;
defm version_script: Eq<"version-script">, HelpText<"Read a version script">;
defm version_script: Eq<"version-script", "Read a version script">;
defm warn_backrefs: B<"warn-backrefs",
"Warn about backward symbol references to fetch archive members",
@ -350,7 +339,7 @@ defm whole_archive: B<"whole-archive",
"Force load of all members in a static library",
"Do not force load of all members in a static library">;
defm wrap: Eq<"wrap">, HelpText<"Use wrapper functions for symbol">,
defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
MetaVarName<"<symbol>">;
def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
@ -413,18 +402,16 @@ def lto_partitions: J<"lto-partitions=">,
def lto_sample_profile: J<"lto-sample-profile=">,
HelpText<"Sample profile file path">;
def disable_verify: F<"disable-verify">;
defm mllvm: Eq<"mllvm">;
defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
HelpText<"YAML output file for optimization remarks">;
def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
HelpText<"Include hotness information in the optimization remarks file">;
defm plugin_opt: Eq<"plugin-opt">,
HelpText<"specifies LTO options for compatibility with GNU linkers">;
defm plugin_opt: Eq<"plugin-opt", "specifies LTO options for compatibility with GNU linkers">;
def save_temps: F<"save-temps">;
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
HelpText<"Path to ThinLTO cached object file directory">;
defm thinlto_cache_policy: Eq<"thinlto-cache-policy">,
HelpText<"Pruning policy for the ThinLTO cache">;
defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
def plugin_opt_O: J<"plugin-opt=O">, Alias<lto_O>;
@ -450,7 +437,7 @@ def plugin_opt_thinlto_prefix_replace_eq: J<"plugin-opt=thinlto-prefix-replace="
// just ignore the option on lld side as it's easier. In fact, the linker could
// be called 'ld' and understanding which linker is used would require parsing of
// --version output.
defm plugin: Eq<"plugin">;
def plugin: J<"plugin">;
def plugin_opt_fresolution_eq: J<"plugin-opt=-fresolution=">;
def plugin_opt_pass_through_eq: J<"plugin-opt=-pass-through=">;
@ -469,7 +456,8 @@ def no_ctors_in_init_array: F<"no-ctors-in-init-array">;
def no_keep_memory: F<"no-keep-memory">;
def no_mmap_output_file: F<"no-mmap-output-file">;
def no_warn_mismatch: F<"no-warn-mismatch">;
defm rpath_link: Eq<"rpath-link">;
def rpath_link: J<"rpath-link">;
def rpath_link_eq: J<"rpath-link=">;
def sort_common: F<"sort-common">;
def stats: F<"stats">;
def warn_execstack: F<"warn-execstack">;