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">; 42 43def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries (default)">; 44 45defm allow_multiple_definition: B<"allow-multiple-definition", 46 "Allow multiple definitions", 47 "Do not allow multiple definitions (default)">; 48 49def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">; 50 51def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">, 52 MetaVarName<"[fast,sha1,uuid,0x<hexstring>]">; 53 54defm color_diagnostics: B<"color-diagnostics", 55 "Alias for --color-diagnostics=always", 56 "Alias for --color-diagnostics=never">; 57def color_diagnostics_eq: J<"color-diagnostics=">, 58 HelpText<"Use colors in diagnostics (default: auto)">, 59 MetaVarName<"[auto,always,never]">; 60 61def compress_relocations: F<"compress-relocations">, 62 HelpText<"Compress the relocation targets in the code section.">; 63 64defm demangle: B<"demangle", 65 "Demangle symbol names (default)", 66 "Do not demangle symbol names">; 67 68def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">; 69 70def error_unresolved_symbols: F<"error-unresolved-symbols">, 71 HelpText<"Report unresolved symbols as errors">; 72 73defm export_dynamic: B<"export-dynamic", 74 "Put symbols in the dynamic symbol table", 75 "Do not put symbols in the dynamic symbol table (default)">; 76 77def end_lib: F<"end-lib">, 78 HelpText<"End a grouping of objects that should be treated as if they were together in an archive">; 79 80def entry: S<"entry">, MetaVarName<"<entry>">, 81 HelpText<"Name of entry point symbol">; 82 83defm error_limit: 84 EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">; 85 86defm fatal_warnings: B<"fatal-warnings", 87 "Treat warnings as errors", 88 "Do not treat warnings as errors (default)">; 89 90defm gc_sections: B<"gc-sections", 91 "Enable garbage collection of unused sections (defualt)", 92 "Disable garbage collection of unused sections">; 93 94defm merge_data_segments: BB<"merge-data-segments", 95 "Enable merging data segments (default)", 96 "Disable merging data segments">; 97 98def help: F<"help">, HelpText<"Print option help">; 99 100def library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">, 101 HelpText<"Root name of library to use">; 102 103def library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">, 104 HelpText<"Add a directory to the library search path">; 105 106def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">; 107 108defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">; 109 110defm Map: Eq<"Map", "Print a link map to the specified file">; 111 112def noinhibit_exec: F<"noinhibit-exec">, 113 HelpText<"Retain the executable output file whenever it is still usable">; 114 115def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">, 116 HelpText<"Path to file to write output">; 117 118def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">; 119 120defm pie: B<"pie", 121 "Create a position independent executable", 122 "Do not create a position independent executable (default)">; 123 124defm print_gc_sections: B<"print-gc-sections", 125 "List removed unused sections", 126 "Do not list removed unused sections (default)">; 127 128def print_map: F<"print-map">, 129 HelpText<"Print a link map to the standard output">; 130 131def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">; 132 133defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">; 134 135defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">, 136 MetaVarName<"[posix,windows]">; 137 138def shared: F<"shared">, HelpText<"Build a shared object">; 139 140def start_lib: F<"start-lib">, 141 HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">; 142 143def strip_all: F<"strip-all">, HelpText<"Strip all symbols">; 144 145def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">; 146 147defm threads 148 : Eq<"threads", "Number of threads. '1' disables multi-threading. By " 149 "default all available hardware threads are used">; 150 151def trace: F<"trace">, HelpText<"Print the names of the input files">; 152 153defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">; 154 155defm undefined: Eq<"undefined", "Force undefined symbol during linking">; 156 157defm unresolved_symbols: 158 Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">; 159 160def v: Flag<["-"], "v">, HelpText<"Display the version number">; 161 162def verbose: F<"verbose">, HelpText<"Verbose mode">; 163 164def version: F<"version">, HelpText<"Display the version number and exit">; 165 166def warn_unresolved_symbols: F<"warn-unresolved-symbols">, 167 HelpText<"Report unresolved symbols as warnings">; 168 169defm wrap: Eq<"wrap", "Use wrapper functions for symbol">, 170 MetaVarName<"<symbol>=<symbol>">; 171 172def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">, 173 HelpText<"Linker option extensions">; 174 175// The follow flags are unique to wasm 176 177def allow_undefined: F<"allow-undefined">, 178 HelpText<"Allow undefined symbols in linked binary. " 179 "This options is equivalent to --import-undefined " 180 "and --unresolved-symbols=ignore-all">; 181 182def import_undefined: F<"import-undefined">, 183 HelpText<"Turn undefined symbols into imports where possible">; 184 185def allow_undefined_file: J<"allow-undefined-file=">, 186 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">; 187 188def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">, 189 Alias<allow_undefined_file>; 190 191defm export: Eq<"export", "Force a symbol to be exported">; 192 193defm export_if_defined: Eq<"export-if-defined", 194 "Force a symbol to be exported, if it is defined in the input">; 195 196def export_all: FF<"export-all">, 197 HelpText<"Export all symbols (normally combined with --no-gc-sections)">; 198 199def export_table: FF<"export-table">, 200 HelpText<"Export function table to the environment">; 201 202def growable_table: FF<"growable-table">, 203 HelpText<"Remove maximum size from function table, allowing table to grow">; 204 205def global_base: JJ<"global-base=">, 206 HelpText<"Memory offset at which to place global data (Defaults to 1024)">; 207 208defm keep_section: Eq<"keep-section", 209 "Preserve a section even when --strip-all is given. This is useful for compiler drivers such as clang or emcc that, for example, depend on the features section for post-link processing. Can be specified multiple times to keep multiple sections">; 210 211def import_memory: FF<"import-memory">, 212 HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">; 213def import_memory_with_name: JJ<"import-memory=">, 214 HelpText<"Import the module's memory from the passed module with the passed name.">, 215 MetaVarName<"<module>,<name>">; 216 217def export_memory: FF<"export-memory">, 218 HelpText<"Export the module's memory with the default name of \"memory\"">; 219def export_memory_with_name: JJ<"export-memory=">, 220 HelpText<"Export the module's memory with the passed name">; 221 222def shared_memory: FF<"shared-memory">, 223 HelpText<"Use shared linear memory">; 224 225defm soname: Eq<"soname", "Set the module name in the generated name section">; 226 227def import_table: FF<"import-table">, 228 HelpText<"Import function table from the environment">; 229 230def initial_heap: JJ<"initial-heap=">, 231 HelpText<"Initial size of the heap">; 232 233def initial_memory: JJ<"initial-memory=">, 234 HelpText<"Initial size of the linear memory">; 235 236def max_memory: JJ<"max-memory=">, 237 HelpText<"Maximum size of the linear memory">; 238 239def no_growable_memory: FF<"no-growable-memory">, 240 HelpText<"Set maximum size of the linear memory to its initial size">; 241 242def no_entry: FF<"no-entry">, 243 HelpText<"Do not output any entry point">; 244 245def no_shlib_sigcheck: FF<"no-shlib-sigcheck">, 246 HelpText<"Do not check signatures of functions defined in shared libraries.">; 247 248def stack_first: FF<"stack-first">, 249 HelpText<"Place stack at start of linear memory rather than after data">; 250 251def table_base: JJ<"table-base=">, 252 HelpText<"Table offset at which to place address taken functions (Defaults to 1)">; 253 254defm whole_archive: B<"whole-archive", 255 "Force load of all members in a static library", 256 "Do not force load of all members in a static library (default)">; 257 258def why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">; 259 260defm check_features: BB<"check-features", 261 "Check feature compatibility of linked objects (default)", 262 "Ignore feature compatibility of linked objects">; 263 264def features: CommaJoined<["--", "-"], "features=">, 265 HelpText<"Comma-separated used features, inferred from input objects by default.">; 266 267def extra_features: CommaJoined<["--", "-"], "extra-features=">, 268 HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">; 269 270// Aliases 271def: JoinedOrSeparate<["-"], "e">, Alias<entry>; 272def: J<"entry=">, Alias<entry>; 273def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">; 274def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">; 275def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 276def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 277def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">; 278def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">; 279def: Flag<["-"], "i">, Alias<initial_memory>; 280def: Separate<["--", "-"], "library">, Alias<library>; 281def: Joined<["--", "-"], "library=">, Alias<library>; 282def: Separate<["--", "-"], "library-path">, Alias<library_path>; 283def: Joined<["--", "-"], "library-path=">, Alias<library_path>; 284def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">; 285def: Flag<["-"], "r">, Alias<relocatable>; 286def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">; 287def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">; 288def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">; 289def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">; 290def: JoinedOrSeparate<["-"], "u">, Alias<undefined>; 291def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">; 292 293// LTO-related options. 294def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">, 295 HelpText<"Optimization level for LTO">; 296def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">, 297 HelpText<"Codegen optimization level for LTO">; 298def lto_partitions: JJ<"lto-partitions=">, 299 HelpText<"Number of LTO codegen partitions">; 300def lto_obj_path_eq: JJ<"lto-obj-path=">; 301def disable_verify: F<"disable-verify">; 302def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">; 303def thinlto_cache_dir: JJ<"thinlto-cache-dir=">, 304 HelpText<"Path to ThinLTO cached object file directory">; 305defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">; 306def thinlto_emit_index_files: FF<"thinlto-emit-index-files">; 307def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">; 308def thinlto_index_only: FF<"thinlto-index-only">; 309def thinlto_index_only_eq: JJ<"thinlto-index-only=">; 310def thinlto_jobs: JJ<"thinlto-jobs=">, 311 HelpText<"Number of ThinLTO jobs. Default to --threads=">; 312def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">; 313def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">; 314def lto_debug_pass_manager: FF<"lto-debug-pass-manager">, 315 HelpText<"Debug new pass manager">; 316 317// Experimental PIC mode. 318def experimental_pic: FF<"experimental-pic">, 319 HelpText<"Enable Experimental PIC">; 320