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>;
25
26multiclass Eq<string name, string help> {
27  def NAME: Separate<["--", "-"], name>;
28  def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
29    HelpText<help>;
30}
31
32multiclass B<string name, string help1, string help2> {
33  def NAME: Flag<["--", "-"], name>, HelpText<help1>;
34  def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
35}
36
37defm auxiliary: Eq<"auxiliary", "Set DT_AUXILIARY field to the specified name">;
38
39def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
40
41def Bsymbolic_functions: F<"Bsymbolic-functions">,
42  HelpText<"Bind defined function symbols locally">;
43
44def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">;
45
46def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
47
48def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
49
50def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
51  MetaVarName<"[fast,md5,sha1,uuid,0x<hexstring>]">;
52
53defm check_sections: B<"check-sections",
54    "Check section addresses for overlaps (default)",
55    "Do not check section addresses for overlaps">;
56
57defm compress_debug_sections:
58  Eq<"compress-debug-sections", "Compress DWARF debug sections">,
59  MetaVarName<"[none,zlib]">;
60
61defm defsym: Eq<"defsym", "Define a symbol alias">, MetaVarName<"<symbol>=<value>">;
62
63defm optimize_bb_jumps: BB<"optimize-bb-jumps",
64    "Remove direct jumps at the end to the next basic block",
65    "Do not remove any direct jumps at the end to the next basic block (default)">;
66
67defm fortran_common : BB<"fortran-common",
68    "Search archive members for definitions to override COMMON symbols (default)",
69    "Do not search archive members for definitions to override COMMON symbols">;
70
71defm split_stack_adjust_size
72    : Eq<"split-stack-adjust-size",
73         "Specify adjustment to stack size when a split-stack function calls a "
74         "non-split-stack function">,
75      MetaVarName<"<value>">;
76
77defm library_path:
78  Eq<"library-path", "Add a directory to the library search path">, MetaVarName<"<dir>">;
79
80def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
81
82defm Tbss: Eq<"Tbss", "Same as --section-start with .bss as the sectionname">;
83
84defm Tdata: Eq<"Tdata", "Same as --section-start with .data as the sectionname">;
85
86defm Ttext: Eq<"Ttext", "Same as --section-start with .text as the sectionname">;
87
88def Ttext_segment: Separate<["-", "--"], "Ttext-segment">;
89
90defm allow_multiple_definition: B<"allow-multiple-definition",
91    "Allow multiple definitions",
92    "Do not allow multiple definitions (default)">;
93
94defm allow_shlib_undefined: B<"allow-shlib-undefined",
95    "Allow unresolved references in shared libraries (default when linking a shared library)",
96    "Do not allow unresolved references in shared libraries (default when linking an executable)">;
97
98defm apply_dynamic_relocs: BB<"apply-dynamic-relocs",
99    "Apply link-time values for dynamic relocations",
100    "Do not apply link-time values for dynamic relocations (default)">;
101
102defm dependent_libraries: BB<"dependent-libraries",
103    "Process dependent library specifiers from input files (default)",
104    "Ignore dependent library specifiers from input files">;
105
106defm as_needed: B<"as-needed",
107    "Only set DT_NEEDED for shared libraries if used",
108    "Always set DT_NEEDED for shared libraries (default)">;
109
110defm call_graph_ordering_file:
111  Eq<"call-graph-ordering-file", "Layout sections to optimize the given callgraph">;
112
113defm call_graph_profile_sort: BB<"call-graph-profile-sort",
114    "Reorder sections with call graph profile (default)",
115    "Do not reorder sections with call graph profile">;
116
117// -chroot doesn't have a help text because it is an internal option.
118def chroot: Separate<["--", "-"], "chroot">;
119
120defm color_diagnostics: B<"color-diagnostics",
121  "Alias for --color-diagnostics=always",
122  "Alias for --color-diagnostics=never">;
123def color_diagnostics_eq: J<"color-diagnostics=">,
124  HelpText<"Use colors in diagnostics (default: auto)">,
125  MetaVarName<"[auto,always,never]">;
126
127defm cref: B<"cref",
128    "Output cross reference table",
129    "Do not output cross reference table">;
130
131defm define_common: B<"define-common",
132    "Assign space to common symbols",
133    "Do not assign space to common symbols">;
134
135defm demangle: B<"demangle",
136    "Demangle symbol names (default)",
137    "Do not demangle symbol names">;
138
139defm dependency_file: EEq<"dependency-file", "Write a dependency file">,
140  MetaVarName<"<file>">;
141
142def disable_new_dtags: F<"disable-new-dtags">,
143  HelpText<"Disable new dynamic tags">;
144
145def discard_all: F<"discard-all">, HelpText<"Delete all local symbols">;
146
147def discard_locals: F<"discard-locals">,
148  HelpText<"Delete temporary local symbols">;
149
150def discard_none: F<"discard-none">,
151  HelpText<"Keep all symbols in the symbol table">;
152
153defm dynamic_linker: Eq<"dynamic-linker", "Which dynamic linker to use">;
154
155defm dynamic_list : Eq<"dynamic-list",
156   "Read a list of dynamic symbols. (executable) Put matched non-local defined"
157   "symbols to the dynamic symbol table. (shared object) References to matched"
158   "non-local STV_DEFAULT symbols shouldn't be bound to definitions within the "
159   "shared object. Implies -Bsymbolic but does not set DF_SYMBOLIC">,
160   MetaVarName<"<file>">;
161
162defm eh_frame_hdr: B<"eh-frame-hdr",
163    "Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header",
164    "Do not create .eh_frame_hdr section">;
165
166def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
167
168def enable_new_dtags: F<"enable-new-dtags">,
169  HelpText<"Enable new dynamic tags (default)">;
170
171def end_group: F<"end-group">,
172  HelpText<"Ignored for compatibility with GNU unless you pass --warn-backrefs">;
173
174def end_lib: F<"end-lib">,
175  HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
176
177defm entry: Eq<"entry", "Name of entry point symbol">,
178  MetaVarName<"<entry>">;
179
180defm error_limit:
181  Eq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
182
183def error_unresolved_symbols: F<"error-unresolved-symbols">,
184  HelpText<"Report unresolved symbols as errors">;
185
186defm error_handling_script: EEq<"error-handling-script",
187    "Specify an error handling script">;
188
189defm exclude_libs: Eq<"exclude-libs", "Exclude static libraries from automatic export">;
190
191defm execute_only: BB<"execute-only",
192    "Mark executable sections unreadable",
193    "Mark executable sections readable (default)">;
194
195defm export_dynamic: B<"export-dynamic",
196    "Put symbols in the dynamic symbol table",
197    "Do not put symbols in the dynamic symbol table (default)">;
198
199defm export_dynamic_symbol : EEq<"export-dynamic-symbol",
200    "(executable) Put matched symbols in the dynamic symbol table. "
201    "(shared object) References to matched non-local STV_DEFAULT symbols "
202    "shouldn't be bound to definitions within the shared object. "
203    "Does not imply -Bsymbolic.">,
204    MetaVarName<"glob">;
205
206defm fatal_warnings: B<"fatal-warnings",
207    "Treat warnings as errors",
208    "Do not treat warnings as errors (default)">;
209
210defm filter: Eq<"filter", "Set DT_FILTER field to the specified name">;
211
212defm fini: Eq<"fini", "Specify a finalizer function">, MetaVarName<"<symbol>">;
213
214def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
215  HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
216
217def fix_cortex_a8: F<"fix-cortex-a8">,
218  HelpText<"Apply fixes for ARM Cortex-A8 erratum 657417">;
219
220defm format: Eq<"format", "Change the input format of the inputs following this option">,
221  MetaVarName<"[default,elf,binary]">;
222
223defm gc_sections: B<"gc-sections",
224    "Enable garbage collection of unused sections",
225    "Disable garbage collection of unused sections (default)">;
226
227defm gdb_index: BB<"gdb-index",
228    "Generate .gdb_index section",
229    "Do not generate .gdb_index section (default)">;
230
231defm gnu_unique: BB<"gnu-unique",
232  "Enable STB_GNU_UNIQUE symbol binding (default)",
233  "Disable STB_GNU_UNIQUE symbol binding">;
234
235defm hash_style: Eq<"hash-style", "Specify hash style (sysv, gnu or both)">;
236
237def help: F<"help">, HelpText<"Print option help">;
238
239def icf_all: F<"icf=all">, HelpText<"Enable identical code folding">;
240
241def icf_safe: F<"icf=safe">, HelpText<"Enable safe identical code folding">;
242
243def icf_none: F<"icf=none">, HelpText<"Disable identical code folding (default)">;
244
245def ignore_function_address_equality: F<"ignore-function-address-equality">,
246  HelpText<"lld can break the address equality of functions">;
247
248def ignore_data_address_equality: F<"ignore-data-address-equality">,
249  HelpText<"lld can break the address equality of data">;
250
251defm image_base: Eq<"image-base", "Set the base address">;
252
253defm init: Eq<"init", "Specify an initializer function">,
254  MetaVarName<"<symbol>">;
255
256defm just_symbols: Eq<"just-symbols", "Just link symbols">;
257
258defm keep_unique: Eq<"keep-unique", "Do not fold this symbol during ICF">;
259
260defm library: Eq<"library", "Root name of library to use">,
261  MetaVarName<"<libName>">;
262
263def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
264
265defm Map: Eq<"Map", "Print a link map to the specified file">;
266
267defm merge_exidx_entries: B<"merge-exidx-entries",
268    "Enable merging .ARM.exidx entries (default)",
269    "Disable merging .ARM.exidx entries">;
270
271defm mmap_output_file: BB<"mmap-output-file",
272    "Mmap the output file for writing (default)",
273    "Do not mmap the output file for writing">;
274
275def nmagic: F<"nmagic">, MetaVarName<"<magic>">,
276  HelpText<"Do not page align sections, link against static libraries.">;
277
278def nostdlib: F<"nostdlib">,
279  HelpText<"Only search directories specified on the command line">;
280
281def no_dynamic_linker: F<"no-dynamic-linker">,
282  HelpText<"Inhibit output of .interp section">;
283
284def noinhibit_exec: F<"noinhibit-exec">,
285  HelpText<"Retain the executable output file whenever it is still usable">;
286
287def no_nmagic: F<"no-nmagic">, MetaVarName<"<magic>">,
288  HelpText<"Page align sections (default)">;
289
290def no_omagic: F<"no-omagic">, MetaVarName<"<magic>">,
291  HelpText<"Do not set the text data sections to be writable, page align sections (default)">;
292
293def no_undefined: F<"no-undefined">,
294  HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
295
296def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
297  HelpText<"Path to file to write output">;
298
299def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">,
300  HelpText<"Specify the binary format for the output object file">;
301
302def omagic: FF<"omagic">, MetaVarName<"<magic>">,
303  HelpText<"Set the text and data sections to be readable and writable, do not page align sections, link against static libraries">;
304
305defm orphan_handling:
306  Eq<"orphan-handling", "Control how orphan sections are handled when linker script used">;
307
308defm pack_dyn_relocs:
309  Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
310  MetaVarName<"[none,android,relr,android+relr]">;
311
312defm use_android_relr_tags: BB<"use-android-relr-tags",
313    "Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*",
314    "Use SHT_RELR / DT_RELR* tags (default)">;
315
316def pic_veneer: F<"pic-veneer">,
317  HelpText<"Always generate position independent thunks (veneers)">;
318
319defm pie: B<"pie",
320    "Create a position independent executable",
321    "Do not create a position independent executable (default)">;
322
323defm print_gc_sections: B<"print-gc-sections",
324    "List removed unused sections",
325    "Do not list removed unused sections (default)">;
326
327defm print_icf_sections: B<"print-icf-sections",
328    "List identical folded sections",
329    "Do not list identical folded sections (default)">;
330
331def print_archive_stats: J<"print-archive-stats=">,
332  HelpText<"Write archive usage statistics to the specified file. "
333           "Print the numbers of members and fetched members for each archive">;
334
335defm print_symbol_order: Eq<"print-symbol-order",
336  "Print a symbol order specified by --call-graph-ordering-file into the specified file">;
337
338def pop_state: F<"pop-state">,
339  HelpText<"Undo the effect of -push-state">;
340
341def push_state: F<"push-state">,
342  HelpText<"Save the current state of -as-needed, -static and -whole-archive">;
343
344def print_map: F<"print-map">,
345  HelpText<"Print a link map to the standard output">;
346
347defm reproduce:
348  Eq<"reproduce",
349     "Write tar file containing inputs and command to reproduce link">;
350
351defm rosegment: BB<"rosegment",
352  "Put read-only non-executable sections in their own segment (default)",
353  "Do not put read-only non-executable sections in their own segment">;
354
355defm rpath: Eq<"rpath", "Add a DT_RUNPATH to the output">;
356
357def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
358
359defm retain_symbols_file:
360  Eq<"retain-symbols-file", "Retain only the symbols listed in the file">,
361  MetaVarName<"<file>">;
362
363defm script: Eq<"script", "Read linker script">;
364
365defm section_start: Eq<"section-start", "Set address of section">,
366  MetaVarName<"<address>">;
367
368def shared: F<"shared">, HelpText<"Build a shared object">;
369
370defm soname: Eq<"soname", "Set DT_SONAME">;
371
372defm sort_section:
373  Eq<"sort-section", "Specifies sections sorting rule when linkerscript is used">;
374
375def start_group: F<"start-group">,
376  HelpText<"Ignored for compatibility with GNU unless you pass --warn-backrefs">;
377
378def start_lib: F<"start-lib">,
379  HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">;
380
381def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
382
383def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
384
385defm symbol_ordering_file:
386  Eq<"symbol-ordering-file", "Layout sections to place symbols in the order specified by symbol ordering file">;
387
388defm sysroot: Eq<"sysroot", "Set the system root">;
389
390def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
391
392def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
393
394defm target2:
395  Eq<"target2", "Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">,
396  MetaVarName<"<type>">;
397
398defm threads
399    : Eq<"threads",
400         "Number of threads. '1' disables multi-threading. By default all "
401         "available hardware threads are used">;
402
403def time_trace: FF<"time-trace">, HelpText<"Record time trace">;
404def time_trace_file_eq: JJ<"time-trace-file=">, HelpText<"Specify time trace output file">;
405
406defm time_trace_granularity: EEq<"time-trace-granularity",
407  "Minimum time granularity (in microseconds) traced by time profiler">;
408
409defm toc_optimize : BB<"toc-optimize",
410    "(PowerPC64) Enable TOC related optimizations (default)",
411    "(PowerPC64) Disable TOC related optimizations">;
412
413defm pcrel_optimize : BB<"pcrel-optimize",
414    "(PowerPC64) Enable PC-relative optimizations (default)",
415    "(PowerPC64) Disable PC-relative optimizations">;
416
417def trace: F<"trace">, HelpText<"Print the names of the input files">;
418
419defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
420
421defm undefined: Eq<"undefined", "Force undefined symbol during linking">,
422  MetaVarName<"<symbol>">;
423
424defm undefined_glob: EEq<"undefined-glob", "Force undefined symbol during linking">,
425  MetaVarName<"<pattern>">;
426
427def unique: F<"unique">, HelpText<"Creates a separate output section for every orphan input section">;
428
429defm unresolved_symbols:
430  Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
431
432defm undefined_version: B<"undefined-version",
433  "Allow unused version in version script (default)",
434  "Report version scripts that refer undefined symbols">;
435
436defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
437  MetaVarName<"[posix,windows]">;
438
439def v: Flag<["-"], "v">, HelpText<"Display the version number">;
440
441def verbose: F<"verbose">, HelpText<"Verbose mode">;
442
443def version: F<"version">, HelpText<"Display the version number and exit">;
444
445defm version_script: Eq<"version-script", "Read a version script">;
446
447defm warn_backrefs: BB<"warn-backrefs",
448    "Warn about backward symbol references to fetch archive members",
449    "Do not warn about backward symbol references to fetch archive members (default)">;
450
451defm warn_backrefs_exclude
452    : EEq<"warn-backrefs-exclude",
453         "Glob describing an archive (or an object file within --start-lib) "
454         "which should be ignored for --warn-backrefs.">,
455      MetaVarName<"<glob>">;
456
457defm warn_common: B<"warn-common",
458    "Warn about duplicate common symbols",
459    "Do not warn about duplicate common symbols (default)">;
460
461defm warn_ifunc_textrel: BB<"warn-ifunc-textrel",
462    "Warn about using ifunc symbols with text relocations",
463    "Do not warn about using ifunc symbols with text relocations (default)">;
464
465defm warn_symbol_ordering: BB<"warn-symbol-ordering",
466    "Warn about problems with the symbol ordering file (default)",
467    "Do not warn about problems with the symbol ordering file">;
468
469def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
470  HelpText<"Report unresolved symbols as warnings">;
471
472defm whole_archive: B<"whole-archive",
473    "Force load of all members in a static library",
474    "Do not force load of all members in a static library (default)">;
475
476defm wrap : Eq<"wrap", "Redirect symbol references to __wrap_symbol and "
477                       "__real_symbol references to symbol">,
478            MetaVarName<"<symbol>">;
479
480def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
481  HelpText<"Linker option extensions">;
482
483def visual_studio_diagnostics_format : F<"vs-diagnostics">,
484HelpText<"Format diagnostics for Visual Studio compatibility">;
485
486// Aliases
487def: Separate<["-"], "f">, Alias<auxiliary>, HelpText<"Alias for --auxiliary">;
488def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
489def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
490def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
491def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
492def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
493def: Flag<["-"], "d">, Alias<define_common>, HelpText<"Alias for --define-common">;
494def: F<"dc">, Alias<define_common>, HelpText<"Alias for --define-common">;
495def: F<"dp">, Alias<define_common>, HelpText<"Alias for --define-common">;
496def: Flag<["-"], "x">, Alias<discard_all>, HelpText<"Alias for --discard-all">;
497def: Flag<["-"], "X">, Alias<discard_locals>, HelpText<"Alias for --discard-locals">;
498def: Flag<["-"], "q">, Alias<emit_relocs>, HelpText<"Alias for --emit-relocs">;
499def: Flag<["-"], ")">, Alias<end_group>, HelpText<"Alias for --end-group">;
500def: JoinedOrSeparate<["-"], "e">, Alias<entry>, HelpText<"Alias for --entry">;
501def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
502def: Separate<["-"], "F">, Alias<filter>, HelpText<"Alias for --filter">;
503def: Separate<["-"], "b">, Alias<format>, HelpText<"Alias for --format">;
504def: JoinedOrSeparate<["-"], "l">, Alias<library>, HelpText<"Alias for --library">;
505def: JoinedOrSeparate<["-"], "L">, Alias<library_path>, HelpText<"Alias for --library-path">;
506def: F<"no-pic-executable">, Alias<no_pie>, HelpText<"Alias for --no-pie">;
507def: Flag<["-"], "n">, Alias<nmagic>, HelpText<"Alias for --nmagic">;
508def: Flag<["-"], "N">, Alias<omagic>, HelpText<"Alias for --omagic">;
509def: Joined<["--"], "output=">, Alias<o>, HelpText<"Alias for -o">;
510def: Separate<["--"], "output">, Alias<o>, HelpText<"Alias for -o">;
511def: F<"pic-executable">, Alias<pie>, HelpText<"Alias for --pie">;
512def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
513def: Flag<["-"], "r">, Alias<relocatable>, HelpText<"Alias for --relocatable">;
514def: JoinedOrSeparate<["-"], "R">, Alias<rpath>, HelpText<"Alias for --rpath">;
515def: JoinedOrSeparate<["-"], "T">, Alias<script>, HelpText<"Alias for --script">;
516def: F<"Bshareable">, Alias<shared>, HelpText<"Alias for --shared">;
517def: JoinedOrSeparate<["-"], "h">, Alias<soname>, HelpText<"Alias for --soname">;
518def: Flag<["-"], "(">, Alias<start_group>, HelpText<"Alias for --start-group">;
519def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
520def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
521def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
522def: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext_segment>;
523def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
524def: JoinedOrSeparate<["-"], "u">, Alias<undefined>, HelpText<"Alias for --undefined">;
525def: Flag<["-"], "V">, Alias<version>, HelpText<"Alias for --version">;
526
527// LTO-related options.
528def lto_aa_pipeline: JJ<"lto-aa-pipeline=">,
529  HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">;
530def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
531  HelpText<"Debug new pass manager">;
532def lto_emit_asm: FF<"lto-emit-asm">,
533  HelpText<"Emit assembly code">;
534defm lto_legacy_pass_manager: BB<"lto-legacy-pass-manager",
535  "Use the legacy pass manager in LLVM",
536  "Use the new pass manager in LLVM">;
537def lto_newpm_passes: JJ<"lto-newpm-passes=">,
538  HelpText<"Passes to run during LTO">;
539def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
540  HelpText<"Optimization level for LTO">;
541def lto_partitions: JJ<"lto-partitions=">,
542  HelpText<"Number of LTO codegen partitions">;
543def lto_cs_profile_generate: FF<"lto-cs-profile-generate">,
544  HelpText<"Perform context sensitive PGO instrumentation">;
545def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
546  HelpText<"Context sensitive profile file path">;
547def lto_obj_path_eq: JJ<"lto-obj-path=">;
548def lto_sample_profile: JJ<"lto-sample-profile=">,
549  HelpText<"Sample profile file path">;
550defm lto_whole_program_visibility: BB<"lto-whole-program-visibility",
551  "Asserts that the LTO link has whole program visibility",
552  "Asserts that the LTO link does not have whole program visibility">;
553def lto_pseudo_probe_for_profiling: F<"lto-pseudo-probe-for-profiling">,
554  HelpText<"Emit pseudo probes for sample profiling">;
555def disable_verify: F<"disable-verify">;
556defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
557def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
558  HelpText<"YAML output file for optimization remarks">;
559defm opt_remarks_hotness_threshold: EEq<"opt-remarks-hotness-threshold",
560  "Minimum profile count required for an optimization remark to be output."
561  " Use 'auto' to apply the threshold from profile summary.">,
562  MetaVarName<"<value>">;
563def opt_remarks_passes: Separate<["--"], "opt-remarks-passes">,
564  HelpText<"Regex for the passes that need to be serialized to the output file">;
565def opt_remarks_with_hotness: FF<"opt-remarks-with-hotness">,
566  HelpText<"Include hotness information in the optimization remarks file">;
567def opt_remarks_format: Separate<["--"], "opt-remarks-format">,
568  HelpText<"The format used for serializing remarks (default: YAML)">;
569def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
570def lto_basic_block_sections: JJ<"lto-basic-block-sections=">,
571  HelpText<"Enable basic block sections for LTO">;
572defm lto_unique_basic_block_section_names: BB<"lto-unique-basic-block-section-names",
573    "Give unique names to every basic block section for LTO",
574    "Do not give unique names to every basic block section for LTO (default)">;
575def shuffle_sections: JJ<"shuffle-sections=">, MetaVarName<"<seed>">,
576  HelpText<"Shuffle input sections using the given seed. If 0, use a random seed">;
577def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
578  HelpText<"Path to ThinLTO cached object file directory">;
579defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
580def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;
581def thinlto_index_only: FF<"thinlto-index-only">;
582def thinlto_index_only_eq: JJ<"thinlto-index-only=">;
583def thinlto_jobs: JJ<"thinlto-jobs=">,
584  HelpText<"Number of ThinLTO jobs. Default to --threads=">;
585def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;
586def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;
587def thinlto_single_module_eq: JJ<"thinlto-single-module=">,
588  HelpText<"Specific a single module to compile in ThinLTO mode, for debugging only">;
589
590def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for --lto-O">;
591def: F<"plugin-opt=debug-pass-manager">,
592  Alias<lto_debug_pass_manager>, HelpText<"Alias for --lto-debug-pass-manager">;
593def: F<"plugin-opt=disable-verify">, Alias<disable_verify>, HelpText<"Alias for --disable-verify">;
594def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
595  HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
596def plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,
597  Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;
598def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;
599def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs>, HelpText<"Alias for --thinlto-jobs">;
600def: J<"plugin-opt=lto-partitions=">, Alias<lto_partitions>, HelpText<"Alias for --lto-partitions">;
601def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
602def: F<"plugin-opt=new-pass-manager">,
603  Alias<no_lto_legacy_pass_manager>, HelpText<"Alias for --no-lto-legacy-pass-manager">;
604def: F<"plugin-opt=legacy-pass-manager">,
605  Alias<lto_legacy_pass_manager>, HelpText<"Alias for --no-legacy-pass-manager">;
606def: F<"plugin-opt=cs-profile-generate">,
607  Alias<lto_cs_profile_generate>, HelpText<"Alias for --lto-cs-profile-generate">;
608def: J<"plugin-opt=cs-profile-path=">,
609  Alias<lto_cs_profile_file>, HelpText<"Alias for --lto-cs-profile-file">;
610def: J<"plugin-opt=obj-path=">,
611  Alias<lto_obj_path_eq>,
612  HelpText<"Alias for --lto-obj-path=">;
613def: J<"plugin-opt=opt-remarks-filename=">,
614  Alias<opt_remarks_filename>,
615  HelpText<"Alias for --opt-remarks-filename">;
616def: J<"plugin-opt=opt-remarks-passes=">,
617  Alias<opt_remarks_passes>,
618  HelpText<"Alias for --opt-remarks-passes">;
619def: J<"plugin-opt=opt-remarks-format=">,
620  Alias<opt_remarks_format>,
621  HelpText<"Alias for --opt-remarks-format">;
622def: F<"plugin-opt=opt-remarks-with-hotness">,
623  Alias<opt_remarks_with_hotness>,
624  HelpText<"Alias for --opt-remarks-with_hotness">;
625def: J<"plugin-opt=opt-remarks-hotness-threshold=">,
626  Alias<opt_remarks_hotness_threshold>,
627  HelpText<"Alias for --opt-remarks-hotness-threshold">;
628def: J<"plugin-opt=pseudo-probe-for-profiling">,
629  Alias<lto_pseudo_probe_for_profiling>, HelpText<"Alias for --lto-pseudo-probe-for-profiling">;
630def: J<"plugin-opt=sample-profile=">,
631  Alias<lto_sample_profile>, HelpText<"Alias for --lto-sample-profile">;
632def: F<"plugin-opt=save-temps">, Alias<save_temps>, HelpText<"Alias for --save-temps">;
633def: F<"plugin-opt=thinlto-emit-imports-files">,
634  Alias<thinlto_emit_imports_files>,
635  HelpText<"Alias for --thinlto-emit-imports-files">;
636def: F<"plugin-opt=thinlto-index-only">,
637  Alias<thinlto_index_only>,
638  HelpText<"Alias for --thinlto-index-only">;
639def: J<"plugin-opt=thinlto-index-only=">,
640  Alias<thinlto_index_only_eq>,
641  HelpText<"Alias for --thinlto-index-only=">;
642def: J<"plugin-opt=thinlto-object-suffix-replace=">,
643 Alias<thinlto_object_suffix_replace_eq>,
644 HelpText<"Alias for --thinlto-object-suffix-replace=">;
645def: J<"plugin-opt=thinlto-prefix-replace=">,
646  Alias<thinlto_prefix_replace_eq>,
647  HelpText<"Alias for --thinlto-prefix-replace=">;
648
649// Ignore LTO plugin-related options.
650// clang -flto passes -plugin and -plugin-opt to the linker. This is required
651// for ld.gold and ld.bfd to get LTO working. But it's not for lld which doesn't
652// rely on a plugin. Instead of detecting which linker is used on clang side we
653// just ignore the option on lld side as it's easier. In fact, the linker could
654// be called 'ld' and understanding which linker is used would require parsing of
655// --version output.
656defm plugin: Eq<"plugin", "Ignored for compatibility with GNU linkers">;
657
658def plugin_opt_eq_minus: J<"plugin-opt=-">,
659  HelpText<"Specify an LLVM option for compatibility with LLVMgold.so">;
660def: J<"plugin-opt=thinlto">;
661
662// Ignore GCC collect2 LTO plugin related options. Note that we don't support
663// GCC LTO, but GCC collect2 passes these options even in non-LTO mode.
664def: J<"plugin-opt=-fresolution=">;
665def: J<"plugin-opt=-pass-through=">;
666// This may be either an unhandled LLVMgold.so feature or GCC passed
667// -plugin-opt=path/to/{liblto_plugin.so,lto-wrapper}
668def plugin_opt_eq : J<"plugin-opt=">;
669
670// Options listed below are silently ignored for now for compatibility.
671def: F<"detect-odr-violations">;
672def: Flag<["-"], "g">;
673def: F<"long-plt">;
674def: F<"no-add-needed">;
675def: F<"no-copy-dt-needed-entries">;
676def: F<"no-ctors-in-init-array">;
677def: F<"no-keep-memory">;
678def: F<"no-pipeline-knowledge">;
679def: F<"no-relax">;
680def: F<"no-warn-mismatch">;
681def: Flag<["-"], "p">;
682def: Separate<["--", "-"], "rpath-link">;
683def: J<"rpath-link=">;
684def: F<"secure-plt">;
685def: F<"sort-common">;
686def: F<"stats">;
687def: F<"warn-execstack">;
688def: F<"warn-once">;
689def: F<"warn-shared-textrel">;
690def: F<"EB">;
691def: F<"EL">;
692def: JoinedOrSeparate<["-"], "G">;
693def: F<"Qy">;
694
695// Hidden option used for testing MIPS multi-GOT implementation.
696defm mips_got_size:
697  Eq<"mips-got-size", "Max size of a single MIPS GOT. 0x10000 by default.">,
698  Flags<[HelpHidden]>;
699