1include "llvm/Option/OptParser.td" 2 3// Convenience classes for long options which only accept two dashes. For lld 4// specific or newer long options, we prefer two dashes to avoid collision with 5// short options. For many others, we have to accept both forms to be compatible 6// with GNU ld. 7class FF<string name> : Flag<["--"], name>; 8class JJ<string name>: Joined<["--"], name>; 9 10multiclass EEq<string name, string help> { 11 def NAME: Separate<["--"], name>; 12 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>, 13 HelpText<help>; 14} 15 16multiclass BB<string name, string help1, string help2> { 17 def NAME: Flag<["--"], name>, HelpText<help1>; 18 def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>; 19} 20 21// For options whose names are multiple letters, either one dash or 22// two can precede the option name except those that start with 'o'. 23class F<string name>: Flag<["--", "-"], name>; 24class J<string name>: Joined<["--", "-"], name>; 25class S<string name>: Separate<["--", "-"], name>; 26 27multiclass Eq<string name, string help> { 28 def NAME: Separate<["--", "-"], name>; 29 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>, 30 HelpText<help>; 31} 32 33multiclass B<string name, string help1, string help2> { 34 def NAME: Flag<["--", "-"], name>, HelpText<help1>; 35 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>; 36} 37 38// The following flags are shared with the ELF linker 39def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">; 40 41def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">; 42 43def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">; 44 45defm color_diagnostics: B<"color-diagnostics", 46 "Alias for --color-diagnostics=always", 47 "Alias for --color-diagnostics=never">; 48def color_diagnostics_eq: J<"color-diagnostics=">, 49 HelpText<"Use colors in diagnostics (default: auto)">, 50 MetaVarName<"[auto,always,never]">; 51 52def compress_relocations: F<"compress-relocations">, 53 HelpText<"Compress the relocation targets in the code section.">; 54 55defm demangle: B<"demangle", 56 "Demangle symbol names", 57 "Do not demangle symbol names">; 58 59def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">; 60 61def error_unresolved_symbols: F<"error-unresolved-symbols">, 62 HelpText<"Report unresolved symbols as errors">; 63 64defm export_dynamic: B<"export-dynamic", 65 "Put symbols in the dynamic symbol table", 66 "Do not put symbols in the dynamic symbol table (default)">; 67 68def entry: S<"entry">, MetaVarName<"<entry>">, 69 HelpText<"Name of entry point symbol">; 70 71defm error_limit: 72 EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">; 73 74def fatal_warnings: F<"fatal-warnings">, 75 HelpText<"Treat warnings as errors">; 76 77defm gc_sections: B<"gc-sections", 78 "Enable garbage collection of unused sections", 79 "Disable garbage collection of unused sections">; 80 81defm merge_data_segments: BB<"merge-data-segments", 82 "Enable merging data segments", 83 "Disable merging data segments">; 84 85def help: F<"help">, HelpText<"Print option help">; 86 87def library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">, 88 HelpText<"Root name of library to use">; 89 90def library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">, 91 HelpText<"Add a directory to the library search path">; 92 93def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">; 94 95defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">; 96 97defm Map: Eq<"Map", "Print a link map to the specified file">; 98 99def no_fatal_warnings: F<"no-fatal-warnings">; 100 101def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">, 102 HelpText<"Path to file to write output">; 103 104def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">; 105 106defm pie: B<"pie", 107 "Create a position independent executable", 108 "Do not create a position independent executable (default)">; 109 110defm print_gc_sections: B<"print-gc-sections", 111 "List removed unused sections", 112 "Do not list removed unused sections">; 113 114def print_map: F<"print-map">, 115 HelpText<"Print a link map to the standard output">; 116 117def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">; 118 119defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">; 120 121defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">, 122 MetaVarName<"[posix,windows]">; 123 124def shared: F<"shared">, HelpText<"Build a shared object">; 125 126def strip_all: F<"strip-all">, HelpText<"Strip all symbols">; 127 128def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">; 129 130defm threads 131 : Eq<"threads", "Number of threads. '1' disables multi-threading. By " 132 "default all available hardware threads are used">; 133 134def trace: F<"trace">, HelpText<"Print the names of the input files">; 135 136defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">; 137 138defm undefined: Eq<"undefined", "Force undefined symbol during linking">; 139 140defm unresolved_symbols: 141 Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">; 142 143def v: Flag<["-"], "v">, HelpText<"Display the version number">; 144 145def verbose: F<"verbose">, HelpText<"Verbose mode">; 146 147def version: F<"version">, HelpText<"Display the version number and exit">; 148 149def warn_unresolved_symbols: F<"warn-unresolved-symbols">, 150 HelpText<"Report unresolved symbols as warnings">; 151 152defm wrap: Eq<"wrap", "Use wrapper functions for symbol">, 153 MetaVarName<"<symbol>=<symbol>">; 154 155def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">, 156 HelpText<"Linker option extensions">; 157 158// The follow flags are unique to wasm 159 160def allow_undefined: F<"allow-undefined">, 161 HelpText<"Allow undefined symbols in linked binary. " 162 "This options is equivalent to --import-undefined " 163 "and --unresolved-symbols=ignore-all">; 164 165def import_undefined: F<"import-undefined">, 166 HelpText<"Turn undefined symbols into imports where possible">; 167 168def allow_undefined_file: J<"allow-undefined-file=">, 169 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">; 170 171def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">, 172 Alias<allow_undefined_file>; 173 174defm export: Eq<"export", "Force a symbol to be exported">; 175 176defm export_if_defined: Eq<"export-if-defined", 177 "Force a symbol to be exported, if it is defined in the input">; 178 179def export_all: FF<"export-all">, 180 HelpText<"Export all symbols (normally combined with --no-gc-sections)">; 181 182def export_table: FF<"export-table">, 183 HelpText<"Export function table to the environment">; 184 185def growable_table: FF<"growable-table">, 186 HelpText<"Remove maximum size from function table, allowing table to grow">; 187 188def global_base: JJ<"global-base=">, 189 HelpText<"Where to start to place global data">; 190 191def import_memory: FF<"import-memory">, 192 HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">; 193def import_memory_with_name: JJ<"import-memory=">, 194 HelpText<"Import the module's memory from the passed module with the passed name.">, 195 MetaVarName<"<module>,<name>">; 196 197def export_memory: FF<"export-memory">, 198 HelpText<"Export the module's memory with the default name of \"memory\"">; 199def export_memory_with_name: JJ<"export-memory=">, 200 HelpText<"Export the module's memory with the passed name">; 201 202def shared_memory: FF<"shared-memory">, 203 HelpText<"Use shared linear memory">; 204 205def import_table: FF<"import-table">, 206 HelpText<"Import function table from the environment">; 207 208def initial_memory: JJ<"initial-memory=">, 209 HelpText<"Initial size of the linear memory">; 210 211def max_memory: JJ<"max-memory=">, 212 HelpText<"Maximum size of the linear memory">; 213 214def no_entry: FF<"no-entry">, 215 HelpText<"Do not output any entry point">; 216 217def stack_first: FF<"stack-first">, 218 HelpText<"Place stack at start of linear memory rather than after data">; 219 220defm whole_archive: B<"whole-archive", 221 "Force load of all members in a static library", 222 "Do not force load of all members in a static library (default)">; 223 224def why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">; 225 226defm check_features: BB<"check-features", 227 "Check feature compatibility of linked objects (default)", 228 "Ignore feature compatibility of linked objects">; 229 230def features: CommaJoined<["--", "-"], "features=">, 231 HelpText<"Comma-separated used features, inferred from input objects by default.">; 232 233def extra_features: CommaJoined<["--", "-"], "extra-features=">, 234 HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">; 235 236// Aliases 237def: JoinedOrSeparate<["-"], "e">, Alias<entry>; 238def: J<"entry=">, Alias<entry>; 239def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">; 240def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">; 241def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 242def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 243def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 244def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">; 245def: Flag<["-"], "i">, Alias<initial_memory>; 246def: Separate<["--", "-"], "library">, Alias<library>; 247def: Joined<["--", "-"], "library=">, Alias<library>; 248def: Separate<["--", "-"], "library-path">, Alias<library_path>; 249def: Joined<["--", "-"], "library-path=">, Alias<library_path>; 250def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">; 251def: Flag<["-"], "r">, Alias<relocatable>; 252def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">; 253def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">; 254def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">; 255def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">; 256def: JoinedOrSeparate<["-"], "u">, Alias<undefined>; 257 258// LTO-related options. 259def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">, 260 HelpText<"Optimization level for LTO">; 261def lto_partitions: JJ<"lto-partitions=">, 262 HelpText<"Number of LTO codegen partitions">; 263def disable_verify: F<"disable-verify">; 264def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">; 265def thinlto_cache_dir: JJ<"thinlto-cache-dir=">, 266 HelpText<"Path to ThinLTO cached object file directory">; 267defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">; 268def thinlto_jobs: JJ<"thinlto-jobs=">, 269 HelpText<"Number of ThinLTO jobs. Default to --threads=">; 270def no_lto_legacy_pass_manager: FF<"no-lto-legacy-pass-manager">, 271 HelpText<"Use new pass manager">; 272def lto_debug_pass_manager: FF<"lto-debug-pass-manager">, 273 HelpText<"Debug new pass manager">; 274 275// Experimental PIC mode. 276def experimental_pic: FF<"experimental-pic">, 277 HelpText<"Enable Experimental PIC">; 278