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 m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
66
67def mllvm: S<"mllvm">, HelpText<"Options to pass to LLVM">;
68
69def no_color_diagnostics: F<"no-color-diagnostics">,
70  HelpText<"Do not use colors in diagnostics">;
71
72def no_fatal_warnings: F<"no-fatal-warnings">;
73
74def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
75  HelpText<"Path to file to write output">;
76
77def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
78
79defm pie: B<"pie",
80    "Create a position independent executable",
81    "Do not create a position independent executable (default)">;
82
83defm print_gc_sections: B<"print-gc-sections",
84    "List removed unused sections",
85    "Do not list removed unused sections">;
86
87def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
88
89defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">;
90
91defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
92  MetaVarName<"[posix,windows]">;
93
94def shared: F<"shared">, HelpText<"Build a shared object">;
95
96def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
97
98def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
99
100defm threads
101    : Eq<"threads", "Number of threads. '1' disables multi-threading. By "
102                    "default all available hardware threads are used">;
103
104def trace: F<"trace">, HelpText<"Print the names of the input files">;
105
106defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
107
108defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
109
110def v: Flag<["-"], "v">, HelpText<"Display the version number">;
111
112def verbose: F<"verbose">, HelpText<"Verbose mode">;
113
114def version: F<"version">, HelpText<"Display the version number and exit">;
115
116def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
117  HelpText<"Linker option extensions">;
118
119defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
120  MetaVarName<"<symbol>=<symbol>">;
121
122// The follow flags are unique to wasm
123
124def allow_undefined: F<"allow-undefined">,
125  HelpText<"Allow undefined symbols in linked binary">;
126
127def allow_undefined_file: J<"allow-undefined-file=">,
128  HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
129
130def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
131  Alias<allow_undefined_file>;
132
133defm export: Eq<"export", "Force a symbol to be exported">;
134
135def export_all: F<"export-all">,
136  HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
137
138def export_table: F<"export-table">,
139  HelpText<"Export function table to the environment">;
140
141def growable_table: F<"growable-table">,
142  HelpText<"Remove maximum size from function table, allowing table to grow">;
143
144def global_base: J<"global-base=">,
145  HelpText<"Where to start to place global data">;
146
147def import_memory: F<"import-memory">,
148  HelpText<"Import memory from the environment">;
149
150def shared_memory: F<"shared-memory">,
151  HelpText<"Use shared linear memory">;
152
153def import_table: F<"import-table">,
154  HelpText<"Import function table from the environment">;
155
156def initial_memory: J<"initial-memory=">,
157  HelpText<"Initial size of the linear memory">;
158
159def max_memory: J<"max-memory=">,
160  HelpText<"Maximum size of the linear memory">;
161
162def no_entry: F<"no-entry">,
163  HelpText<"Do not output any entry point">;
164
165def stack_first: F<"stack-first">,
166  HelpText<"Place stack at start of linear memory rather than after data">;
167
168defm whole_archive: B<"whole-archive",
169    "Force load of all members in a static library",
170    "Do not force load of all members in a static library (default)">;
171
172defm check_features: B<"check-features",
173    "Check feature compatibility of linked objects (default)",
174    "Ignore feature compatibility of linked objects">;
175
176def features: CommaJoined<["--", "-"], "features=">,
177  HelpText<"Comma-separated used features, inferred from input objects by default.">;
178
179// Aliases
180def: JoinedOrSeparate<["-"], "e">, Alias<entry>;
181def: J<"entry=">, Alias<entry>;
182def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
183def: Flag<["-"], "i">, Alias<initial_memory>;
184def: Flag<["-"], "r">, Alias<relocatable>;
185def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
186def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
187def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
188def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
189def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
190
191// LTO-related options.
192def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
193  HelpText<"Optimization level for LTO">;
194def lto_partitions: J<"lto-partitions=">,
195  HelpText<"Number of LTO codegen partitions">;
196def disable_verify: F<"disable-verify">;
197def save_temps: F<"save-temps">;
198def thinlto_cache_dir: J<"thinlto-cache-dir=">,
199  HelpText<"Path to ThinLTO cached object file directory">;
200defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
201def thinlto_jobs: J<"thinlto-jobs=">,
202  HelpText<"Number of ThinLTO jobs. Default to --threads=">;
203
204// Experimental PIC mode.
205def experimental_pic: F<"experimental-pic">,
206  HelpText<"Enable Experimental PIC">;
207