blob: 2f699e2f68350688f9aa22f9077a6a74f3a07f1d [file] [log] [blame]
Sam Cleggc94d3932017-11-17 18:14:091include "llvm/Option/OptParser.td"
2
Sam Clegg87628f52022-05-26 21:05:053// 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
6// with GNU ld.
7class FF<string name> : Flag<["--"], name>;
8class JJ<string name>: Joined<["--"], name>;
9
10multiclass EEq<string name, string help> {
11 def NAME: Separate<["--"], name>;
12 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
13 HelpText<help>;
14}
15
16multiclass BB<string name, string help1, string help2> {
17 def NAME: Flag<["--"], name>, HelpText<help1>;
18 def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
19}
20
Sam Cleggc94d3932017-11-17 18:14:0921// For options whose names are multiple letters, either one dash or
22// two can precede the option name except those that start with 'o'.
23class F<string name>: Flag<["--", "-"], name>;
24class J<string name>: Joined<["--", "-"], name>;
25class S<string name>: Separate<["--", "-"], name>;
26
Sam Cleggad980a72018-10-22 08:34:3727multiclass Eq<string name, string help> {
28 def NAME: Separate<["--", "-"], name>;
29 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
30 HelpText<help>;
Sam Clegg31de2f02017-12-07 03:19:5331}
32
Nicholas Wilson08cff612018-03-13 13:12:0333multiclass B<string name, string help1, string help2> {
34 def NAME: Flag<["--", "-"], name>, HelpText<help1>;
35 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
36}
37
Sam Cleggbfb75342018-11-15 00:37:2138// The following flags are shared with the ELF linker
Sam Clegg25134072020-10-07 21:48:3739def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
40
YAMAMOTO Takashi2b6c6bb2024-06-11 23:45:5341def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
Sam Clegg0a9756f2022-10-03 15:31:2342
YAMAMOTO Takashi2b6c6bb2024-06-11 23:45:5343def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries (default)">;
Sam Clegg0a9756f2022-10-03 15:31:2344
mzukovec03673052024-09-04 15:50:1045defm allow_multiple_definition: B<"allow-multiple-definition",
46 "Allow multiple definitions",
47 "Do not allow multiple definitions (default)">;
48
Derek Schuffc7af9ae2023-03-02 23:52:2549def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
50
51def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
52 MetaVarName<"[fast,sha1,uuid,0x<hexstring>]">;
53
Nico Weberbaa2aa22020-11-17 17:15:4254defm color_diagnostics: B<"color-diagnostics",
55 "Alias for --color-diagnostics=always",
56 "Alias for --color-diagnostics=never">;
Sam Cleggc94d3932017-11-17 18:14:0957def color_diagnostics_eq: J<"color-diagnostics=">,
Nico Weberbaa2aa22020-11-17 17:15:4258 HelpText<"Use colors in diagnostics (default: auto)">,
59 MetaVarName<"[auto,always,never]">;
Sam Cleggc94d3932017-11-17 18:14:0960
Sam Clegg30161dc2018-08-17 19:42:4661def compress_relocations: F<"compress-relocations">,
62 HelpText<"Compress the relocation targets in the code section.">;
63
Nicholas Wilson08cff612018-03-13 13:12:0364defm demangle: B<"demangle",
Sam Clegg888b1302024-07-18 01:26:5965 "Demangle symbol names (default)",
Nicholas Wilson08cff612018-03-13 13:12:0366 "Do not demangle symbol names">;
67
Sam Clegg35be7ff2019-05-24 13:28:2768def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
69
Sam Clegg206884b2020-05-01 16:14:5970def error_unresolved_symbols: F<"error-unresolved-symbols">,
71 HelpText<"Report unresolved symbols as errors">;
72
Sam Clegg305b0342018-09-27 21:06:2573defm export_dynamic: B<"export-dynamic",
74 "Put symbols in the dynamic symbol table",
75 "Do not put symbols in the dynamic symbol table (default)">;
Sam Clegg4e624182018-09-25 21:50:1576
Sam Clegg19261392024-01-22 18:04:2677def end_lib: F<"end-lib">,
78 HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
79
Sam Cleggb839f152018-01-28 19:57:0480def entry: S<"entry">, MetaVarName<"<entry>">,
81 HelpText<"Name of entry point symbol">;
82
Sam Clegg87628f52022-05-26 21:05:0583defm error_limit:
84 EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
Sam Cleggb839f152018-01-28 19:57:0485
Sam Clegg888b1302024-07-18 01:26:5986defm fatal_warnings: B<"fatal-warnings",
87 "Treat warnings as errors",
88 "Do not treat warnings as errors (default)">;
Sam Cleggb839f152018-01-28 19:57:0489
Nicholas Wilson88d9ffc2018-03-13 13:16:1590defm gc_sections: B<"gc-sections",
Sam Clegg888b1302024-07-18 01:26:5991 "Enable garbage collection of unused sections (defualt)",
Nicholas Wilson88d9ffc2018-03-13 13:16:1592 "Disable garbage collection of unused sections">;
Sam Clegg03626332018-01-31 01:45:4793
Sam Clegg87628f52022-05-26 21:05:0594defm merge_data_segments: BB<"merge-data-segments",
Sam Clegg888b1302024-07-18 01:26:5995 "Enable merging data segments (default)",
Sam Clegg66844762018-05-10 18:23:5196 "Disable merging data segments">;
97
Sam Cleggc94d3932017-11-17 18:14:0998def help: F<"help">, HelpText<"Print option help">;
99
Sam Clegg0a9756f2022-10-03 15:31:23100def library: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
Sam Cleggc94d3932017-11-17 18:14:09101 HelpText<"Root name of library to use">;
102
Sam Clegg0a9756f2022-10-03 15:31:23103def library_path: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
Sam Cleggb839f152018-01-28 19:57:04104 HelpText<"Add a directory to the library search path">;
105
Wouter van Oortmerssenb9a539c2020-06-15 22:31:10106def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
107
Sam Clegg87628f52022-05-26 21:05:05108defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
Sam Cleggc94d3932017-11-17 18:14:09109
Sam Cleggcc2da552020-03-27 23:52:27110defm Map: Eq<"Map", "Print a link map to the specified file">;
111
mzukovec03673052024-09-04 15:50:10112def noinhibit_exec: F<"noinhibit-exec">,
113 HelpText<"Retain the executable output file whenever it is still usable">;
114
Sam Cleggc94d3932017-11-17 18:14:09115def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
116 HelpText<"Path to file to write output">;
117
Sam Cleggfb983cd2018-05-18 23:28:05118def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
119
Sam Cleggbfb75342018-11-15 00:37:21120defm pie: B<"pie",
121 "Create a position independent executable",
122 "Do not create a position independent executable (default)">;
123
Nicholas Wilson88d9ffc2018-03-13 13:16:15124defm print_gc_sections: B<"print-gc-sections",
125 "List removed unused sections",
Sam Clegg888b1302024-07-18 01:26:59126 "Do not list removed unused sections (default)">;
Sam Clegg03626332018-01-31 01:45:47127
Sam Cleggcc2da552020-03-27 23:52:27128def print_map: F<"print-map">,
129 HelpText<"Print a link map to the standard output">;
130
Sam Cleggc94d3932017-11-17 18:14:09131def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
132
Sam Clegg87628f52022-05-26 21:05:05133defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
Rui Ueyama35150bb2019-05-21 11:52:14134
Hood Chatham80ea31c2025-02-28 19:12:52135defm rpath: Eq<"rpath", "Add a DT_RUNPATH to the output">;
136
Sam Clegg928e9e12020-03-04 19:29:45137defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
138 MetaVarName<"[posix,windows]">;
139
Sam Cleggbfb75342018-11-15 00:37:21140def shared: F<"shared">, HelpText<"Build a shared object">;
141
Sam Clegg19261392024-01-22 18:04:26142def start_lib: F<"start-lib">,
143 HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">;
144
Sam Cleggc94d3932017-11-17 18:14:09145def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
146
147def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
148
Fangrui Songeb4663d2020-03-17 19:40:19149defm threads
150 : Eq<"threads", "Number of threads. '1' disables multi-threading. By "
151 "default all available hardware threads are used">;
Sam Cleggb839f152018-01-28 19:57:04152
Sam Clegg1f3f7742019-02-06 02:35:18153def trace: F<"trace">, HelpText<"Print the names of the input files">;
154
155defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
156
Sam Cleggad980a72018-10-22 08:34:37157defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
Sam Clegg31de2f02017-12-07 03:19:53158
Sam Clegg206884b2020-05-01 16:14:59159defm unresolved_symbols:
160 Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
161
Sam Cleggb839f152018-01-28 19:57:04162def v: Flag<["-"], "v">, HelpText<"Display the version number">;
163
164def verbose: F<"verbose">, HelpText<"Verbose mode">;
165
166def version: F<"version">, HelpText<"Display the version number and exit">;
167
Sam Clegg206884b2020-05-01 16:14:59168def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
169 HelpText<"Report unresolved symbols as warnings">;
Sam Cleggc94d3932017-11-17 18:14:09170
Sam Clegga5ca34e2019-05-24 14:14:25171defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
172 MetaVarName<"<symbol>=<symbol>">;
173
Sam Clegg206884b2020-05-01 16:14:59174def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
175 HelpText<"Linker option extensions">;
176
Sam Cleggc94d3932017-11-17 18:14:09177// The follow flags are unique to wasm
178
Sam Cleggc94d3932017-11-17 18:14:09179def allow_undefined: F<"allow-undefined">,
Nico Weber9f903472021-10-27 13:52:17180 HelpText<"Allow undefined symbols in linked binary. "
181 "This options is equivalent to --import-undefined "
182 "and --unresolved-symbols=ignore-all">;
Sam Clegg758633f2021-05-27 21:27:10183
184def import_undefined: F<"import-undefined">,
185 HelpText<"Turn undefined symbols into imports where possible">;
Sam Cleggc94d3932017-11-17 18:14:09186
187def allow_undefined_file: J<"allow-undefined-file=">,
188 HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
189
Sam Cleggb839f152018-01-28 19:57:04190def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
191 Alias<allow_undefined_file>;
192
Sam Cleggad980a72018-10-22 08:34:37193defm export: Eq<"export", "Force a symbol to be exported">;
Sam Cleggb839f152018-01-28 19:57:04194
Sam Clegga6f40642021-04-05 15:00:30195defm export_if_defined: Eq<"export-if-defined",
196 "Force a symbol to be exported, if it is defined in the input">;
197
Sam Clegg87628f52022-05-26 21:05:05198def export_all: FF<"export-all">,
Sam Clegg177b4582018-06-07 01:27:07199 HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
200
Sam Clegg87628f52022-05-26 21:05:05201def export_table: FF<"export-table">,
Nicholas Wilson874eedd2018-03-27 17:38:51202 HelpText<"Export function table to the environment">;
203
Sam Clegg87628f52022-05-26 21:05:05204def growable_table: FF<"growable-table">,
Jacob Gravelle92ed86d2019-08-27 22:58:21205 HelpText<"Remove maximum size from function table, allowing table to grow">;
206
Sam Clegg87628f52022-05-26 21:05:05207def global_base: JJ<"global-base=">,
Sam Clegg93adcb72023-08-25 20:56:16208 HelpText<"Memory offset at which to place global data (Defaults to 1024)">;
Sam Cleggb839f152018-01-28 19:57:04209
Sam Clegg89d56352023-05-04 23:04:04210defm keep_section: Eq<"keep-section",
211 "Preserve a section even when --strip-all is given. This is useful for compiler drivers such as clang or emcc that, for example, depend on the features section for post-link processing. Can be specified multiple times to keep multiple sections">;
212
Sam Clegg87628f52022-05-26 21:05:05213def import_memory: FF<"import-memory">,
Dan Gohmand4c8a0e2022-10-04 19:50:10214 HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">;
215def import_memory_with_name: JJ<"import-memory=">,
216 HelpText<"Import the module's memory from the passed module with the passed name.">,
217 MetaVarName<"<module>,<name>">;
218
219def export_memory: FF<"export-memory">,
220 HelpText<"Export the module's memory with the default name of \"memory\"">;
221def export_memory_with_name: JJ<"export-memory=">,
222 HelpText<"Export the module's memory with the passed name">;
Sam Cleggb839f152018-01-28 19:57:04223
Sam Clegg87628f52022-05-26 21:05:05224def shared_memory: FF<"shared-memory">,
Derek Schuff3bea8bc2018-11-06 17:59:32225 HelpText<"Use shared linear memory">;
226
Sam Clegg8e44f032023-05-27 01:17:45227defm soname: Eq<"soname", "Set the module name in the generated name section">;
228
Sam Clegg87628f52022-05-26 21:05:05229def import_table: FF<"import-table">,
Nicholas Wilson874eedd2018-03-27 17:38:51230 HelpText<"Import function table from the environment">;
231
SingleAccretionb2cdf3c2023-12-15 18:16:38232def initial_heap: JJ<"initial-heap=">,
233 HelpText<"Initial size of the heap">;
234
Nick Fitzgerald60189302025-03-04 17:39:30235def page_size: JJ<"page-size=">,
236 HelpText<"The Wasm page size (Defaults to 65536)">;
237
Sam Clegg87628f52022-05-26 21:05:05238def initial_memory: JJ<"initial-memory=">,
Sam Cleggb839f152018-01-28 19:57:04239 HelpText<"Initial size of the linear memory">;
240
Sam Clegg87628f52022-05-26 21:05:05241def max_memory: JJ<"max-memory=">,
Sam Cleggb839f152018-01-28 19:57:04242 HelpText<"Maximum size of the linear memory">;
243
SingleAccretioncb4f94d2024-02-25 16:43:11244def no_growable_memory: FF<"no-growable-memory">,
245 HelpText<"Set maximum size of the linear memory to its initial size">;
246
Sam Clegg87628f52022-05-26 21:05:05247def no_entry: FF<"no-entry">,
Sam Cleggb839f152018-01-28 19:57:04248 HelpText<"Do not output any entry point">;
Sam Cleggc94d3932017-11-17 18:14:09249
Sam Clegg22b7b842024-07-12 20:26:52250def no_shlib_sigcheck: FF<"no-shlib-sigcheck">,
251 HelpText<"Do not check signatures of functions defined in shared libraries.">;
252
Sam Clegg87628f52022-05-26 21:05:05253def stack_first: FF<"stack-first">,
Sam Clegga0f095e2018-05-03 17:21:53254 HelpText<"Place stack at start of linear memory rather than after data">;
255
Sam Clegg93adcb72023-08-25 20:56:16256def table_base: JJ<"table-base=">,
257 HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
258
Sam Clegg8adf7ac2018-07-23 23:51:19259defm whole_archive: B<"whole-archive",
260 "Force load of all members in a static library",
261 "Do not force load of all members in a static library (default)">;
262
Sam Clegg8aef04f2023-03-06 17:18:03263def why_extract: JJ<"why-extract=">, HelpText<"Print to a file about why archive members are extracted">;
264
Sam Clegg87628f52022-05-26 21:05:05265defm check_features: BB<"check-features",
Thomas Lively82de51a2019-03-26 04:11:05266 "Check feature compatibility of linked objects (default)",
267 "Ignore feature compatibility of linked objects">;
268
269def features: CommaJoined<["--", "-"], "features=">,
270 HelpText<"Comma-separated used features, inferred from input objects by default.">;
271
Sam Cleggc07e8382022-10-12 23:39:47272def extra_features: CommaJoined<["--", "-"], "extra-features=">,
273 HelpText<"Comma-separated list of features to add to the default set of features inferred from input objects.">;
274
Sam Cleggc94d3932017-11-17 18:14:09275// Aliases
Sam Clegg305b0342018-09-27 21:06:25276def: JoinedOrSeparate<["-"], "e">, Alias<entry>;
277def: J<"entry=">, Alias<entry>;
Sam Clegg0a9756f2022-10-03 15:31:23278def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
279def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
280def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
281def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
282def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
Sam Clegg305b0342018-09-27 21:06:25283def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
284def: Flag<["-"], "i">, Alias<initial_memory>;
Sam Clegg0a9756f2022-10-03 15:31:23285def: Separate<["--", "-"], "library">, Alias<library>;
286def: Joined<["--", "-"], "library=">, Alias<library>;
287def: Separate<["--", "-"], "library-path">, Alias<library_path>;
288def: Joined<["--", "-"], "library-path=">, Alias<library_path>;
Sam Cleggcc2da552020-03-27 23:52:27289def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
Sam Clegg305b0342018-09-27 21:06:25290def: Flag<["-"], "r">, Alias<relocatable>;
Sam Clegg59d52f82018-10-31 19:30:43291def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
292def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
Sam Clegg1f3f7742019-02-06 02:35:18293def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
294def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
Sam Clegg305b0342018-09-27 21:06:25295def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
Sam Clegg0764e552024-10-22 17:47:57296def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">;
Sam Cleggc729c1b2018-05-30 18:07:52297
298// LTO-related options.
Sam Clegg87628f52022-05-26 21:05:05299def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
Sam Cleggc729c1b2018-05-30 18:07:52300 HelpText<"Optimization level for LTO">;
Scott Linder45ee0a92023-02-15 17:12:47301def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">,
302 HelpText<"Codegen optimization level for LTO">;
Sam Clegg87628f52022-05-26 21:05:05303def lto_partitions: JJ<"lto-partitions=">,
Sam Cleggc729c1b2018-05-30 18:07:52304 HelpText<"Number of LTO codegen partitions">;
Sam Clegg9a450a02024-11-01 23:34:06305def lto_obj_path_eq: JJ<"lto-obj-path=">;
Sam Cleggc729c1b2018-05-30 18:07:52306def disable_verify: F<"disable-verify">;
Sam Clegg299b0e52021-01-18 19:39:28307def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
Sam Clegg87628f52022-05-26 21:05:05308def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
Sam Cleggc729c1b2018-05-30 18:07:52309 HelpText<"Path to ThinLTO cached object file directory">;
Sam Clegg87628f52022-05-26 21:05:05310defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
Sam Clegg9a450a02024-11-01 23:34:06311def thinlto_emit_index_files: FF<"thinlto-emit-index-files">;
312def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;
313def thinlto_index_only: FF<"thinlto-index-only">;
314def thinlto_index_only_eq: JJ<"thinlto-index-only=">;
Sam Clegg87628f52022-05-26 21:05:05315def thinlto_jobs: JJ<"thinlto-jobs=">,
Fangrui Songeb4663d2020-03-17 19:40:19316 HelpText<"Number of ThinLTO jobs. Default to --threads=">;
Sam Cleggb70eb862024-11-09 00:48:30317def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;
318def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;
Sam Clegg87628f52022-05-26 21:05:05319def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
Arthur Eubanks1314a492020-12-01 20:22:27320 HelpText<"Debug new pass manager">;
Dan Gohman46a32682020-06-12 19:05:40321
322// Experimental PIC mode.
Sam Clegg87628f52022-05-26 21:05:05323def experimental_pic: FF<"experimental-pic">,
Dan Gohman46a32682020-06-12 19:05:40324 HelpText<"Enable Experimental PIC">;