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