1 include "llvm/Option/OptParser.td"
3 // For options whose names are multiple letters, either one dash or
4 // two can precede the option name except those that start with 'o'.
5 class F<string name>: Flag<["--", "-"], name>;
6 class J<string name>: Joined<["--", "-"], name>;
7 class S<string name>: Separate<["--", "-"], name>;
9 multiclass Eq<string name> {
10 def "": Separate<["--", "-"], name>;
11 def _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
14 def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">;
16 def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
18 def Bsymbolic_functions: F<"Bsymbolic-functions">,
19 HelpText<"Bind defined function symbols locally">;
21 def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
23 def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
25 def build_id: F<"build-id">, HelpText<"Generate build ID note">;
27 def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">;
29 defm compress_debug_sections : Eq<"compress-debug-sections">,
30 HelpText<"Compress DWARF debug sections">;
32 defm defsym: Eq<"defsym">, HelpText<"Define a symbol alias">;
34 defm library_path: Eq<"library-path">,
35 HelpText<"Add a directory to the library search path">, MetaVarName<"<dir>">;
37 def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
39 defm Tbss: Eq<"Tbss">,
40 HelpText<"Same as --section-start with .bss as the sectionname">;
42 defm Tdata: Eq<"Tdata">,
43 HelpText<"Same as --section-start with .data as the sectionname">;
45 defm Ttext: Eq<"Ttext">,
46 HelpText<"Same as --section-start with .text as the sectionname">;
48 def allow_multiple_definition: F<"allow-multiple-definition">,
49 HelpText<"Allow multiple definitions">;
51 def as_needed: F<"as-needed">,
52 HelpText<"Only set DT_NEEDED for shared libraries if used">;
54 // -chroot doesn't have a help text because it is an internal option.
55 def chroot: S<"chroot">;
57 def color_diagnostics: F<"color-diagnostics">,
58 HelpText<"Use colors in diagnostics">;
60 def color_diagnostics_eq: J<"color-diagnostics=">,
61 HelpText<"Use colors in diagnostics">;
63 def define_common: F<"define-common">,
64 HelpText<"Assign space to common symbols">;
66 def demangle: F<"demangle">, HelpText<"Demangle symbol names">;
68 def disable_new_dtags: F<"disable-new-dtags">,
69 HelpText<"Disable new dynamic tags">;
71 def discard_all: F<"discard-all">, HelpText<"Delete all local symbols">;
73 def discard_locals: F<"discard-locals">,
74 HelpText<"Delete temporary local symbols">;
76 def discard_none: F<"discard-none">,
77 HelpText<"Keep all symbols in the symbol table">;
79 def dynamic_linker: S<"dynamic-linker">,
80 HelpText<"Which dynamic linker to use">;
82 defm dynamic_list: Eq<"dynamic-list">,
83 HelpText<"Read a list of dynamic symbols">;
85 def eh_frame_hdr: F<"eh-frame-hdr">,
86 HelpText<"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header">;
88 def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
90 def enable_new_dtags: F<"enable-new-dtags">,
91 HelpText<"Enable new dynamic tags">;
93 def end_lib: F<"end-lib">,
94 HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
96 defm entry: Eq<"entry">, HelpText<"Name of entry point symbol">,
97 MetaVarName<"<entry>">;
99 defm error_limit: Eq<"error-limit">,
100 HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
102 def error_unresolved_symbols: F<"error-unresolved-symbols">,
103 HelpText<"Report unresolved symbols as errors">;
105 defm exclude_libs: Eq<"exclude-libs">,
106 HelpText<"Exclude static libraries from automatic export">;
108 def export_dynamic: F<"export-dynamic">,
109 HelpText<"Put symbols in the dynamic symbol table">;
111 defm export_dynamic_symbol: Eq<"export-dynamic-symbol">,
112 HelpText<"Put a symbol in the dynamic symbol table">;
114 def fatal_warnings: F<"fatal-warnings">,
115 HelpText<"Treat warnings as errors">;
117 defm filter: Eq<"filter">,
118 HelpText<"Set DT_FILTER field to the specified name">;
120 defm fini: Eq<"fini">,
121 HelpText<"Specify a finalizer function">, MetaVarName<"<symbol>">;
123 def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
124 HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
126 def full_shutdown : F<"full-shutdown">,
127 HelpText<"Perform a full shutdown instead of calling _exit">;
129 defm format: Eq<"format">,
130 HelpText<"Change the input format of the inputs following this option">,
131 MetaVarName<"<input-format>">;
133 def gc_sections: F<"gc-sections">,
134 HelpText<"Enable garbage collection of unused sections">;
136 def gdb_index: F<"gdb-index">,
137 HelpText<"Generate .gdb_index section">;
139 defm hash_style: Eq<"hash-style">,
140 HelpText<"Specify hash style (sysv, gnu or both)">;
142 def help: F<"help">, HelpText<"Print option help">;
144 def icf_all: F<"icf=all">, HelpText<"Enable identical code folding">;
146 def icf_data: F<"icf-data">,
147 HelpText<"Enable ICF to also fold identical read only data">;
149 def icf_none: F<"icf=none">, HelpText<"Disable identical code folding">;
151 defm image_base : Eq<"image-base">, HelpText<"Set the base address">;
153 defm init: Eq<"init">, HelpText<"Specify an initializer function">,
154 MetaVarName<"<symbol>">;
156 defm library: Eq<"library">, HelpText<"Root name of library to use">,
157 MetaVarName<"<libName>">;
159 def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
160 HelpText<"Optimization level for LTO">;
162 def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
164 defm Map: Eq<"Map">, HelpText<"Print a link map to the specified file">;
166 def merge_exidx_entries: F<"merge-exidx-entries">,
167 HelpText<"Enable merging .ARM.exidx entries">;
169 def nostdlib: F<"nostdlib">,
170 HelpText<"Only search directories specified on the command line">;
172 def no_as_needed: F<"no-as-needed">,
173 HelpText<"Always DT_NEEDED for shared libraries">;
175 def no_color_diagnostics: F<"no-color-diagnostics">,
176 HelpText<"Do not use colors in diagnostics">;
178 def no_define_common: F<"no-define-common">,
179 HelpText<"Do not assign space to common symbols">;
181 def no_demangle: F<"no-demangle">,
182 HelpText<"Do not demangle symbol names">;
184 def no_dynamic_linker: F<"no-dynamic-linker">,
185 HelpText<"Inhibit output of .interp section">;
187 def no_eh_frame_hdr: F<"no-eh-frame-hdr">,
188 HelpText<"Do not create .eh_frame_hdr section">;
190 def no_export_dynamic: F<"no-export-dynamic">;
191 def no_fatal_warnings: F<"no-fatal-warnings">;
193 def no_gc_sections: F<"no-gc-sections">,
194 HelpText<"Disable garbage collection of unused sections">;
196 def no_gdb_index: F<"no-gdb-index">,
197 HelpText<"Do not generate .gdb_index section">;
199 def no_gnu_unique: F<"no-gnu-unique">,
200 HelpText<"Disable STB_GNU_UNIQUE symbol binding">;
202 def no_merge_exidx_entries: F<"no-merge-exidx-entries">,
203 HelpText<"Disable merging .ARM.exidx entries">;
205 def no_threads: F<"no-threads">,
206 HelpText<"Do not run the linker multi-threaded">;
208 def no_whole_archive: F<"no-whole-archive">,
209 HelpText<"Restores the default behavior of loading archive members">;
211 def noinhibit_exec: F<"noinhibit-exec">,
212 HelpText<"Retain the executable output file whenever it is still usable">;
214 def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">;
216 def no_omagic: Flag<["--"], "no-omagic">, MetaVarName<"<magic>">,
217 HelpText<"Do not set the text data sections to be writable">;
219 def no_print_gc_sections: F<"no-print-gc-sections">,
220 HelpText<"Do not list removed unused sections">;
222 def no_rosegment: F<"no-rosegment">,
223 HelpText<"Do not put read-only non-executable sections in their own segment">;
225 def no_undefined: F<"no-undefined">,
226 HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
228 def no_undefined_version: F<"no-undefined-version">,
229 HelpText<"Report version scripts that refer undefined symbols">;
231 def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
232 HelpText<"Path to file to write output">;
234 def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">,
235 HelpText<"Specify the binary format for the output object file">;
237 def omagic: Flag<["--"], "omagic">, MetaVarName<"<magic>">,
238 HelpText<"Set the text and data sections to be readable and writable">;
240 defm orphan_handling: Eq<"orphan-handling">,
241 HelpText<"Control how orphan sections are handled when linker script used">;
243 def pack_dyn_relocs_eq: J<"pack-dyn-relocs=">, MetaVarName<"<format>">,
244 HelpText<"Pack dynamic relocations in the given format (none or android)">;
246 def pie: F<"pie">, HelpText<"Create a position independent executable">;
248 def print_gc_sections: F<"print-gc-sections">,
249 HelpText<"List removed unused sections">;
251 def print_map: F<"print-map">,
252 HelpText<"Print a link map to the standard output">;
254 defm reproduce: Eq<"reproduce">,
255 HelpText<"Dump linker invocation and input files for debugging">;
257 defm rpath: Eq<"rpath">, HelpText<"Add a DT_RUNPATH to the output">;
259 def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
261 defm retain_symbols_file: Eq<"retain-symbols-file">,
262 HelpText<"Retain only the symbols listed in the file">,
263 MetaVarName<"<file>">;
265 defm script: Eq<"script">, HelpText<"Read linker script">;
267 def section_start: S<"section-start">, MetaVarName<"<address>">,
268 HelpText<"Set address of section">;
270 def shared: F<"shared">, HelpText<"Build a shared object">;
272 defm soname: Eq<"soname">, HelpText<"Set DT_SONAME">;
274 defm sort_section: Eq<"sort-section">,
275 HelpText<"Specifies sections sorting rule when linkerscript is used">;
277 def start_lib: F<"start-lib">,
278 HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">;
280 def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
282 def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
284 def symbol_ordering_file: S<"symbol-ordering-file">,
285 HelpText<"Layout sections in the order specified by symbol file">;
287 defm sysroot: Eq<"sysroot">, HelpText<"Set the system root">;
289 def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
291 def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32">;
293 defm target2: Eq<"target2">,
294 HelpText<"Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">,
295 MetaVarName<"<type>">;
297 def threads: F<"threads">, HelpText<"Run the linker multi-threaded">;
299 def trace: F<"trace">, HelpText<"Print the names of the input files">;
301 defm trace_symbol : Eq<"trace-symbol">, HelpText<"Trace references to symbols">;
303 defm undefined: Eq<"undefined">,
304 HelpText<"Force undefined symbol during linking">;
306 defm unresolved_symbols: Eq<"unresolved-symbols">,
307 HelpText<"Determine how to handle unresolved symbols">;
309 defm rsp_quoting: Eq<"rsp-quoting">,
310 HelpText<"Quoting style for response files. Values supported: windows|posix">;
312 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
314 def verbose: F<"verbose">, HelpText<"Verbose mode">;
316 def version: F<"version">, HelpText<"Display the version number and exit">;
318 defm version_script: Eq<"version-script">, HelpText<"Read a version script">;
320 def warn_common: F<"warn-common">,
321 HelpText<"Warn about duplicate common symbols">;
323 def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
324 HelpText<"Report unresolved symbols as warnings">;
326 def whole_archive: F<"whole-archive">,
327 HelpText<"Force load of all members in a static library">;
329 defm wrap: Eq<"wrap">, HelpText<"Use wrapper functions for symbol">,
330 MetaVarName<"<symbol>">;
332 def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
333 HelpText<"Linker option extensions">;
336 def alias_auxiliary: Separate<["-"], "f">, Alias<auxiliary>;
337 def alias_Bdynamic_call_shared: F<"call_shared">, Alias<Bdynamic>;
338 def alias_Bdynamic_dy: F<"dy">, Alias<Bdynamic>;
339 def alias_Bstatic_dn: F<"dn">, Alias<Bstatic>;
340 def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>;
341 def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
342 def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>;
343 def alias_define_common_dc: F<"dc">, Alias<define_common>;
344 def alias_define_common_dp: F<"dp">, Alias<define_common>;
345 def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
346 def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
347 def alias_emit_relocs: Flag<["-"], "q">, Alias<emit_relocs>;
348 def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
349 def alias_export_dynamic_E: Flag<["-"], "E">, Alias<export_dynamic>;
350 def alias_filter: Separate<["-"], "F">, Alias<filter>;
351 def alias_format_b: S<"b">, Alias<format>;
352 def alias_library: JoinedOrSeparate<["-"], "l">, Alias<library>;
353 def alias_library_path: JoinedOrSeparate<["-"], "L">, Alias<library_path>;
354 def alias_omagic: Flag<["-"], "N">, Alias<omagic>;
355 def alias_o_output: Joined<["--"], "output=">, Alias<o>;
356 def alias_o_output2 : Separate<["--"], "output">, Alias<o>;
357 def alias_pie_pic_executable: F<"pic-executable">, Alias<pie>;
358 def alias_print_map_M: Flag<["-"], "M">, Alias<print_map>;
359 def alias_relocatable_r: Flag<["-"], "r">, Alias<relocatable>;
360 def alias_rpath_R: JoinedOrSeparate<["-"], "R">, Alias<rpath>;
361 def alias_script_T: JoinedOrSeparate<["-"], "T">, Alias<script>;
362 def alias_shared_Bshareable: F<"Bshareable">, Alias<shared>;
363 def alias_soname_h: JoinedOrSeparate<["-"], "h">, Alias<soname>;
364 def alias_strip_all: Flag<["-"], "s">, Alias<strip_all>;
365 def alias_strip_debug_S: Flag<["-"], "S">, Alias<strip_debug>;
366 def alias_trace: Flag<["-"], "t">, Alias<trace>;
367 def alias_trace_symbol_y : JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>;
368 def alias_Ttext_segment: S<"Ttext-segment">, Alias<Ttext>;
369 def alias_Ttext_segment_eq: J<"Ttext-segment=">, Alias<Ttext>;
370 def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
371 def alias_version_V: Flag<["-"], "V">, Alias<version>;
373 // Our symbol resolution algorithm handles symbols in archive files differently
374 // than traditional linkers, so we don't need --start-group and --end-group.
375 // These options are recongized for compatibility but ignored.
376 def end_group: F<"end-group">;
377 def end_group_paren: Flag<["-"], ")">;
378 def start_group: F<"start-group">;
379 def start_group_paren: Flag<["-"], "(">;
381 // LTO-related options.
382 def lto_aa_pipeline: J<"lto-aa-pipeline=">,
383 HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">;
384 def lto_newpm_passes: J<"lto-newpm-passes=">,
385 HelpText<"Passes to run during LTO">;
386 def lto_partitions: J<"lto-partitions=">,
387 HelpText<"Number of LTO codegen partitions">;
388 def disable_verify: F<"disable-verify">;
389 def mllvm: S<"mllvm">;
390 def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
391 HelpText<"YAML output file for optimization remarks">;
392 def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
393 HelpText<"Include hotness informations in the optimization remarks file">;
394 defm plugin_opt: Eq<"plugin-opt">,
395 HelpText<"specifies LTO options for compatibility with GNU linkers">;
396 def save_temps: F<"save-temps">;
397 def thinlto_cache_dir: J<"thinlto-cache-dir=">,
398 HelpText<"Path to ThinLTO cached object file directory">;
399 def thinlto_cache_policy: S<"thinlto-cache-policy">,
400 HelpText<"Pruning policy for the ThinLTO cache">;
401 def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
403 // Ignore LTO plugin-related options.
404 // clang -flto passes -plugin and -plugin-opt to the linker. This is required
405 // for ld.gold and ld.bfd to get LTO working. But it's not for lld which doesn't
406 // rely on a plugin. Instead of detecting which linker is used on clang side we
407 // just ignore the option on lld side as it's easier. In fact, the linker could
408 // be called 'ld' and understanding which linker is used would require parsing of
410 def plugin: S<"plugin">;
411 def plugin_eq: J<"plugin=">;
413 // Options listed below are silently ignored for now for compatibility.
414 def allow_shlib_undefined: F<"allow-shlib-undefined">;
416 def detect_odr_violations: F<"detect-odr-violations">;
417 def g: Flag<["-"], "g">;
418 def long_plt: F<"long-plt">;
419 def no_add_needed: F<"no-add-needed">;
420 def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
421 def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">;
422 def no_ctors_in_init_array: F<"no-ctors-in-init-array">;
423 def no_keep_memory: F<"no-keep-memory">;
424 def no_mmap_output_file: F<"no-mmap-output-file">;
425 def no_warn_common: F<"no-warn-common">;
426 def no_warn_mismatch: F<"no-warn-mismatch">;
427 def rpath_link: S<"rpath-link">;
428 def rpath_link_eq: J<"rpath-link=">;
429 def sort_common: F<"sort-common">;
430 def stats: F<"stats">;
431 def warn_execstack: F<"warn-execstack">;
432 def warn_once: F<"warn-once">;
433 def warn_shared_textrel: F<"warn-shared-textrel">;
436 def G: JoinedOrSeparate<["-"], "G">;