1include "llvm/Option/OptParser.td" 2 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'. 5class F<string name>: Flag<["--", "-"], name>; 6class J<string name>: Joined<["--", "-"], name>; 7class S<string name>: Separate<["--", "-"], name>; 8class JS<string name>: JoinedOrSeparate<["--", "-"], name>; 9 10def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">; 11 12def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">; 13 14def Bsymbolic_functions: F<"Bsymbolic-functions">, 15 HelpText<"Bind defined function symbols locally">; 16 17def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">; 18 19def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">; 20 21def build_id: F<"build-id">, HelpText<"Generate build ID note">; 22 23def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">; 24 25def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">, 26 HelpText<"Add a directory to the library search path">; 27 28def O: Joined<["-"], "O">, HelpText<"Optimize output file size">; 29 30def Tbss: S<"Tbss">, HelpText<"Same as --section-start with .bss as the sectionname">; 31 32def Tdata: S<"Tdata">, HelpText<"Same as --section-start with .data as the sectionname">; 33 34def Ttext: S<"Ttext">, HelpText<"Same as --section-start with .text as the sectionname">; 35 36def allow_multiple_definition: F<"allow-multiple-definition">, 37 HelpText<"Allow multiple definitions">; 38 39def as_needed: F<"as-needed">, 40 HelpText<"Only set DT_NEEDED for shared libraries if used">; 41 42def color_diagnostics: F<"color-diagnostics">, 43 HelpText<"Use colors in diagnostics">; 44 45def color_diagnostics_eq: J<"color-diagnostics=">, 46 HelpText<"Use colors in diagnostics">; 47 48def disable_new_dtags: F<"disable-new-dtags">, 49 HelpText<"Disable new dynamic tags">; 50 51def discard_all: F<"discard-all">, HelpText<"Delete all local symbols">; 52 53def discard_locals: F<"discard-locals">, 54 HelpText<"Delete temporary local symbols">; 55 56def discard_none: F<"discard-none">, 57 HelpText<"Keep all symbols in the symbol table">; 58 59def dynamic_linker: S<"dynamic-linker">, 60 HelpText<"Which dynamic linker to use">; 61 62def dynamic_list: S<"dynamic-list">, 63 HelpText<"Read a list of dynamic symbols">; 64 65def eh_frame_hdr: F<"eh-frame-hdr">, 66 HelpText<"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header">; 67 68def enable_new_dtags: F<"enable-new-dtags">, 69 HelpText<"Enable new dynamic tags">; 70 71def end_lib: F<"end-lib">, 72 HelpText<"End a grouping of objects that should be treated as if they were together in an archive">; 73 74def entry: S<"entry">, MetaVarName<"<entry>">, 75 HelpText<"Name of entry point symbol">; 76 77def error_limit: S<"error-limit">, 78 HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">; 79 80def export_dynamic: F<"export-dynamic">, 81 HelpText<"Put symbols in the dynamic symbol table">; 82 83def export_dynamic_symbol: S<"export-dynamic-symbol">, 84 HelpText<"Put a symbol in the dynamic symbol table">; 85 86def fatal_warnings: F<"fatal-warnings">, 87 HelpText<"Treat warnings as errors">; 88 89def fini: S<"fini">, MetaVarName<"<symbol>">, 90 HelpText<"Specify a finalizer function">; 91 92def full_shutdown : F<"full-shutdown">, 93 HelpText<"Perform a full shutdown instead of calling _exit">; 94 95def format: J<"format=">, MetaVarName<"<input-format>">, 96 HelpText<"Change the input format of the inputs following this option">; 97 98def gc_sections: F<"gc-sections">, 99 HelpText<"Enable garbage collection of unused sections">; 100 101def gdb_index: F<"gdb-index">, 102 HelpText<"Generate .gdb_index section">; 103 104def hash_style: S<"hash-style">, 105 HelpText<"Specify hash style (sysv, gnu or both)">; 106 107def help: F<"help">, HelpText<"Print option help">; 108 109def icf: F<"icf=all">, HelpText<"Enable identical code folding">; 110 111def image_base : J<"image-base=">, HelpText<"Set the base address">; 112 113def init: S<"init">, MetaVarName<"<symbol>">, 114 HelpText<"Specify an initializer function">; 115 116def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">, 117 HelpText<"Root name of library to use">; 118 119def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">, 120 HelpText<"Optimization level for LTO">; 121 122def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">; 123 124def nostdlib: F<"nostdlib">, 125 HelpText<"Only search directories specified on the command line">; 126 127def no_as_needed: F<"no-as-needed">, 128 HelpText<"Always DT_NEEDED for shared libraries">; 129 130def no_color_diagnostics: F<"no-color-diagnostics">, 131 HelpText<"Do not use colors in diagnostics">; 132 133def no_demangle: F<"no-demangle">, 134 HelpText<"Do not demangle symbol names">; 135 136def no_gc_sections: F<"no-gc-sections">, 137 HelpText<"Disable garbage collection of unused sections">; 138 139def no_gnu_unique: F<"no-gnu-unique">, 140 HelpText<"Disable STB_GNU_UNIQUE symbol binding">; 141 142def no_threads: F<"no-threads">, 143 HelpText<"Do not run the linker multi-threaded">; 144 145def no_whole_archive: F<"no-whole-archive">, 146 HelpText<"Restores the default behavior of loading archive members">; 147 148def noinhibit_exec: F<"noinhibit-exec">, 149 HelpText<"Retain the executable output file whenever it is still usable">; 150 151def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">; 152 153def no_rosegment: F<"no-rosegment">, HelpText<"Do not put read-only non-executable sections in their own segment">; 154 155def no_undefined: F<"no-undefined">, 156 HelpText<"Report unresolved symbols even if the linker is creating a shared library">; 157 158def no_undefined_version: F<"no-undefined-version">, 159 HelpText<"Report version scripts that refer undefined symbols">; 160 161def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">, 162 HelpText<"Path to file to write output">; 163 164def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">, 165 HelpText<"Specify the binary format for the output object file">; 166 167def omagic: F<"omagic">, MetaVarName<"<magic>">, 168 HelpText<"Set the text and data sections to be readable and writable">; 169 170def pie: F<"pie">, HelpText<"Create a position independent executable">; 171 172def print_gc_sections: F<"print-gc-sections">, 173 HelpText<"List removed unused sections">; 174 175def reproduce: S<"reproduce">, 176 HelpText<"Dump linker invocation and input files for debugging">; 177 178def rpath: S<"rpath">, HelpText<"Add a DT_RUNPATH to the output">; 179 180def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">; 181 182def retain_symbols_file: J<"retain-symbols-file=">, MetaVarName<"<file>">, 183 HelpText<"Retain only the symbols listed in the file">; 184 185def script: S<"script">, HelpText<"Read linker script">; 186 187def section_start: S<"section-start">, MetaVarName<"<address>">, 188 HelpText<"Set address of section">; 189 190def shared: F<"shared">, HelpText<"Build a shared object">; 191 192def soname: J<"soname=">, HelpText<"Set DT_SONAME">; 193 194def sort_section: S<"sort-section">, HelpText<"Specifies sections sorting rule when linkerscript is used">; 195 196def start_lib: F<"start-lib">, 197 HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">; 198 199def strip_all: F<"strip-all">, HelpText<"Strip all symbols">; 200 201def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">; 202 203def symbol_ordering_file: S<"symbol-ordering-file">, 204 HelpText<"Layout sections in the order specified by symbol file">; 205 206def sysroot: J<"sysroot=">, HelpText<"Set the system root">; 207 208def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">; 209 210def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32">; 211 212def target2: J<"target2=">, MetaVarName<"<type>">, HelpText<"Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">; 213 214def threads: F<"threads">, HelpText<"Run the linker multi-threaded">; 215 216def trace: F<"trace">, HelpText<"Print the names of the input files">; 217 218def trace_symbol : J<"trace-symbol=">, HelpText<"Trace references to symbols">; 219 220def undefined: S<"undefined">, 221 HelpText<"Force undefined symbol during linking">; 222 223def unresolved_symbols: J<"unresolved-symbols=">, 224 HelpText<"Determine how to handle unresolved symbols">; 225 226def rsp_quoting: J<"rsp-quoting=">, 227 HelpText<"Quoting style for response files. Values supported: windows|posix">; 228 229def v: Flag<["-"], "v">, HelpText<"Display the version number">; 230 231def verbose: F<"verbose">, HelpText<"Verbose mode">; 232 233def version: F<"version">, HelpText<"Display the version number and exit">; 234 235def version_script: S<"version-script">, 236 HelpText<"Read a version script">; 237 238def warn_common: F<"warn-common">, 239 HelpText<"Warn about duplicate common symbols">; 240 241def whole_archive: F<"whole-archive">, 242 HelpText<"Force load of all members in a static library">; 243 244def wrap: S<"wrap">, MetaVarName<"<symbol>">, 245 HelpText<"Use wrapper functions for symbol">; 246 247def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">, 248 HelpText<"Linker option extensions">; 249 250// Aliases 251def alias_auxiliary: Separate<["-"], "f">, Alias<auxiliary>; 252def alias_Bdynamic_call_shared: F<"call_shared">, Alias<Bdynamic>; 253def alias_Bdynamic_dy: F<"dy">, Alias<Bdynamic>; 254def alias_Bstatic_dn: F<"dn">, Alias<Bstatic>; 255def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>; 256def alias_Bstatic_static: F<"static">, Alias<Bstatic>; 257def alias_L__library_path: J<"library-path=">, Alias<L>; 258def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>; 259def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>; 260def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>; 261def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>; 262def alias_entry_entry: J<"entry=">, Alias<entry>; 263def alias_error_limit: J<"error-limit=">, Alias<error_limit>; 264def alias_export_dynamic_E: Flag<["-"], "E">, Alias<export_dynamic>; 265def alias_export_dynamic_symbol: J<"export-dynamic-symbol=">, 266 Alias<export_dynamic_symbol>; 267def alias_fini_fini: J<"fini=">, Alias<fini>; 268def alias_format_b: S<"b">, Alias<format>; 269def alias_hash_style_hash_style: J<"hash-style=">, Alias<hash_style>; 270def alias_init_init: J<"init=">, Alias<init>; 271def alias_l__library: J<"library=">, Alias<l>; 272def alias_omagic: Flag<["-"], "N">, Alias<omagic>; 273def alias_o_output: Joined<["--"], "output=">, Alias<o>; 274def alias_o_output2 : Separate<["--"], "output">, Alias<o>; 275def alias_pie_pic_executable: F<"pic-executable">, Alias<pie>; 276def alias_relocatable_r: Flag<["-"], "r">, Alias<relocatable>; 277def alias_retain_symbols_file: S<"retain-symbols-file">, Alias<retain_symbols_file>; 278def alias_rpath_R: JoinedOrSeparate<["-"], "R">, Alias<rpath>; 279def alias_rpath_rpath: J<"rpath=">, Alias<rpath>; 280def alias_script_T: JoinedOrSeparate<["-"], "T">, Alias<script>; 281def alias_shared_Bshareable: F<"Bshareable">, Alias<shared>; 282def alias_soname_h: JoinedOrSeparate<["-"], "h">, Alias<soname>; 283def alias_soname_soname: S<"soname">, Alias<soname>; 284def alias_sort_section: J<"sort-section=">, Alias<sort_section>; 285def alias_script: J<"script=">, Alias<script>; 286def alias_strip_all: Flag<["-"], "s">, Alias<strip_all>; 287def alias_strip_debug_S: Flag<["-"], "S">, Alias<strip_debug>; 288def alias_Tbss: J<"Tbss=">, Alias<Tbss>; 289def alias_Tdata: J<"Tdata=">, Alias<Tdata>; 290def alias_trace: Flag<["-"], "t">, Alias<trace>; 291def alias_trace_symbol_y : JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>; 292def alias_Ttext: J<"Ttext=">, Alias<Ttext>; 293def alias_Ttext_segment: S<"Ttext-segment">, Alias<Ttext>; 294def alias_Ttext_segment_eq: J<"Ttext-segment=">, Alias<Ttext>; 295def alias_undefined_eq: J<"undefined=">, Alias<undefined>; 296def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>; 297def alias_version_V: Flag<["-"], "V">, Alias<version>; 298def alias_wrap_wrap: J<"wrap=">, Alias<wrap>; 299 300// Our symbol resolution algorithm handles symbols in archive files differently 301// than traditional linkers, so we don't need --start-group and --end-group. 302// These options are recongized for compatibility but ignored. 303def end_group: F<"end-group">; 304def end_group_paren: Flag<["-"], ")">; 305def start_group: F<"start-group">; 306def start_group_paren: Flag<["-"], "(">; 307 308// Ignore LTO plugin-related options. 309// clang -flto passes -plugin and -plugin-opt to the linker. This is required 310// for ld.gold and ld.bfd to get LTO working. But it's not for lld which doesn't 311// rely on a plugin. Instead of detecting which linker is used on clang side we 312// just ignore the option on lld side as it's easier. In fact, the linker could 313// be called 'ld' and understanding which linker is used would require parsing of 314// --version output. 315def plugin: S<"plugin">; 316def plugin_eq: J<"plugin=">; 317def plugin_opt: S<"plugin-opt">; 318def plugin_opt_eq: J<"plugin-opt=">; 319 320// Options listed below are silently ignored for now for compatibility. 321def allow_shlib_undefined: F<"allow-shlib-undefined">; 322def cref: Flag<["--"], "cref">; 323def define_common: F<"define-common">; 324def demangle: F<"demangle">; 325def detect_odr_violations: F<"detect-odr-violations">; 326def g: Flag<["-"], "g">; 327def M: Flag<["-"], "M">; 328def Map: JS<"Map">; 329def no_add_needed: F<"no-add-needed">; 330def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">; 331def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">, 332 Alias<no_add_needed>; 333def no_dynamic_linker: F<"no-dynamic-linker">; 334def no_fatal_warnings: F<"no-fatal-warnings">; 335def no_mmap_output_file: F<"no-mmap-output-file">; 336def no_warn_common: F<"no-warn-common">; 337def no_warn_mismatch: F<"no-warn-mismatch">; 338def rpath_link: S<"rpath-link">; 339def rpath_link_eq: J<"rpath-link=">; 340def sort_common: F<"sort-common">; 341def stats: F<"stats">; 342def warn_execstack: F<"warn-execstack">; 343def warn_shared_textrel: F<"warn-shared-textrel">; 344def EB : F<"EB">; 345def EL : F<"EL">; 346def G: JoinedOrSeparate<["-"], "G">; 347def Qy : F<"Qy">; 348 349// Aliases for ignored options 350def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>; 351def alias_define_common_dc: F<"dc">, Alias<define_common>; 352def alias_define_common_dp: F<"dp">, Alias<define_common>; 353def alias_Map_eq: J<"Map=">, Alias<Map>; 354def alias_version_script_version_script: J<"version-script=">, 355 Alias<version_script>; 356 357// LTO-related options. 358def lto_aa_pipeline: J<"lto-aa-pipeline=">, 359 HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">; 360def lto_newpm_passes: J<"lto-newpm-passes=">, 361 HelpText<"Passes to run during LTO">; 362def lto_partitions: J<"lto-partitions=">, 363 HelpText<"Number of LTO codegen partitions">; 364def disable_verify: F<"disable-verify">; 365def mllvm: S<"mllvm">; 366def save_temps: F<"save-temps">; 367def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">; 368