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