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