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