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