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>; 8 9multiclass Eq<string name, string help> { 10 def NAME: Separate<["--", "-"], name>; 11 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>, 12 HelpText<help>; 13} 14 15multiclass B<string name, string help1, string help2> { 16 def NAME: Flag<["--", "-"], name>, HelpText<help1>; 17 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>; 18} 19 20// The following flags are shared with the ELF linker 21def color_diagnostics: F<"color-diagnostics">, 22 HelpText<"Use colors in diagnostics">; 23 24def color_diagnostics_eq: J<"color-diagnostics=">, 25 HelpText<"Use colors in diagnostics; one of 'always', 'never', 'auto'">; 26 27def compress_relocations: F<"compress-relocations">, 28 HelpText<"Compress the relocation targets in the code section.">; 29 30defm demangle: B<"demangle", 31 "Demangle symbol names", 32 "Do not demangle symbol names">; 33 34def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">; 35 36defm export_dynamic: B<"export-dynamic", 37 "Put symbols in the dynamic symbol table", 38 "Do not put symbols in the dynamic symbol table (default)">; 39 40def entry: S<"entry">, MetaVarName<"<entry>">, 41 HelpText<"Name of entry point symbol">; 42 43def error_limit: J<"error-limit=">, 44 HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">; 45 46def fatal_warnings: F<"fatal-warnings">, 47 HelpText<"Treat warnings as errors">; 48 49defm gc_sections: B<"gc-sections", 50 "Enable garbage collection of unused sections", 51 "Disable garbage collection of unused sections">; 52 53defm merge_data_segments: B<"merge-data-segments", 54 "Enable merging data segments", 55 "Disable merging data segments">; 56 57def help: F<"help">, HelpText<"Print option help">; 58 59def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">, 60 HelpText<"Root name of library to use">; 61 62def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">, 63 HelpText<"Add a directory to the library search path">; 64 65def mllvm: S<"mllvm">, HelpText<"Options to pass to LLVM">; 66 67def no_threads: F<"no-threads">, 68 HelpText<"Do not run the linker multi-threaded">; 69 70def no_color_diagnostics: F<"no-color-diagnostics">, 71 HelpText<"Do not use colors in diagnostics">; 72 73def no_fatal_warnings: F<"no-fatal-warnings">; 74 75def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">, 76 HelpText<"Path to file to write output">; 77 78def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">; 79 80defm pie: B<"pie", 81 "Create a position independent executable", 82 "Do not create a position independent executable (default)">; 83 84defm print_gc_sections: B<"print-gc-sections", 85 "List removed unused sections", 86 "Do not list removed unused sections">; 87 88def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">; 89 90defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">; 91 92def shared: F<"shared">, HelpText<"Build a shared object">; 93 94def strip_all: F<"strip-all">, HelpText<"Strip all symbols">; 95 96def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">; 97 98def threads: F<"threads">, HelpText<"Run the linker multi-threaded">; 99 100def trace: F<"trace">, HelpText<"Print the names of the input files">; 101 102defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">; 103 104defm undefined: Eq<"undefined", "Force undefined symbol during linking">; 105 106def v: Flag<["-"], "v">, HelpText<"Display the version number">; 107 108def verbose: F<"verbose">, HelpText<"Verbose mode">; 109 110def version: F<"version">, HelpText<"Display the version number and exit">; 111 112def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">, 113 HelpText<"Linker option extensions">; 114 115defm wrap: Eq<"wrap", "Use wrapper functions for symbol">, 116 MetaVarName<"<symbol>=<symbol>">; 117 118// The follow flags are unique to wasm 119 120def allow_undefined: F<"allow-undefined">, 121 HelpText<"Allow undefined symbols in linked binary">; 122 123def allow_undefined_file: J<"allow-undefined-file=">, 124 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">; 125 126def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">, 127 Alias<allow_undefined_file>; 128 129defm export: Eq<"export", "Force a symbol to be exported">; 130 131def export_all: F<"export-all">, 132 HelpText<"Export all symbols (normally combined with --no-gc-sections)">; 133 134def export_table: F<"export-table">, 135 HelpText<"Export function table to the environment">; 136 137def growable_table: F<"growable-table">, 138 HelpText<"Remove maximum size from function table, allowing table to grow">; 139 140def global_base: J<"global-base=">, 141 HelpText<"Where to start to place global data">; 142 143def import_memory: F<"import-memory">, 144 HelpText<"Import memory from the environment">; 145 146def shared_memory: F<"shared-memory">, 147 HelpText<"Use shared linear memory">; 148 149def import_table: F<"import-table">, 150 HelpText<"Import function table from the environment">; 151 152def initial_memory: J<"initial-memory=">, 153 HelpText<"Initial size of the linear memory">; 154 155def max_memory: J<"max-memory=">, 156 HelpText<"Maximum size of the linear memory">; 157 158def no_entry: F<"no-entry">, 159 HelpText<"Do not output any entry point">; 160 161def stack_first: F<"stack-first">, 162 HelpText<"Place stack at start of linear memory rather than after data">; 163 164defm whole_archive: B<"whole-archive", 165 "Force load of all members in a static library", 166 "Do not force load of all members in a static library (default)">; 167 168defm check_features: B<"check-features", 169 "Check feature compatibility of linked objects (default)", 170 "Ignore feature compatibility of linked objects">; 171 172def features: CommaJoined<["--", "-"], "features=">, 173 HelpText<"Comma-separated used features, inferred from input objects by default.">; 174 175// Aliases 176def: JoinedOrSeparate<["-"], "e">, Alias<entry>; 177def: J<"entry=">, Alias<entry>; 178def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">; 179def: Flag<["-"], "i">, Alias<initial_memory>; 180def: Flag<["-"], "m">, Alias<max_memory>; 181def: Flag<["-"], "r">, Alias<relocatable>; 182def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">; 183def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">; 184def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">; 185def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">; 186def: JoinedOrSeparate<["-"], "u">, Alias<undefined>; 187 188// LTO-related options. 189def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">, 190 HelpText<"Optimization level for LTO">; 191def lto_partitions: J<"lto-partitions=">, 192 HelpText<"Number of LTO codegen partitions">; 193def disable_verify: F<"disable-verify">; 194def save_temps: F<"save-temps">; 195def thinlto_cache_dir: J<"thinlto-cache-dir=">, 196 HelpText<"Path to ThinLTO cached object file directory">; 197defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">; 198def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">; 199