1 include "llvm/Option/OptParser.td"
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
7 class FF<string name> : Flag<["--"], name>;
8 class JJ<string name>: Joined<["--"], name>;
10 multiclass EEq<string name, string help> {
11 def NAME: Separate<["--"], name>;
12 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
16 multiclass BB<string name, string help1, string help2> {
17 def NAME: Flag<["--"], name>, HelpText<help1>;
18 def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
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'.
23 class F<string name>: Flag<["--", "-"], name>;
24 class J<string name>: Joined<["--", "-"], name>;
25 class S<string name>: Separate<["--", "-"], name>;
27 multiclass Eq<string name, string help> {
28 def NAME: Separate<["--", "-"], name>;
29 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
33 multiclass B<string name, string help1, string help2> {
34 def NAME: Flag<["--", "-"], name>, HelpText<help1>;
35 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
38 // The following flags are shared with the ELF linker
39 def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
41 def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
43 def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries (default)">;
45 defm allow_multiple_definition: B<"allow-multiple-definition",
46 "Allow multiple definitions",
47 "Do not allow multiple definitions (default)">;
49 def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
51 def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
52 MetaVarName<"[fast,sha1,uuid,0x<hexstring>]">;
54 defm color_diagnostics: B<"color-diagnostics",
55 "Alias for --color-diagnostics=always",
56 "Alias for --color-diagnostics=never">;
57 def color_diagnostics_eq: J<"color-diagnostics=">,
58 HelpText<"Use colors in diagnostics (default: auto)">,
59 MetaVarName<"[auto,always,never]">;
61 def compress_relocations: F<"compress-relocations">,
62 HelpText<"Compress the relocation targets in the code section.">;
64 defm demangle: B<"demangle",
65 "Demangle symbol names (default)",
66 "Do not demangle symbol names">;
68 def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
70 def error_unresolved_symbols: F<"error-unresolved-symbols">,
71 HelpText<"Report unresolved symbols as errors">;
73 defm export_dynamic: B<"export-dynamic",
74 "Put symbols in the dynamic symbol table",
75 "Do not put symbols in the dynamic symbol table (default)">;
77 def end_lib: F<"end-lib">,
78 HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
80 def entry: S<"entry">, MetaVarName<"<entry>">,
81 HelpText<"Name of entry point symbol">;
84 EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
86 defm fatal_warnings: B<"fatal-warnings",
87 "Treat warnings as errors",
88 "Do not treat warnings as errors (default)">;
90 defm gc_sections: B<"gc-sections",
91 "Enable garbage collection of unused sections (defualt)",
92 "Disable garbage collection of unused sections">;
94 defm merge_data_segments: BB<"merge-data-segments",
95 "Enable merging data segments (default)",
96 "Disable merging data segments">;
98 def help: F<"help">, HelpText<"Print option help">;
100 def library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
101 HelpText<"Root name of library to use">;
103 def library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
104 HelpText<"Add a directory to the library search path">;
106 def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
108 defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
110 defm Map: Eq<"Map", "Print a link map to the specified file">;
112 def noinhibit_exec: F<"noinhibit-exec">,
113 HelpText<"Retain the executable output file whenever it is still usable">;
115 def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
116 HelpText<"Path to file to write output">;
118 def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
121 "Create a position independent executable",
122 "Do not create a position independent executable (default)">;
124 defm print_gc_sections: B<"print-gc-sections",
125 "List removed unused sections",
126 "Do not list removed unused sections (default)">;
128 def print_map: F<"print-map">,
129 HelpText<"Print a link map to the standard output">;
131 def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
133 defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
135 defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
136 MetaVarName<"[posix,windows]">;
138 def shared: F<"shared">, HelpText<"Build a shared object">;
140 def start_lib: F<"start-lib">,
141 HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">;
143 def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
145 def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
148 : Eq<"threads", "Number of threads. '1' disables multi-threading. By "
149 "default all available hardware threads are used">;
151 def trace: F<"trace">, HelpText<"Print the names of the input files">;
153 defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
155 defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
157 defm unresolved_symbols:
158 Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
160 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
162 def verbose: F<"verbose">, HelpText<"Verbose mode">;
164 def version: F<"version">, HelpText<"Display the version number and exit">;
166 def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
167 HelpText<"Report unresolved symbols as warnings">;
169 defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
170 MetaVarName<"<symbol>=<symbol>">;
172 def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
173 HelpText<"Linker option extensions">;
175 // The follow flags are unique to wasm
177 def 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">;
182 def import_undefined: F<"import-undefined">,
183 HelpText<"Turn undefined symbols into imports where possible">;
185 def allow_undefined_file: J<"allow-undefined-file=">,
186 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
188 def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
189 Alias<allow_undefined_file>;
191 defm export: Eq<"export", "Force a symbol to be exported">;
193 defm export_if_defined: Eq<"export-if-defined",
194 "Force a symbol to be exported, if it is defined in the input">;
196 def export_all: FF<"export-all">,
197 HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
199 def export_table: FF<"export-table">,
200 HelpText<"Export function table to the environment">;
202 def growable_table: FF<"growable-table">,
203 HelpText<"Remove maximum size from function table, allowing table to grow">;
205 def global_base: JJ<"global-base=">,
206 HelpText<"Memory offset at which to place global data (Defaults to 1024)">;
208 defm 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">;
211 def import_memory: FF<"import-memory">,
212 HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">;
213 def 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>">;
217 def export_memory: FF<"export-memory">,
218 HelpText<"Export the module's memory with the default name of \"memory\"">;
219 def export_memory_with_name: JJ<"export-memory=">,
220 HelpText<"Export the module's memory with the passed name">;
222 def shared_memory: FF<"shared-memory">,
223 HelpText<"Use shared linear memory">;
225 defm soname: Eq<"soname", "Set the module name in the generated name section">;
227 def import_table: FF<"import-table">,
228 HelpText<"Import function table from the environment">;
230 def initial_heap: JJ<"initial-heap=">,
231 HelpText<"Initial size of the heap">;
233 def initial_memory: JJ<"initial-memory=">,
234 HelpText<"Initial size of the linear memory">;
236 def max_memory: JJ<"max-memory=">,
237 HelpText<"Maximum size of the linear memory">;
239 def no_growable_memory: FF<"no-growable-memory">,
240 HelpText<"Set maximum size of the linear memory to its initial size">;
242 def no_entry: FF<"no-entry">,
243 HelpText<"Do not output any entry point">;
245 def no_shlib_sigcheck: FF<"no-shlib-sigcheck">,
246 HelpText<"Do not check signatures of functions defined in shared libraries.">;
248 def stack_first: FF<"stack-first">,
249 HelpText<"Place stack at start of linear memory rather than after data">;
251 def table_base: JJ<"table-base=">,
252 HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
254 defm 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)">;
258 def why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">;
260 defm check_features: BB<"check-features",
261 "Check feature compatibility of linked objects (default)",
262 "Ignore feature compatibility of linked objects">;
264 def features: CommaJoined<["--", "-"], "features=">,
265 HelpText<"Comma-separated used features, inferred from input objects by default.">;
267 def extra_features: CommaJoined<["--", "-"], "extra-features=">,
268 HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">;
271 def: JoinedOrSeparate<["-"], "e">, Alias<entry>;
272 def: J<"entry=">, Alias<entry>;
273 def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
274 def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
275 def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
276 def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
277 def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
278 def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
279 def: Flag<["-"], "i">, Alias<initial_memory>;
280 def: Separate<["--", "-"], "library">, Alias<library>;
281 def: Joined<["--", "-"], "library=">, Alias<library>;
282 def: Separate<["--", "-"], "library-path">, Alias<library_path>;
283 def: Joined<["--", "-"], "library-path=">, Alias<library_path>;
284 def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
285 def: Flag<["-"], "r">, Alias<relocatable>;
286 def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
287 def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
288 def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
289 def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
290 def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
291 def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">;
293 // LTO-related options.
294 def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
295 HelpText<"Optimization level for LTO">;
296 def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">,
297 HelpText<"Codegen optimization level for LTO">;
298 def lto_partitions: JJ<"lto-partitions=">,
299 HelpText<"Number of LTO codegen partitions">;
300 def lto_obj_path_eq: JJ<"lto-obj-path=">;
301 def disable_verify: F<"disable-verify">;
302 def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
303 def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
304 HelpText<"Path to ThinLTO cached object file directory">;
305 defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
306 def thinlto_emit_index_files: FF<"thinlto-emit-index-files">;
307 def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;
308 def thinlto_index_only: FF<"thinlto-index-only">;
309 def thinlto_index_only_eq: JJ<"thinlto-index-only=">;
310 def thinlto_jobs: JJ<"thinlto-jobs=">,
311 HelpText<"Number of ThinLTO jobs. Default to --threads=">;
312 def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;
313 def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;
314 def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
315 HelpText<"Debug new pass manager">;
317 // Experimental PIC mode.
318 def experimental_pic: FF<"experimental-pic">,
319 HelpText<"Enable Experimental PIC">;