1 include "llvm/Option/OptParser.td"
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
7 class FF<string name> : Flag<["--"], name>;
8 class JJ<string name>: Joined<["--"], name>;
10 multiclass EEq<string name, string help> {
11 def NAME: Separate<["--"], name>;
12 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
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>;
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 class S<string name>: Separate<["--", "-"], name>;
27 multiclass Eq<string name, string help> {
28 def NAME: Separate<["--", "-"], name>;
29 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
33 multiclass B<string name, string help1, string help2> {
34 def NAME: Flag<["--", "-"], name>, HelpText<help1>;
35 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
38 // The following flags are shared with the ELF linker
39 def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
41 def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">;
43 def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
45 def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
47 def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
48 MetaVarName<"[fast,sha1,uuid,0x<hexstring>]">;
50 defm color_diagnostics: B<"color-diagnostics",
51 "Alias for --color-diagnostics=always",
52 "Alias for --color-diagnostics=never">;
53 def color_diagnostics_eq: J<"color-diagnostics=">,
54 HelpText<"Use colors in diagnostics (default: auto)">,
55 MetaVarName<"[auto,always,never]">;
57 def compress_relocations: F<"compress-relocations">,
58 HelpText<"Compress the relocation targets in the code section.">;
60 defm demangle: B<"demangle",
61 "Demangle symbol names",
62 "Do not demangle symbol names">;
64 def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
66 def error_unresolved_symbols: F<"error-unresolved-symbols">,
67 HelpText<"Report unresolved symbols as errors">;
69 defm export_dynamic: B<"export-dynamic",
70 "Put symbols in the dynamic symbol table",
71 "Do not put symbols in the dynamic symbol table (default)">;
73 def entry: S<"entry">, MetaVarName<"<entry>">,
74 HelpText<"Name of entry point symbol">;
77 EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
79 def fatal_warnings: F<"fatal-warnings">,
80 HelpText<"Treat warnings as errors">;
82 defm gc_sections: B<"gc-sections",
83 "Enable garbage collection of unused sections",
84 "Disable garbage collection of unused sections">;
86 defm merge_data_segments: BB<"merge-data-segments",
87 "Enable merging data segments",
88 "Disable merging data segments">;
90 def help: F<"help">, HelpText<"Print option help">;
92 def library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
93 HelpText<"Root name of library to use">;
95 def library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
96 HelpText<"Add a directory to the library search path">;
98 def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
100 defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
102 defm Map: Eq<"Map", "Print a link map to the specified file">;
104 def no_fatal_warnings: F<"no-fatal-warnings">;
106 def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
107 HelpText<"Path to file to write output">;
109 def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
112 "Create a position independent executable",
113 "Do not create a position independent executable (default)">;
115 defm print_gc_sections: B<"print-gc-sections",
116 "List removed unused sections",
117 "Do not list removed unused sections">;
119 def print_map: F<"print-map">,
120 HelpText<"Print a link map to the standard output">;
122 def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
124 defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
126 defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
127 MetaVarName<"[posix,windows]">;
129 def shared: F<"shared">, HelpText<"Build a shared object">;
131 def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
133 def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
136 : Eq<"threads", "Number of threads. '1' disables multi-threading. By "
137 "default all available hardware threads are used">;
139 def trace: F<"trace">, HelpText<"Print the names of the input files">;
141 defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
143 defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
145 defm unresolved_symbols:
146 Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
148 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
150 def verbose: F<"verbose">, HelpText<"Verbose mode">;
152 def version: F<"version">, HelpText<"Display the version number and exit">;
154 def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
155 HelpText<"Report unresolved symbols as warnings">;
157 defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
158 MetaVarName<"<symbol>=<symbol>">;
160 def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
161 HelpText<"Linker option extensions">;
163 // The follow flags are unique to wasm
165 def allow_undefined: F<"allow-undefined">,
166 HelpText<"Allow undefined symbols in linked binary. "
167 "This options is equivalent to --import-undefined "
168 "and --unresolved-symbols=ignore-all">;
170 def import_undefined: F<"import-undefined">,
171 HelpText<"Turn undefined symbols into imports where possible">;
173 def allow_undefined_file: J<"allow-undefined-file=">,
174 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
176 def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
177 Alias<allow_undefined_file>;
179 defm export: Eq<"export", "Force a symbol to be exported">;
181 defm export_if_defined: Eq<"export-if-defined",
182 "Force a symbol to be exported, if it is defined in the input">;
184 def export_all: FF<"export-all">,
185 HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
187 def export_table: FF<"export-table">,
188 HelpText<"Export function table to the environment">;
190 def growable_table: FF<"growable-table">,
191 HelpText<"Remove maximum size from function table, allowing table to grow">;
193 def global_base: JJ<"global-base=">,
194 HelpText<"Memory offset at which to place global data (Defaults to 1024)">;
196 def import_memory: FF<"import-memory">,
197 HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">;
198 def import_memory_with_name: JJ<"import-memory=">,
199 HelpText<"Import the module's memory from the passed module with the passed name.">,
200 MetaVarName<"<module>,<name>">;
202 def export_memory: FF<"export-memory">,
203 HelpText<"Export the module's memory with the default name of \"memory\"">;
204 def export_memory_with_name: JJ<"export-memory=">,
205 HelpText<"Export the module's memory with the passed name">;
207 def shared_memory: FF<"shared-memory">,
208 HelpText<"Use shared linear memory">;
210 defm soname: Eq<"soname", "Set the module name in the generated name section">;
212 def import_table: FF<"import-table">,
213 HelpText<"Import function table from the environment">;
215 def initial_memory: JJ<"initial-memory=">,
216 HelpText<"Initial size of the linear memory">;
218 def max_memory: JJ<"max-memory=">,
219 HelpText<"Maximum size of the linear memory">;
221 def no_entry: FF<"no-entry">,
222 HelpText<"Do not output any entry point">;
224 def stack_first: FF<"stack-first">,
225 HelpText<"Place stack at start of linear memory rather than after data">;
227 def table_base: JJ<"table-base=">,
228 HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
230 defm whole_archive: B<"whole-archive",
231 "Force load of all members in a static library",
232 "Do not force load of all members in a static library (default)">;
234 def why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">;
236 defm check_features: BB<"check-features",
237 "Check feature compatibility of linked objects (default)",
238 "Ignore feature compatibility of linked objects">;
240 def features: CommaJoined<["--", "-"], "features=">,
241 HelpText<"Comma-separated used features, inferred from input objects by default.">;
243 def extra_features: CommaJoined<["--", "-"], "extra-features=">,
244 HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">;
247 def: JoinedOrSeparate<["-"], "e">, Alias<entry>;
248 def: J<"entry=">, Alias<entry>;
249 def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
250 def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
251 def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
252 def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
253 def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
254 def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
255 def: Flag<["-"], "i">, Alias<initial_memory>;
256 def: Separate<["--", "-"], "library">, Alias<library>;
257 def: Joined<["--", "-"], "library=">, Alias<library>;
258 def: Separate<["--", "-"], "library-path">, Alias<library_path>;
259 def: Joined<["--", "-"], "library-path=">, Alias<library_path>;
260 def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
261 def: Flag<["-"], "r">, Alias<relocatable>;
262 def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
263 def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
264 def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
265 def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
266 def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
268 // LTO-related options.
269 def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
270 HelpText<"Optimization level for LTO">;
271 def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">,
272 HelpText<"Codegen optimization level for LTO">;
273 def lto_partitions: JJ<"lto-partitions=">,
274 HelpText<"Number of LTO codegen partitions">;
275 def disable_verify: F<"disable-verify">;
276 def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
277 def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
278 HelpText<"Path to ThinLTO cached object file directory">;
279 defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
280 def thinlto_jobs: JJ<"thinlto-jobs=">,
281 HelpText<"Number of ThinLTO jobs. Default to --threads=">;
282 def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
283 HelpText<"Debug new pass manager">;
285 // Experimental PIC mode.
286 def experimental_pic: FF<"experimental-pic">,
287 HelpText<"Enable Experimental PIC">;