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