1 include "llvm/Option/OptParser.td"
3 class F<string name>: Flag<["--", "-"], name>;
4 class J<string name>: Joined<["--", "-"], name>;
5 class S<string name>: Separate<["--", "-"], name>;
7 // Convenience classes for long options which only accept two dashes. For lld
8 // specific or newer long options, we prefer two dashes to avoid collision with
9 // short options. For many others, we have to accept both forms to be compatible
11 class FF<string name> : Flag<["--"], name>;
12 class JJ<string name>: Joined<["--"], name>;
14 multiclass Eq<string name, string help> {
15 def NAME: Separate<["--", "-"], name>;
16 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
20 multiclass EEq<string name, string help> {
21 def NAME: Separate<["--"], name>;
22 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
26 multiclass EqLong<string name, string help> {
27 def NAME: Separate<["--"], name>;
28 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
32 multiclass EqNoHelp<string name> {
33 def NAME: Separate<["--", "-"], name>;
34 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
37 multiclass B<string name, string help1, string help2> {
38 def NAME: Flag<["--", "-"], name>, HelpText<help1>;
39 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
42 multiclass B_disable<string name, string help1, string help2> {
43 def NAME: Flag<["--", "-"], name>, HelpText<help1>;
44 def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
47 multiclass B_enable_disable<string name, string help1, string help2> {
48 def enable_ # NAME: Flag<["--", "-"], "enable-" # name>, HelpText<help1>;
49 def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
52 def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
53 HelpText<"Add a directory to the library search path">;
54 defm allow_multiple_definition: B<"allow-multiple-definition",
55 "Allow multiple definitions",
56 "Do not allow multiple definitions (default)">;
57 def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
58 def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
59 defm demangle: B<"demangle",
60 "Demangle symbol names (default)",
61 "Do not demangle symbol names">;
62 def disable_auto_import: F<"disable-auto-import">,
63 HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;
64 def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,
65 HelpText<"Don't do automatic imports that require runtime fixups">;
66 def disable_stdcall_fixup: F<"disable-stdcall-fixup">,
67 HelpText<"Don't resolve stdcall/fastcall/vectorcall to undecorated symbols">;
68 defm dynamicbase: B_disable<"dynamicbase", "Enable ASLR", "Disable ASLR">;
69 def enable_auto_import: F<"enable-auto-import">,
70 HelpText<"Automatically import data symbols from other DLLs where needed">;
71 def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">,
72 HelpText<"Allow automatic imports that require runtime fixups">;
73 def enable_stdcall_fixup: F<"enable-stdcall-fixup">,
74 HelpText<"Resolve stdcall/fastcall/vectorcall to undecorated symbols without warnings">;
75 defm entry: Eq<"entry", "Name of entry point symbol">, MetaVarName<"<entry>">;
76 def exclude_all_symbols: F<"exclude-all-symbols">,
77 HelpText<"Don't automatically export any symbols">;
78 defm exclude_symbols: Eq<"exclude-symbols",
79 "Exclude symbols from automatic export">, MetaVarName<"<symbol[,symbol,...]>">;
80 def export_all_symbols: F<"export-all-symbols">,
81 HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
82 defm fatal_warnings: B<"fatal-warnings",
83 "Treat warnings as errors",
84 "Do not treat warnings as errors (default)">;
85 defm file_alignment: Eq<"file-alignment", "Set file alignment">;
86 defm gc_sections: B<"gc-sections",
87 "Remove unused sections",
88 "Don't remove unused sections">;
89 defm heap: Eq<"heap", "Set size of the initial heap">;
90 def help: F<"help">, HelpText<"Print option help">;
91 defm high_entropy_va: B_disable<"high-entropy-va",
92 "Set the 'high entropy VA' flag", "Don't set the 'high entropy VA' flag">;
93 defm icf: Eq<"icf", "Identical code folding">;
94 defm image_base: Eq<"image-base", "Base address of the program">;
95 defm insert_timestamp: B<"insert-timestamp",
96 "Include PE header timestamp",
97 "Don't include PE header timestamp">;
98 def kill_at: F<"kill-at">, HelpText<"Remove @n from exported symbols">;
99 def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
100 HelpText<"Root name of library to use">;
101 def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
102 defm major_os_version: EqLong<"major-os-version",
103 "Set the OS and subsystem major version">;
104 defm major_subsystem_version: EqLong<"major-subsystem-version",
105 "Set the OS and subsystem major version">;
106 defm map: Eq<"Map", "Output a linker map">;
107 defm minor_os_version: EqLong<"minor-os-version",
108 "Set the OS and subsystem minor version">;
109 defm minor_subsystem_version: EqLong<"minor-subsystem-version",
110 "Set the OS and subsystem minor version">;
111 defm no_seh: B_disable<"no-seh",
112 "Set the 'no SEH' flag in the executable", "Don't set the 'no SEH' flag">;
113 defm nxcompat: B_disable<"nxcompat",
114 "Set the 'nxcompat' flag in the executable", "Don't set the 'nxcompat' flag">;
115 def large_address_aware: Flag<["--"], "large-address-aware">,
116 HelpText<"Enable large addresses">;
117 def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
118 HelpText<"Path to file to write output">;
119 defm out_implib: Eq<"out-implib", "Import library name">;
120 defm output_def: Eq<"output-def", "Output def file">;
121 defm reloc_section: B_enable_disable<"reloc-section",
122 "Enable base relocations", "Disable base relocations">;
123 defm section_alignment: Eq<"section-alignment", "Set section alignment">;
124 def shared: F<"shared">, HelpText<"Build a shared object">;
125 defm subs: Eq<"subsystem", "Specify subsystem">;
126 defm stack: Eq<"stack", "Set size of the initial stack">;
127 def strip_all: F<"strip-all">,
128 HelpText<"Omit all symbol information from the output binary">;
129 def strip_debug: F<"strip-debug">,
130 HelpText<"Omit all debug information, but keep symbol information">;
131 defm reproduce: Eq<"reproduce",
132 "Write a tar file containing input files and command line options to reproduce link">;
133 defm require_defined: Eq<"require-defined",
134 "Force symbol to be added to symbol table as an undefined one">;
137 "Number of threads. '1' disables multi-threading. By default all "
138 "available hardware threads are used">;
139 defm tsaware: B_disable<"tsaware",
140 "Set the 'Terminal Server aware' flag", "Don't set the 'Terminal Server aware' flag">;
141 defm undefined: Eq<"undefined", "Include symbol in the link, if available">;
142 defm undefined_glob: EEq<"undefined-glob", "Force undefined symbol during linking">,
143 MetaVarName<"<pattern>">;
144 defm whole_archive: B<"whole-archive",
145 "Include all object files for following archives",
146 "No longer include all object files for following archives">;
147 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
148 def verbose: F<"verbose">, HelpText<"Verbose mode">;
149 def version: F<"version">, HelpText<"Display the version number and exit">;
150 defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
151 MetaVarName<"<symbol>">;
154 // LLD specific options, for LTO, shared with the ELF backend
155 def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
156 HelpText<"Optimization level for LTO">;
157 def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">,
158 HelpText<"Codegen optimization level for LTO">;
159 def lto_cs_profile_generate: FF<"lto-cs-profile-generate">,
160 HelpText<"Perform context sensitive PGO instrumentation">;
161 def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
162 HelpText<"Context sensitive profile file path">;
163 def lto_emit_asm: FF<"lto-emit-asm">,
164 HelpText<"Emit assembly code">;
165 def lto_sample_profile: JJ<"lto-sample-profile=">,
166 HelpText<"Sample profile file path">;
168 def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
169 HelpText<"Path to ThinLTO cached object file directory">;
170 defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
171 def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;
172 def thinlto_index_only: FF<"thinlto-index-only">;
173 def thinlto_index_only_eq: JJ<"thinlto-index-only=">;
174 def thinlto_jobs_eq: JJ<"thinlto-jobs=">,
175 HelpText<"Number of ThinLTO jobs. Default to --threads=">;
176 def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;
177 def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;
179 def plugin_opt_eq_minus: J<"plugin-opt=-">,
180 HelpText<"Specify an LLVM option for compatibility with LLVMgold.so">;
181 def: J<"plugin-opt=thinlto">;
183 def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for --lto-O">;
184 def: F<"plugin-opt=cs-profile-generate">,
185 Alias<lto_cs_profile_generate>, HelpText<"Alias for --lto-cs-profile-generate">;
186 def: J<"plugin-opt=cs-profile-path=">,
187 Alias<lto_cs_profile_file>, HelpText<"Alias for --lto-cs-profile-file">;
188 def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
189 HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
190 def plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,
191 Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;
192 def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;
193 def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs_eq>, HelpText<"Alias for --thinlto-jobs=">;
194 def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
196 // This may be either an unhandled LLVMgold.so feature or GCC passed
197 // -plugin-opt=path/to/{liblto_plugin.so,lto-wrapper}
198 def plugin_opt_eq : J<"plugin-opt=">;
200 // LLD specific options
201 def _HASH_HASH_HASH : Flag<["-"], "###">,
202 HelpText<"Print (but do not run) the commands to run for this compilation">;
203 def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
204 defm delayload: Eq<"delayload", "DLL to load only on demand">;
205 defm mllvm: EqNoHelp<"mllvm">;
206 defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
207 defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;
208 defm guard_cf : B<"guard-cf", "Enable Control Flow Guard" ,
209 "Do not enable Control Flow Guard (default)">;
210 defm guard_longjmp : B<"guard-longjmp",
211 "Enable Control Flow Guard long jump hardening (default for --guard-cf)" ,
212 "Do not enable Control Flow Guard long jump hardening">;
214 EqLong<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
215 def build_id: J<"build-id=">, HelpText<"Generate build ID note (pass none to disable)">,
216 MetaVarName<"<arg>">;
217 def : F<"build-id">, Alias<build_id>, HelpText<"Alias for --build-id=">;
218 def functionpadmin: J<"functionpadmin=">, HelpText<"Prepares an image for hotpatching">,
219 MetaVarName<"<arg>">;
220 def : F<"functionpadmin">, Alias<functionpadmin>, HelpText<"Alias for --functionpadmin=">;
223 def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
224 def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
225 def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;
226 def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;
227 def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;
228 def alias_dll: F<"dll">, Alias<shared>;
229 def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
230 def alias_no_dynamicbase: F<"no-dynamicbase">, Alias<disable_dynamicbase>;
231 def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;
232 def alias_strip_S: Flag<["-"], "S">, Alias<strip_debug>;
233 def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
236 def: Joined<["-"], "O">;
238 def: F<"disable-auto-image-base">;
239 def: F<"enable-auto-image-base">;
241 def: Flag<["--"], "full-shutdown">;
242 defm: EqNoHelp<"major-image-version">;
243 defm: EqNoHelp<"minor-image-version">;
244 def: F<"no-undefined">;
245 def: F<"pic-executable">;
246 defm: EqNoHelp<"plugin">;
247 defm: EqNoHelp<"sysroot">;
248 def: F<"sort-common">;
249 def: F<"start-group">;
251 // Ignored options, that produce warnings
252 defm rpath: EqNoHelp<"rpath">;
254 // Ignore GCC collect2 LTO plugin related options. Note that we don't support
255 // GCC LTO, but GCC collect2 passes these options even in non-LTO mode.
256 def: J<"plugin-opt=-fresolution=">;
257 def: J<"plugin-opt=-pass-through=">;