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