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