xref: /openbsd-src/gnu/llvm/lld/wasm/Options.td (revision dfe94b169149f14cc1aee2cf6dad58a8d9a1860c)
1ece8a530Spatrickinclude "llvm/Option/OptParser.td"
2ece8a530Spatrick
3*dfe94b16Srobert// Convenience classes for long options which only accept two dashes. For lld
4*dfe94b16Srobert// specific or newer long options, we prefer two dashes to avoid collision with
5*dfe94b16Srobert// short options. For many others, we have to accept both forms to be compatible
6*dfe94b16Srobert// with GNU ld.
7*dfe94b16Srobertclass FF<string name> : Flag<["--"], name>;
8*dfe94b16Srobertclass JJ<string name>: Joined<["--"], name>;
9*dfe94b16Srobert
10*dfe94b16Srobertmulticlass EEq<string name, string help> {
11*dfe94b16Srobert  def NAME: Separate<["--"], name>;
12*dfe94b16Srobert  def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
13*dfe94b16Srobert    HelpText<help>;
14*dfe94b16Srobert}
15*dfe94b16Srobert
16*dfe94b16Srobertmulticlass BB<string name, string help1, string help2> {
17*dfe94b16Srobert  def NAME: Flag<["--"], name>, HelpText<help1>;
18*dfe94b16Srobert  def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
19*dfe94b16Srobert}
20*dfe94b16Srobert
21ece8a530Spatrick// For options whose names are multiple letters, either one dash or
22ece8a530Spatrick// two can precede the option name except those that start with 'o'.
23ece8a530Spatrickclass F<string name>: Flag<["--", "-"], name>;
24ece8a530Spatrickclass J<string name>: Joined<["--", "-"], name>;
25ece8a530Spatrickclass S<string name>: Separate<["--", "-"], name>;
26ece8a530Spatrick
27ece8a530Spatrickmulticlass Eq<string name, string help> {
28ece8a530Spatrick  def NAME: Separate<["--", "-"], name>;
29ece8a530Spatrick  def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
30ece8a530Spatrick    HelpText<help>;
31ece8a530Spatrick}
32ece8a530Spatrick
33ece8a530Spatrickmulticlass B<string name, string help1, string help2> {
34ece8a530Spatrick  def NAME: Flag<["--", "-"], name>, HelpText<help1>;
35ece8a530Spatrick  def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
36ece8a530Spatrick}
37ece8a530Spatrick
381cf9926bSpatrick// The following flags are shared with the ELF linker
391cf9926bSpatrickdef Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
401cf9926bSpatrick
41*dfe94b16Srobertdef Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">;
42*dfe94b16Srobert
43*dfe94b16Srobertdef Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
44*dfe94b16Srobert
451cf9926bSpatrickdefm color_diagnostics: B<"color-diagnostics",
461cf9926bSpatrick  "Alias for --color-diagnostics=always",
471cf9926bSpatrick  "Alias for --color-diagnostics=never">;
48ece8a530Spatrickdef color_diagnostics_eq: J<"color-diagnostics=">,
491cf9926bSpatrick  HelpText<"Use colors in diagnostics (default: auto)">,
501cf9926bSpatrick  MetaVarName<"[auto,always,never]">;
51ece8a530Spatrick
52ece8a530Spatrickdef compress_relocations: F<"compress-relocations">,
53ece8a530Spatrick  HelpText<"Compress the relocation targets in the code section.">;
54ece8a530Spatrick
55ece8a530Spatrickdefm demangle: B<"demangle",
56ece8a530Spatrick    "Demangle symbol names",
57ece8a530Spatrick    "Do not demangle symbol names">;
58ece8a530Spatrick
59ece8a530Spatrickdef emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
60ece8a530Spatrick
611cf9926bSpatrickdef error_unresolved_symbols: F<"error-unresolved-symbols">,
621cf9926bSpatrick  HelpText<"Report unresolved symbols as errors">;
631cf9926bSpatrick
64ece8a530Spatrickdefm export_dynamic: B<"export-dynamic",
65ece8a530Spatrick    "Put symbols in the dynamic symbol table",
66ece8a530Spatrick    "Do not put symbols in the dynamic symbol table (default)">;
67ece8a530Spatrick
68ece8a530Spatrickdef entry: S<"entry">, MetaVarName<"<entry>">,
69ece8a530Spatrick  HelpText<"Name of entry point symbol">;
70ece8a530Spatrick
71*dfe94b16Srobertdefm error_limit:
72*dfe94b16Srobert  EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
73ece8a530Spatrick
74ece8a530Spatrickdef fatal_warnings: F<"fatal-warnings">,
75ece8a530Spatrick  HelpText<"Treat warnings as errors">;
76ece8a530Spatrick
77ece8a530Spatrickdefm gc_sections: B<"gc-sections",
78ece8a530Spatrick    "Enable garbage collection of unused sections",
79ece8a530Spatrick    "Disable garbage collection of unused sections">;
80ece8a530Spatrick
81*dfe94b16Srobertdefm merge_data_segments: BB<"merge-data-segments",
82ece8a530Spatrick    "Enable merging data segments",
83ece8a530Spatrick    "Disable merging data segments">;
84ece8a530Spatrick
85ece8a530Spatrickdef help: F<"help">, HelpText<"Print option help">;
86ece8a530Spatrick
87*dfe94b16Srobertdef library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
88ece8a530Spatrick  HelpText<"Root name of library to use">;
89ece8a530Spatrick
90*dfe94b16Srobertdef library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
91ece8a530Spatrick  HelpText<"Add a directory to the library search path">;
92ece8a530Spatrick
93bb684c34Spatrickdef m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
94ece8a530Spatrick
95*dfe94b16Srobertdefm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
96ece8a530Spatrick
971cf9926bSpatrickdefm Map: Eq<"Map", "Print a link map to the specified file">;
98ece8a530Spatrick
99ece8a530Spatrickdef no_fatal_warnings: F<"no-fatal-warnings">;
100ece8a530Spatrick
101ece8a530Spatrickdef o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
102ece8a530Spatrick  HelpText<"Path to file to write output">;
103ece8a530Spatrick
104ece8a530Spatrickdef O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
105ece8a530Spatrick
106ece8a530Spatrickdefm pie: B<"pie",
107ece8a530Spatrick    "Create a position independent executable",
108ece8a530Spatrick    "Do not create a position independent executable (default)">;
109ece8a530Spatrick
110ece8a530Spatrickdefm print_gc_sections: B<"print-gc-sections",
111ece8a530Spatrick    "List removed unused sections",
112ece8a530Spatrick    "Do not list removed unused sections">;
113ece8a530Spatrick
1141cf9926bSpatrickdef print_map: F<"print-map">,
1151cf9926bSpatrick  HelpText<"Print a link map to the standard output">;
1161cf9926bSpatrick
117ece8a530Spatrickdef relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
118ece8a530Spatrick
119*dfe94b16Srobertdefm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
120ece8a530Spatrick
121bb684c34Spatrickdefm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
122bb684c34Spatrick  MetaVarName<"[posix,windows]">;
123bb684c34Spatrick
124ece8a530Spatrickdef shared: F<"shared">, HelpText<"Build a shared object">;
125ece8a530Spatrick
126ece8a530Spatrickdef strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
127ece8a530Spatrick
128ece8a530Spatrickdef strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
129ece8a530Spatrick
130bb684c34Spatrickdefm threads
131bb684c34Spatrick    : Eq<"threads", "Number of threads. '1' disables multi-threading. By "
132bb684c34Spatrick                    "default all available hardware threads are used">;
133ece8a530Spatrick
134ece8a530Spatrickdef trace: F<"trace">, HelpText<"Print the names of the input files">;
135ece8a530Spatrick
136ece8a530Spatrickdefm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
137ece8a530Spatrick
138ece8a530Spatrickdefm undefined: Eq<"undefined", "Force undefined symbol during linking">;
139ece8a530Spatrick
1401cf9926bSpatrickdefm unresolved_symbols:
1411cf9926bSpatrick  Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
1421cf9926bSpatrick
143ece8a530Spatrickdef v: Flag<["-"], "v">, HelpText<"Display the version number">;
144ece8a530Spatrick
145ece8a530Spatrickdef verbose: F<"verbose">, HelpText<"Verbose mode">;
146ece8a530Spatrick
147ece8a530Spatrickdef version: F<"version">, HelpText<"Display the version number and exit">;
148ece8a530Spatrick
1491cf9926bSpatrickdef warn_unresolved_symbols: F<"warn-unresolved-symbols">,
1501cf9926bSpatrick  HelpText<"Report unresolved symbols as warnings">;
151ece8a530Spatrick
152ece8a530Spatrickdefm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
153ece8a530Spatrick  MetaVarName<"<symbol>=<symbol>">;
154ece8a530Spatrick
1551cf9926bSpatrickdef z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
1561cf9926bSpatrick  HelpText<"Linker option extensions">;
1571cf9926bSpatrick
158ece8a530Spatrick// The follow flags are unique to wasm
159ece8a530Spatrick
160ece8a530Spatrickdef allow_undefined: F<"allow-undefined">,
161*dfe94b16Srobert  HelpText<"Allow undefined symbols in linked binary. "
162*dfe94b16Srobert           "This options is equivalent to --import-undefined "
163*dfe94b16Srobert           "and --unresolved-symbols=ignore-all">;
1641cf9926bSpatrick
1651cf9926bSpatrickdef import_undefined: F<"import-undefined">,
1661cf9926bSpatrick  HelpText<"Turn undefined symbols into imports where possible">;
167ece8a530Spatrick
168ece8a530Spatrickdef allow_undefined_file: J<"allow-undefined-file=">,
169ece8a530Spatrick  HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
170ece8a530Spatrick
171ece8a530Spatrickdef allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
172ece8a530Spatrick  Alias<allow_undefined_file>;
173ece8a530Spatrick
174ece8a530Spatrickdefm export: Eq<"export", "Force a symbol to be exported">;
175ece8a530Spatrick
1761cf9926bSpatrickdefm export_if_defined: Eq<"export-if-defined",
1771cf9926bSpatrick     "Force a symbol to be exported, if it is defined in the input">;
1781cf9926bSpatrick
179*dfe94b16Srobertdef export_all: FF<"export-all">,
180ece8a530Spatrick  HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
181ece8a530Spatrick
182*dfe94b16Srobertdef export_table: FF<"export-table">,
183ece8a530Spatrick  HelpText<"Export function table to the environment">;
184ece8a530Spatrick
185*dfe94b16Srobertdef growable_table: FF<"growable-table">,
186ece8a530Spatrick  HelpText<"Remove maximum size from function table, allowing table to grow">;
187ece8a530Spatrick
188*dfe94b16Srobertdef global_base: JJ<"global-base=">,
189ece8a530Spatrick  HelpText<"Where to start to place global data">;
190ece8a530Spatrick
191*dfe94b16Srobertdef import_memory: FF<"import-memory">,
192*dfe94b16Srobert  HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">;
193*dfe94b16Srobertdef import_memory_with_name: JJ<"import-memory=">,
194*dfe94b16Srobert  HelpText<"Import the module's memory from the passed module with the passed name.">,
195*dfe94b16Srobert  MetaVarName<"<module>,<name>">;
196ece8a530Spatrick
197*dfe94b16Srobertdef export_memory: FF<"export-memory">,
198*dfe94b16Srobert  HelpText<"Export the module's memory with the default name of \"memory\"">;
199*dfe94b16Srobertdef export_memory_with_name: JJ<"export-memory=">,
200*dfe94b16Srobert  HelpText<"Export the module's memory with the passed name">;
201*dfe94b16Srobert
202*dfe94b16Srobertdef shared_memory: FF<"shared-memory">,
203ece8a530Spatrick  HelpText<"Use shared linear memory">;
204ece8a530Spatrick
205*dfe94b16Srobertdef import_table: FF<"import-table">,
206ece8a530Spatrick  HelpText<"Import function table from the environment">;
207ece8a530Spatrick
208*dfe94b16Srobertdef initial_memory: JJ<"initial-memory=">,
209ece8a530Spatrick  HelpText<"Initial size of the linear memory">;
210ece8a530Spatrick
211*dfe94b16Srobertdef max_memory: JJ<"max-memory=">,
212ece8a530Spatrick  HelpText<"Maximum size of the linear memory">;
213ece8a530Spatrick
214*dfe94b16Srobertdef no_entry: FF<"no-entry">,
215ece8a530Spatrick  HelpText<"Do not output any entry point">;
216ece8a530Spatrick
217*dfe94b16Srobertdef stack_first: FF<"stack-first">,
218ece8a530Spatrick  HelpText<"Place stack at start of linear memory rather than after data">;
219ece8a530Spatrick
220ece8a530Spatrickdefm whole_archive: B<"whole-archive",
221ece8a530Spatrick    "Force load of all members in a static library",
222ece8a530Spatrick    "Do not force load of all members in a static library (default)">;
223ece8a530Spatrick
224*dfe94b16Srobertdef why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">;
225*dfe94b16Srobert
226*dfe94b16Srobertdefm check_features: BB<"check-features",
227ece8a530Spatrick    "Check feature compatibility of linked objects (default)",
228ece8a530Spatrick    "Ignore feature compatibility of linked objects">;
229ece8a530Spatrick
230ece8a530Spatrickdef features: CommaJoined<["--", "-"], "features=">,
231ece8a530Spatrick  HelpText<"Comma-separated used features, inferred from input objects by default.">;
232ece8a530Spatrick
233*dfe94b16Srobertdef extra_features: CommaJoined<["--", "-"], "extra-features=">,
234*dfe94b16Srobert  HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">;
235*dfe94b16Srobert
236ece8a530Spatrick// Aliases
237ece8a530Spatrickdef: JoinedOrSeparate<["-"], "e">, Alias<entry>;
238ece8a530Spatrickdef: J<"entry=">, Alias<entry>;
239*dfe94b16Srobertdef: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
240*dfe94b16Srobertdef: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
241*dfe94b16Srobertdef: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
242*dfe94b16Srobertdef: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
243*dfe94b16Srobertdef: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
244ece8a530Spatrickdef: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
245ece8a530Spatrickdef: Flag<["-"], "i">, Alias<initial_memory>;
246*dfe94b16Srobertdef: Separate<["--", "-"], "library">, Alias<library>;
247*dfe94b16Srobertdef: Joined<["--", "-"], "library=">, Alias<library>;
248*dfe94b16Srobertdef: Separate<["--", "-"], "library-path">, Alias<library_path>;
249*dfe94b16Srobertdef: Joined<["--", "-"], "library-path=">, Alias<library_path>;
2501cf9926bSpatrickdef: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
251ece8a530Spatrickdef: Flag<["-"], "r">, Alias<relocatable>;
252ece8a530Spatrickdef: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
253ece8a530Spatrickdef: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
254ece8a530Spatrickdef: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
255ece8a530Spatrickdef: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
256ece8a530Spatrickdef: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
257ece8a530Spatrick
258ece8a530Spatrick// LTO-related options.
259*dfe94b16Srobertdef lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
260ece8a530Spatrick  HelpText<"Optimization level for LTO">;
261*dfe94b16Srobertdef lto_partitions: JJ<"lto-partitions=">,
262ece8a530Spatrick  HelpText<"Number of LTO codegen partitions">;
263ece8a530Spatrickdef disable_verify: F<"disable-verify">;
2641cf9926bSpatrickdef save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
265*dfe94b16Srobertdef thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
266ece8a530Spatrick  HelpText<"Path to ThinLTO cached object file directory">;
267*dfe94b16Srobertdefm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
268*dfe94b16Srobertdef thinlto_jobs: JJ<"thinlto-jobs=">,
269bb684c34Spatrick  HelpText<"Number of ThinLTO jobs. Default to --threads=">;
270*dfe94b16Srobertdef no_lto_legacy_pass_manager: FF<"no-lto-legacy-pass-manager">,
271*dfe94b16Srobert  HelpText<"Use new pass manager">;
272*dfe94b16Srobertdef lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
2731cf9926bSpatrick  HelpText<"Debug new pass manager">;
274bb684c34Spatrick
275bb684c34Spatrick// Experimental PIC mode.
276*dfe94b16Srobertdef experimental_pic: FF<"experimental-pic">,
277bb684c34Spatrick  HelpText<"Enable Experimental PIC">;
278