1 include "llvm/Option/OptParser.td"
3 // link.exe accepts options starting with either a dash or a slash.
5 // Flag that takes no arguments.
6 class F<string name> : Flag<["/", "-", "/?", "-?"], name>;
8 // Flag that takes one argument after ":".
9 class P<string name, string help> :
10 Joined<["/", "-", "/?", "-?"], name#":">, HelpText<help>;
12 // Same as P<> above, but without help texts, for private undocumented
14 class P_priv<string name> :
15 Joined<["/", "-", "/?", "-?"], name#":">;
17 // Boolean flag which can be suffixed by ":no". Using it unsuffixed turns the
18 // flag on and using it suffixed by ":no" turns it off.
19 multiclass B<string name, string help_on, string help_off> {
20 def "" : F<name>, HelpText<help_on>;
21 def _no : F<name#":no">, HelpText<help_off>;
24 // Same as B<> above, but without help texts, for private undocumented
26 multiclass B_priv<string name> {
28 def _no : F<name#":no">;
31 def align : P<"align", "Section alignment">;
32 def aligncomm : P<"aligncomm", "Set common symbol alignment">;
33 def alternatename : P<"alternatename", "Define weak alias">;
34 def base : P<"base", "Base address of the program">;
35 def color_diagnostics: Flag<["--"], "color-diagnostics">,
36 HelpText<"Alias for --color-diagnostics=always">;
37 def no_color_diagnostics: Flag<["--"], "no-color-diagnostics">,
38 HelpText<"Alias for --color-diagnostics=never">;
39 def color_diagnostics_eq: Joined<["--"], "color-diagnostics=">,
40 HelpText<"Use colors in diagnostics (default: auto)">,
41 MetaVarName<"[auto,always,never]">;
42 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
43 def delayload : P<"delayload", "Delay loaded DLL name">;
44 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
45 def entry : P<"entry", "Name of entry point symbol">;
46 def errorlimit : P<"errorlimit",
47 "Maximum number of errors to emit before stopping (0 = no limit)">;
48 def export : P<"export", "Export a function">;
49 // No help text because /failifmismatch is not intended to be used by the user.
50 def failifmismatch : P<"failifmismatch", "">;
51 def filealign : P<"filealign", "Section alignment in the output file">;
52 def functionpadmin : F<"functionpadmin">;
53 def functionpadmin_opt : P<"functionpadmin",
54 "Prepares an image for hotpatching">;
55 def guard : P<"guard", "Control flow guard">;
56 def heap : P<"heap", "Size of the heap">;
57 def ignore : P<"ignore", "Specify warning codes to ignore">;
58 def implib : P<"implib", "Import library name">;
60 HelpText<"Act like lib.exe; must be first argument if present">;
61 def libpath : P<"libpath", "Additional library search path">;
62 def linkrepro : Joined<["/", "-", "/?", "-?"], "linkrepro:">,
63 MetaVarName<"directory">,
64 HelpText<"Write repro.tar containing inputs and command to reproduce link">;
65 def lldignoreenv : F<"lldignoreenv">,
66 HelpText<"Ignore environment variables like %LIB%">;
67 def lldltocache : P<"lldltocache",
68 "Path to ThinLTO cached object file directory">;
69 def lldltocachepolicy : P<"lldltocachepolicy",
70 "Pruning policy for the ThinLTO cache">;
71 def lldsavetemps : F<"lldsavetemps">,
72 HelpText<"Save intermediate LTO compilation results">;
73 def machine : P<"machine", "Specify target platform">;
74 def merge : P<"merge", "Combine sections">;
75 def mllvm : P<"mllvm", "Options to pass to LLVM">;
76 def nodefaultlib : P<"nodefaultlib", "Remove a default library">;
77 def opt : P<"opt", "Control optimizations">;
78 def order : P<"order", "Put functions in order">;
79 def out : P<"out", "Path to file to write output">;
80 def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
81 def pdb : P<"pdb", "PDB file path">;
82 def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
83 def pdbpagesize : P<"pdbpagesize", "PDB page size">;
84 def pdbstripped : P<"pdbstripped", "Stripped PDB file path">;
85 def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">,
86 MetaVarName<"<name>=<file>">,
87 HelpText<"Embed the contents of <file> in the PDB as named stream <name>">;
88 def section : P<"section", "Specify section attributes">;
89 def stack : P<"stack", "Size of the stack">;
90 def stub : P<"stub", "Specify DOS stub file">;
91 def subsystem : P<"subsystem", "Specify subsystem">;
92 def timestamp : P<"timestamp", "Specify the PE header timestamp">;
93 def vctoolsdir : P<"vctoolsdir", "Set the location of the VC tools">;
94 def vctoolsversion : P<"vctoolsversion",
95 "Specify which VC tools version to use">;
96 def version : P<"version", "Specify a version number in the PE header">;
97 def wholearchive_file : P<"wholearchive",
98 "Include all object files from this library">;
99 def winsdkdir : P<"winsdkdir", "Set the location of the Windows SDK">;
100 def winsdkversion : P<"winsdkversion", "Specify which SDK version to use">;
101 def winsysroot : P<"winsysroot",
102 "Adds several subdirectories to the library search paths">;
104 def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
107 def manifest : F<"manifest">, HelpText<"Create .manifest file">;
108 def manifest_colon : P<
110 "NO disables manifest output; EMBED[,ID=#] embeds manifest as resource in the image">;
111 def manifestuac : P<"manifestuac", "User access control">;
112 def manifestfile : P<"manifestfile", "Manifest output path, with /manifest">;
113 def manifestdependency : P<
114 "manifestdependency",
115 "Attributes for <dependency> element in manifest file; implies /manifest">;
116 def manifestinput : P<
118 "Additional manifest inputs; only valid with /manifest:embed">;
120 // We cannot use multiclass P because class name "incl" is different
121 // from its command line option name. We do this because "include" is
122 // a reserved keyword in tablegen.
123 def incl : Joined<["/", "-", "/?", "-?"], "include:">,
124 HelpText<"Force symbol to be added to symbol table as undefined one">;
126 // "def" is also a keyword.
127 def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
128 HelpText<"Use module-definition file">;
130 def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
131 def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
132 def debugtype : P<"debugtype", "Debug Info Options">;
133 def dll : F<"dll">, HelpText<"Create a DLL">;
134 def driver : F<"driver">, HelpText<"Generate a Windows NT Kernel Mode Driver">;
135 def driver_wdm : F<"driver:wdm">,
136 HelpText<"Set IMAGE_FILE_UP_SYSTEM_ONLY bit in PE header">;
137 def driver_uponly : F<"driver:uponly">,
138 HelpText<"Set IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER bit in PE header">;
139 def driver_wdm_uponly : F<"driver:wdm,uponly">;
140 def driver_uponly_wdm : F<"driver:uponly,wdm">;
141 def nodefaultlib_all : F<"nodefaultlib">,
142 HelpText<"Remove all default libraries">;
143 def noentry : F<"noentry">,
144 HelpText<"Don't add reference to DllMainCRTStartup; only valid with /dll">;
145 def profile : F<"profile">;
146 def repro : F<"Brepro">,
147 HelpText<"Use a hash of the executable as the PE header timestamp">;
148 def reproduce : Joined<["/", "-", "/?", "-?"], "reproduce:">,
149 MetaVarName<"filename">,
150 HelpText<"Write tar file containing inputs and command to reproduce link">;
151 def swaprun : P<"swaprun",
152 "Comma-separated list of 'cd' or 'net'">;
153 def swaprun_cd : F<"swaprun:cd">, Alias<swaprun>, AliasArgs<["cd"]>,
154 HelpText<"Make loader run output binary from swap instead of from CD">;
155 def swaprun_net : F<"swaprun:net">, Alias<swaprun>, AliasArgs<["net"]>,
156 HelpText<"Make loader run output binary from swap instead of from network">;
157 def verbose : F<"verbose">;
158 def wholearchive_flag : F<"wholearchive">,
159 HelpText<"Include all object files from all libraries">;
161 def force : F<"force">,
162 HelpText<"Allow undefined and multiply defined symbols">;
163 def force_unresolved : F<"force:unresolved">,
164 HelpText<"Allow undefined symbols when creating executables">;
165 def force_multiple : F<"force:multiple">,
166 HelpText<"Allow multiply defined symbols when creating executables">;
167 def force_multipleres : F<"force:multipleres">,
168 HelpText<"Allow multiply defined resources when creating executables">;
169 defm WX : B<"WX", "Treat warnings as errors", "Don't treat warnings as errors">;
171 defm allowbind : B<"allowbind", "Enable DLL binding (default)",
172 "Disable DLL binding">;
173 defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
174 "Disable DLL isolation">;
175 defm appcontainer : B<"appcontainer",
176 "Image can only be run in an app container",
177 "Image can run outside an app container (default)">;
178 defm cetcompat : B<"cetcompat", "Mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack",
179 "Don't mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack (default)">;
180 defm dynamicbase : B<"dynamicbase", "Enable ASLR (default unless /fixed)",
181 "Disable ASLR (default when /fixed)">;
182 defm fixed : B<"fixed", "Disable base relocations",
183 "Enable base relocations (default)">;
184 defm highentropyva : B<"highentropyva",
185 "Enable 64-bit ASLR (default on 64-bit)",
186 "Disable 64-bit ASLR">;
187 defm incremental : B<"incremental",
188 "Keep original import library if contents are unchanged",
189 "Overwrite import library even if contents are unchanged">;
190 defm integritycheck : B<"integritycheck",
191 "Set FORCE_INTEGRITY bit in PE header",
192 "No effect (default)">;
193 defm largeaddressaware : B<"largeaddressaware",
194 "Enable large addresses (default on 64-bit)",
195 "Disable large addresses (default on 32-bit)">;
196 defm nxcompat : B<"nxcompat", "Enable data execution prevention (default)",
197 "Disable data execution provention">;
198 defm safeseh : B<"safeseh",
199 "Produce an image with Safe Exception Handler (only for x86)",
200 "Don't produce an image with Safe Exception Handler">;
201 defm tsaware : B<"tsaware",
202 "Create Terminal Server aware executable (default)",
203 "Create non-Terminal Server aware executable">;
205 def help : F<"help">;
207 // /?? and -?? must be before /? and -? to not confuse lib/Options.
208 def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
211 defm auto_import : B_priv<"auto-import">;
212 defm runtime_pseudo_reloc : B_priv<"runtime-pseudo-reloc">;
213 def end_lib : F<"end-lib">,
214 HelpText<"End group of objects treated as if they were in a library">;
215 def exclude_all_symbols : F<"exclude-all-symbols">;
216 def export_all_symbols : F<"export-all-symbols">;
217 defm demangle : B<"demangle",
218 "Demangle symbols in output (default)",
219 "Do not demangle symbols in output">;
220 def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
221 HelpText<"Add symbol as undefined, but allow it to remain undefined">;
222 def kill_at : F<"kill-at">;
223 def lldmingw : F<"lldmingw">;
224 def noseh : F<"noseh">;
225 def osversion : P_priv<"osversion">;
226 def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
227 def pdb_source_path : P<"pdbsourcepath",
228 "Base path used to make relative source file path absolute in PDB">;
229 def rsp_quoting : Joined<["--"], "rsp-quoting=">,
230 HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
231 def start_lib : F<"start-lib">,
232 HelpText<"Start group of objects treated as if they were in a library">;
233 defm stdcall_fixup : B_priv<"stdcall-fixup">;
234 def thinlto_emit_imports_files :
235 F<"thinlto-emit-imports-files">,
236 HelpText<"Emit .imports files with -thinlto-index-only">;
237 def thinlto_index_only :
238 F<"thinlto-index-only">,
239 HelpText<"Instead of linking, emit ThinLTO index files">;
240 def thinlto_index_only_arg : P<
241 "thinlto-index-only",
242 "-thinlto-index-only and also write native module names to file">;
243 def thinlto_object_suffix_replace : P<
244 "thinlto-object-suffix-replace",
245 "'old;new' replace old suffix with new suffix in ThinLTO index">;
246 def thinlto_prefix_replace: P<
247 "thinlto-prefix-replace",
248 "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
249 def lto_obj_path : P<
251 "output native object for merged LTO unit to this path">;
252 def lto_cs_profile_generate: F<"lto-cs-profile-generate">,
253 HelpText<"Perform context sensitive PGO instrumentation">;
254 def lto_cs_profile_file : P<"lto-cs-profile-file",
255 "Context sensitive profile file path">;
256 defm lto_pgo_warn_mismatch: B<
257 "lto-pgo-warn-mismatch",
258 "turn on warnings about profile cfg mismatch (default)>",
259 "turn off warnings about profile cfg mismatch">;
260 def dash_dash_version : Flag<["--"], "version">,
261 HelpText<"Display the version number and exit">;
263 : P<"threads", "Number of threads. '1' disables multi-threading. By "
264 "default all available hardware threads are used">;
265 def call_graph_ordering_file: P<
266 "call-graph-ordering-file",
267 "Layout sections to optimize the given callgraph">;
268 defm call_graph_profile_sort: B<
269 "call-graph-profile-sort",
270 "Reorder sections with call graph profile (default)",
271 "Do not reorder sections with call graph profile">;
272 def print_symbol_order: P<
273 "print-symbol-order",
274 "Print a symbol order specified by /call-graph-ordering-file and "
275 "/call-graph-profile-sort into the specified file">;
276 def wrap : P_priv<"wrap">;
278 // Flags for debugging
279 def lldmap : F<"lldmap">;
280 def lldmap_file : P_priv<"lldmap">;
282 def map_file : P_priv<"map">;
283 def show_timing : F<"time">;
284 def summary : F<"summary">;
286 //==============================================================================
287 // The flags below do nothing. They are defined only for link.exe compatibility.
288 //==============================================================================
290 def ignoreidl : F<"ignoreidl">;
291 def ltcg : F<"ltcg">;
292 def nologo : F<"nologo">;
293 def throwingnew : F<"throwingnew">;
294 def editandcontinue : F<"editandcontinue">;
295 def fastfail : F<"fastfail">;
297 def delay : P_priv<"delay">;
298 def errorreport : P_priv<"errorreport">;
299 def idlout : P_priv<"idlout">;
300 def ilk : P_priv<"ilk">;
301 def ltcg_opt : P_priv<"ltcg">;
302 def ltcgout : P_priv<"ltcgout">;
303 def maxilksize : P_priv<"maxilksize">;
304 def tlbid : P_priv<"tlbid">;
305 def tlbout : P_priv<"tlbout">;
306 def verbose_all : P_priv<"verbose">;
307 def guardsym : P_priv<"guardsym">;