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